public void ConstructionByLocalName() { UnqualifiedTopicName topicName = new UnqualifiedTopicName("LocalName"); Assert.AreEqual("LocalName", topicName.LocalName); Assert.IsNull(topicName.Namespace); }
public void Name() { UnqualifiedTopicName name = new UnqualifiedTopicName("LocalName"); UnqualifiedTopicRevision revision = new UnqualifiedTopicRevision(name); Assert.AreEqual("LocalName", revision.Name.DottedName, "Checking that name is recorded correctly."); }
public override TopicChangeCollection AllChangesForTopicSince(UnqualifiedTopicName topicName, DateTime stamp) { MockTopic topic = GetTopic(topicName, ExistencePolicy.ExistingOnly); // If the topicName does not exist, return a null list if (topic == null) { return null; } TopicChangeCollection changes = new TopicChangeCollection(); foreach (MockTopicHistory topicHistory in topic.History) { if (topicHistory.Created >= stamp) { QualifiedTopicRevision namespaceQualifiedTopic = new QualifiedTopicRevision(topicName.LocalName, Namespace); namespaceQualifiedTopic.Version = TopicRevision.NewVersionStringForUser(topicHistory.Author, topicHistory.Created); changes.Add(new TopicChange(namespaceQualifiedTopic, topicHistory.Created, topicHistory.Author)); } } return changes; }
public override void LockTopic(UnqualifiedTopicName topic) { Next.LockTopic(topic); }
public override void DeleteTopic(UnqualifiedTopicName topic, bool removeHistory) { Next.DeleteTopic(topic, removeHistory); }
public override bool TopicIsReadOnly(UnqualifiedTopicName name) { AddDependency(new TopicPermissionsDependency(name.ResolveRelativeTo(Namespace))); return Next.TopicIsReadOnly(name); }
public void NamespaceSet() { UnqualifiedTopicName topicName = new UnqualifiedTopicName(); topicName.Namespace = "Foo"; }
private void ProcessPost() { //NamespaceManager storeManager = Federation.NamespaceManagerForNamespace(_preferredNamespace); _action = Request.Form["fileaction"]; _topic = Request.Form["topic"]; TopicName topic = new TopicName(_topic); UnqualifiedTopicName unqualifiedtopic = new UnqualifiedTopicName(topic.LocalName); NamespaceManager _namespacemgr = Federation.NamespaceManagerForTopic(topic); if (_namespacemgr.HasNamespacePermission(NamespacePermission.Manage)) { if (_action == "Lock") { _namespacemgr.LockTopic(unqualifiedtopic); } else if (_action == "Unlock") { _namespacemgr.UnlockTopic(unqualifiedtopic); } } }
public override bool HasPermission(UnqualifiedTopicName topic, TopicPermission permission) { _hasPermissionCalled = true; MockTopic mockTopic = GetTopic(topic, ExistencePolicy.ExistingOnly); if (mockTopic == null) { return true; } if (permission == TopicPermission.Edit) { return mockTopic.Latest.CanWrite; } else if (permission == TopicPermission.Read) { return mockTopic.Latest.CanRead; } else { throw new ArgumentException("Unrecognized TopicPermission " + permission.ToString()); } }
public override void DeleteTopic(UnqualifiedTopicName topicName, bool removeHistory) { MockTopic topic = GetTopic(topicName, ExistencePolicy.All); topic.DeleteLatest(); }
public void GetTopicCreationTimeModifiedVersion() { Federation federation = WikiTestUtilities.SetupFederation("test://NamespaceManagerTests", TestContentSets.MultipleVersions); NamespaceManager manager = federation.NamespaceManagerForNamespace("NamespaceOne"); // Flip through the history and get the oldest version UnqualifiedTopicName topicName = new UnqualifiedTopicName("TopicOne"); TopicChangeCollection changes = manager.AllChangesForTopic(topicName); UnqualifiedTopicRevision revision = new UnqualifiedTopicRevision(topicName.LocalName, changes[0].Version); manager.WriteTopic(revision, "Modified content"); DateTime creationTime = manager.GetTopicCreationTime(revision); Assert.AreEqual(new DateTime(2004, 10, 28, 14, 11, 02), creationTime, "Checking that the creation time for the first version doesn't change even when modified."); }
public void WriteTopicSpecificVersion() { Federation federation = WikiTestUtilities.SetupFederation("test://NamespaceManagerTests", TestContentSets.MultipleVersions); NamespaceManager manager = federation.NamespaceManagerForNamespace("NamespaceOne"); UnqualifiedTopicName topicName = new UnqualifiedTopicName("TopicOne"); TopicChangeCollection changes = manager.AllChangesForTopic(topicName); UnqualifiedTopicRevision revision = new UnqualifiedTopicRevision(topicName, changes[1].Version); string newContents = "New contents"; manager.WriteTopic(revision, newContents); string actualContents = manager.Read(revision); Assert.AreEqual(changes.Count, manager.AllChangesForTopic(topicName).Count, "Checking that no new versions were created."); Assert.AreEqual(newContents, actualContents, "Checking that content was updated correctly."); }
public void TextReaderForTopicHistorical() { Federation federation = WikiTestUtilities.SetupFederation("test://NamespaceManagerTests", TestContentSets.SingleTopicNoImports); NamespaceManager manager = federation.NamespaceManagerForNamespace("NamespaceOne"); UnqualifiedTopicName topicName = new UnqualifiedTopicName("TopicOne"); manager.WriteTopicAndNewVersion(topicName, "new content", "author"); string historicalVersion = manager.AllChangesForTopic(topicName)[0].Version; Assert.AreEqual("new content", manager.TextReaderForTopic(topicName).ReadToEnd(), "Checking that latest content is returned when no version is supplied."); Assert.AreEqual("content", manager.TextReaderForTopic(new UnqualifiedTopicRevision(topicName, historicalVersion)).ReadToEnd(), "Checking that historical content is returned when requested."); }
public void RenameTopicWithFixups() { Federation federation = WikiTestUtilities.SetupFederation("test://NamespaceManagerTests/", TestContentSets.ImportingReferencingSet); NamespaceManager manager = federation.NamespaceManagerForNamespace("NamespaceOne"); UnqualifiedTopicName oldName = new UnqualifiedTopicName("ReferencedTopic"); UnqualifiedTopicName newName = new UnqualifiedTopicName("ReferencedTopicRenamed"); RenameTopicDetails details = manager.RenameTopic(oldName, newName, ReferenceFixupPolicy.FixReferences, "rename"); // Note that we don't fix up references from other namespaces. Assert.AreEqual(1, details.UpdatedReferenceTopics.Count, "Checking that the right number of fixups were reported."); Assert.AreEqual("NamespaceOne.ReferencingTopic", details.UpdatedReferenceTopics[0].DottedName, "Checking that the right topic was fixed up."); string contents = manager.Read("ReferencingTopic"); Assert.IsTrue(contents.Contains("ReferencedTopicRenamed"), "Checking that the topic fixup was done correctly."); }
public void RenameTopicToExistingTopic() { Federation federation = WikiTestUtilities.SetupFederation("test://NamespaceManagerTests/", TestContentSets.NonImportingReferencingSet); NamespaceManager manager = federation.NamespaceManagerForNamespace("NamespaceOne"); UnqualifiedTopicName oldName = new UnqualifiedTopicName("ReferencingTopic"); UnqualifiedTopicName newName = new UnqualifiedTopicName("ReferencedTopic"); RenameTopicDetails details = manager.RenameTopic(oldName, newName, ReferenceFixupPolicy.DoNotFixReferences, "rename"); Assert.AreEqual(RenameTopicResult.DestinationTopicExists, details.Result, "Checking that the result of the operation is 'DestinationTopicExists'."); Assert.AreEqual(0, details.UpdatedReferenceTopics.Count, "Checking that no topics were reported updated."); }
public override bool TopicExists(UnqualifiedTopicName name) { RegisterCall(MethodInfo.GetCurrentMethod()); throw new NotImplementedException(); }
public override void WriteTopicAndNewVersion(UnqualifiedTopicName topic, string content, string author) { RegisterCall(MethodInfo.GetCurrentMethod()); throw new NotImplementedException(); }
public override bool TopicExists(UnqualifiedTopicName name) { _topicExistsCalled = true; return GetTopic(name, ExistencePolicy.ExistingOnly) != null; }
public void ConstructionByEmptyNamespace() { UnqualifiedTopicName topicName = new UnqualifiedTopicName(".FooBar"); Assert.IsNull(topicName.Namespace, "Checking that the namespace is null."); Assert.AreEqual("FooBar", topicName.LocalName, "Checking that the local name is correct."); }
public override bool TopicIsReadOnly(UnqualifiedTopicName name) { _topicIsReadOnlyCalled = true; MockTopic topic = GetTopic(name, ExistencePolicy.ExistingOnly); if (topic == null) { return false; } else { return !topic.Latest.CanWrite; } }
public void ConstructionByQualifiedName() { UnqualifiedTopicName topicName = new UnqualifiedTopicName("Dotted.Namespace.LocalName"); }
public override void UnlockTopic(UnqualifiedTopicName topic) { MockTopic mockTopic = GetTopic(topic, ExistencePolicy.ExistingOnly); mockTopic.Latest.CanWrite = true; }
public void NullLocalName() { UnqualifiedTopicName topicName = new UnqualifiedTopicName(null); }
private MockTopic GetTopic(UnqualifiedTopicName topicName, ExistencePolicy existencePolicy) { return GetTopic(topicName.LocalName, existencePolicy); }
public override TopicChangeCollection AllChangesForTopicSince(UnqualifiedTopicName topic, DateTime stamp) { AddDependency(new TopicContentsDependency(topic.ResolveRelativeTo(Namespace))); return Next.AllChangesForTopicSince(topic, stamp); }
public override TopicChangeCollection AllChangesForTopicSince(UnqualifiedTopicName topic, DateTime stamp) { RegisterCall(MethodInfo.GetCurrentMethod()); throw new NotImplementedException(); }
public override bool HasPermission(UnqualifiedTopicName topic, TopicPermission permission) { AddDependency(new TopicPermissionsDependency(topic.ResolveRelativeTo(Namespace))); return Next.HasPermission(topic, permission); }
public override void DeleteTopic(UnqualifiedTopicName topic) { RegisterCall(MethodInfo.GetCurrentMethod()); throw new NotImplementedException(); }
public override bool TopicExists(UnqualifiedTopicName name) { AddDependency(new TopicExistenceDependency(name.ResolveRelativeTo(Namespace))); return Next.TopicExists(name); }
public override bool IsExistingTopicWritable(UnqualifiedTopicName topic) { RegisterCall(MethodInfo.GetCurrentMethod()); throw new NotImplementedException(); }