Пример #1
0
 public void ConstructByLocalNameAndNamespace()
 {
     TopicRevision revision = new TopicRevision("Foo", "Bar");
     Assert.AreEqual("Foo", revision.LocalName, "Checking that local name is correct.");
     Assert.AreEqual("Bar", revision.Namespace, "Checking that namespace is correct.");
     Assert.IsNull(revision.Version, "Checking that version is null when not specified."); 
 }
Пример #2
0
 public void ConstructByLocalNameNamespaceAndVersion()
 {
     TopicRevision revision = new TopicRevision("Foo", "Bar", "1.0");
     Assert.AreEqual("Foo", revision.LocalName, "Checking that local name is correct.");
     Assert.AreEqual("Bar", revision.Namespace, "Checking that namespace is correct.");
     Assert.AreEqual("1.0", revision.Version, "Checking that version is correct.");
 }
Пример #3
0
 public void ConstructDefault()
 {
     TopicRevision revision = new TopicRevision();
     Assert.IsNull(revision.LocalName, "Checking that local name is null by default.");
     Assert.IsNull(revision.Namespace, "Checking that namespace is null by default.");
     Assert.IsNull(revision.Version, "Checking that version is null by default.");
 }
Пример #4
0
        public void CompareTo()
        {
            TopicRevision aa11 = new TopicRevision("A", "A", "1");
            TopicRevision aa12 = new TopicRevision("A", "A", "1");
            TopicRevision aa21 = new TopicRevision("A", "A", "2");
            TopicRevision ab11 = new TopicRevision("A", "B", "1");
            TopicRevision ba11 = new TopicRevision("B", "A", "1");

            Assert.AreEqual(0, aa11.CompareTo(aa11), "Checking that an object compares equal to itself.");
            Assert.AreEqual(0, aa11.CompareTo(aa12), "Checking that an object compares equal to an equivalent object.");
            Assert.AreEqual(-1, aa11.CompareTo(aa21), "Checking that an object with a higher version compares higher.");
            Assert.AreEqual(1, aa21.CompareTo(aa11), "Checking that an object with a lower version compares lower.");
            Assert.AreEqual(-1, aa11.CompareTo(ab11), "Checking that an object with a higher namespace compares higher.");
            Assert.AreEqual(1, ab11.CompareTo(aa11), "Checking that an object with a lower namespace compares lower.");
            Assert.AreEqual(-1, aa11.CompareTo(ba11), "Checking that an object with a higher local name compares higher.");
            Assert.AreEqual(1, ba11.CompareTo(aa11), "Checking that an object with a lower local name compares lower.");
            Assert.AreEqual(1, aa11.CompareTo(null), "Checking that an object compares greater than null.");

            QualifiedTopicRevision qualifiedRevision = new QualifiedTopicRevision("A", "A", "1");
            Assert.AreEqual(0, aa11.CompareTo(qualifiedRevision), "Checking that a QualifiedTopicRevision can compare successfully to a TopicRevision"); 
        }
Пример #5
0
        public void ConstructByString()
        {
            // format is revision, name, version
            string[][] data = {
                new string[] { "Foo", "Foo", null } ,
                new string[] { "Foo.Bar", "Foo.Bar", null } ,
                new string[] { "Cat.Dog.Hello", "Cat.Dog.Hello", null } ,
                new string[] { "Hello()", "Hello", null } ,
                new string[] { "Hello(123-abc)", "Hello", "123-abc" } , 
            };
            string[] revisions = { "Foo", "Foo.Bar", "Cat.Dog.Hello", "Hello()" };
            string[] names = { "Foo", "Foo.Bar", "Cat.Dog.Hello", "Hello" };
            string[] versions = { null, null, null, null }; 

            for (int i = 0; i < data.Length; ++i)
            {
                string revisionName = data[i][0];
                string name = data[i][1];
                string version = data[i][2]; 

                TopicRevision revision = new TopicRevision(revisionName);
                Assert.AreEqual(revision.Name, new TopicName(name),
                    "Checking that name was correct during construction by name was successful for " + name); 
                Assert.AreEqual(revision.Version, version, 
                    "Checking that version was correct during construction by name was successful for " + name); 
            }
            
        }
Пример #6
0
 public void ConstructByNull()
 {
     TopicRevision revision = new TopicRevision(null);
 }
Пример #7
0
 public void CompareToIncompatibleType()
 {
     TopicRevision revision = new TopicRevision("Foo");
     revision.CompareTo("Foo"); 
 }
Пример #8
0
        public void ResolveRelativeToFromUnqualified()
        {
            TopicRevision revision = new TopicRevision(new TopicName("TopicName"), "version");

            QualifiedTopicRevision qualifiedRevision = revision.ResolveRelativeTo("SomeNamespace");

            Assert.AreEqual("SomeNamespace.TopicName(version)", qualifiedRevision.DottedNameWithVersion,
                "Checking that the new namespace is used when resolving an unqualified name.");
        }
