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.");
        }
Пример #3
0
        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;
        }
Пример #4
0
 public override void LockTopic(UnqualifiedTopicName topic)
 {
     Next.LockTopic(topic);
 }
Пример #5
0
 public override void DeleteTopic(UnqualifiedTopicName topic, bool removeHistory)
 {
     Next.DeleteTopic(topic, removeHistory);
 }
Пример #6
0
 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";
 }
Пример #8
0
        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);
                }
            }
        }
Пример #9
0
        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());
            }
        }
Пример #10
0
        public override void DeleteTopic(UnqualifiedTopicName topicName, bool removeHistory)
        {
            MockTopic topic = GetTopic(topicName, ExistencePolicy.All);

            topic.DeleteLatest();
        }
Пример #11
0
        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.");
        }
Пример #12
0
        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.");

        }
Пример #13
0
        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.");

        }
Пример #14
0
        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.");
        }
Пример #15
0
        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.");

        }
Пример #16
0
 public override bool TopicExists(UnqualifiedTopicName name)
 {
     RegisterCall(MethodInfo.GetCurrentMethod());
     throw new NotImplementedException();
 }
Пример #17
0
 public override void WriteTopicAndNewVersion(UnqualifiedTopicName topic, string content, string author)
 {
     RegisterCall(MethodInfo.GetCurrentMethod());
     throw new NotImplementedException();
 }
Пример #18
0
        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.");
 }
Пример #20
0
        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");
 }
Пример #22
0
 public override void UnlockTopic(UnqualifiedTopicName topic)
 {
     MockTopic mockTopic = GetTopic(topic, ExistencePolicy.ExistingOnly);
     mockTopic.Latest.CanWrite = true;
 }
 public void NullLocalName()
 {
     UnqualifiedTopicName topicName = new UnqualifiedTopicName(null);
 }
Пример #24
0
 private MockTopic GetTopic(UnqualifiedTopicName topicName, ExistencePolicy existencePolicy)
 {
     return GetTopic(topicName.LocalName, existencePolicy);
 }
Пример #25
0
 public override TopicChangeCollection AllChangesForTopicSince(UnqualifiedTopicName topic, DateTime stamp)
 {
     AddDependency(new TopicContentsDependency(topic.ResolveRelativeTo(Namespace)));
     return Next.AllChangesForTopicSince(topic, stamp);
 }
Пример #26
0
 public override TopicChangeCollection AllChangesForTopicSince(UnqualifiedTopicName topic, DateTime stamp)
 {
     RegisterCall(MethodInfo.GetCurrentMethod());
     throw new NotImplementedException(); 
 }
Пример #27
0
 public override bool HasPermission(UnqualifiedTopicName topic, TopicPermission permission)
 {
     AddDependency(new TopicPermissionsDependency(topic.ResolveRelativeTo(Namespace)));
     return Next.HasPermission(topic, permission);
 }
Пример #28
0
 public override void DeleteTopic(UnqualifiedTopicName topic)
 {
     RegisterCall(MethodInfo.GetCurrentMethod());
     throw new NotImplementedException();
 }
Пример #29
0
 public override bool TopicExists(UnqualifiedTopicName name)
 {
     AddDependency(new TopicExistenceDependency(name.ResolveRelativeTo(Namespace)));
     return Next.TopicExists(name);
 }
Пример #30
0
 public override bool IsExistingTopicWritable(UnqualifiedTopicName topic)
 {
     RegisterCall(MethodInfo.GetCurrentMethod());
     throw new NotImplementedException();
 }