Пример #9
0
        public void NewOfSameType()
        {
            TopicRevision revision = new TopicRevision().NewOfSameType("A.B(C)");

            Assert.AreEqual(typeof(TopicRevision), revision.GetType(), "Checking that the newly created type is a TopicRevision.");
            Assert.AreEqual("A.B(C)", revision.DottedNameWithVersion, "Checking that the correct properties were parsed."); 
        }
Пример #10
0
        public void ResolveRelativeToFromQualified()
        {
            TopicRevision revision = new TopicRevision("TopicName", "Namespace", "version");

            QualifiedTopicRevision qualifiedRevision = revision.ResolveRelativeTo("SomeNamespace");

            Assert.AreEqual("Namespace.TopicName(version)", qualifiedRevision.DottedNameWithVersion,
                "Checking that the original namespace is kept when resolving an already-qualified revision.");
        }
Пример #11
0
        public void LocalNameForNullName()
        {
            TopicRevision revision = new TopicRevision();

            Assert.IsNull(revision.Name); 
            Assert.IsNull(revision.LocalName, "Checking that LocalName doesn't blow up even when Name is null."); 
        }
Пример #12
0
        public void GetHashCodeTests()
        {
            TopicRevision aa11 = new TopicRevision("A", "A", "1");
            TopicRevision aa12 = new TopicRevision("A", "A", "1");
            TopicRevision aa21 = new TopicRevision("A", "A", "2");
            TopicRevision ab11 = new TopicRevision("A", "B", "1");
            TopicRevision ba11 = new TopicRevision("B", "A", "1");

            Assert.AreEqual(aa11.GetHashCode(), aa11.GetHashCode(), 
                "Checking that an object always returns the same hash code.");
            Assert.AreEqual(aa12.GetHashCode(), aa11.GetHashCode(), 
                "Checking that an object returns the same hash code as an equivalent object.");
            Assert.IsFalse(aa11.GetHashCode() == aa21.GetHashCode(), 
                "Checking that an object with a different version returns a different hash code.");
            Assert.IsFalse(aa11.GetHashCode() == ab11.GetHashCode(), 
                "Checking that an object with a different namespace returns a different hash code.");
            Assert.IsFalse(aa11.GetHashCode() == ba11.GetHashCode(),
                "Checking that an object with a different local name returns a different hash code.");

        }
Пример #13
0
        public void EqualsTest()
        {
            TopicRevision aa11 = new TopicRevision("A", "A", "1");
            TopicRevision aa12 = new TopicRevision("A", "A", "1");
            TopicRevision aa21 = new TopicRevision("A", "A", "2");
            TopicRevision ab11 = new TopicRevision("A", "B", "1");
            TopicRevision ba11 = new TopicRevision("B", "A", "1");

            Assert.IsTrue(aa11.Equals(aa11), "Checking that an object compares equal to itself.");
            Assert.IsTrue(aa11.Equals(aa12), "Checking that an object compares equal to an equivalent object.");
            Assert.IsFalse(aa11.Equals(aa21), "Checking that an object is not equal to something with a different version.");
            Assert.IsFalse(aa11.Equals(ab11), "Checking that an object is not equal to something with a different namespace.");
            Assert.IsFalse(aa11.Equals(ba11), "Checking that an object is not equal to something with a different local name.");
            Assert.IsFalse(aa11.Equals(null), "Checking that an object is not equal to null."); 
        }
Пример #14
0
        public void TopicExistsRelativeQualifiedPositive()
        {
            Federation federation = WikiTestUtilities.SetupFederation("test://NamespaceManagerTests",
                TestContentSets.ImportingReferencingSet);
            NamespaceManager manager = federation.NamespaceManagerForNamespace("NamespaceOne");

            TopicRevision revision = new TopicRevision("OtherTopic", "NamespaceTwo");

            Assert.IsTrue(manager.TopicExists(revision, ImportPolicy.DoNotIncludeImports),
                "Checking that an existing topic returns true from TopicExists.");
        }
Пример #15
0
        public void TopicExistsRelativeUnqualifiedNegative()
        {
            Federation federation = WikiTestUtilities.SetupFederation("test://NamespaceManagerTests",
                TestContentSets.ImportingReferencingSet);
            NamespaceManager manager = federation.NamespaceManagerForNamespace("NamespaceOne");

            TopicRevision revision = new TopicRevision("NoSuchTopic");

            Assert.IsFalse(manager.TopicExists(revision, ImportPolicy.DoNotIncludeImports),
                "Checking that a nonexistent topic returns false from TopicExists.");

        }