Пример #1
0
 [Test] public void Test_Insensitive()
 {
     JID j = new JID("foo@boo/bar");
     Assert.AreEqual(0, j.CompareTo(new JID("foo@BOO/bar")));
     Assert.AreEqual(0, j.CompareTo(new JID("FOO@boo/bar")));
     Assert.AreEqual(0, j.CompareTo(new JID("FOO@BOO/bar")));
     Assert.AreEqual(-1, j.CompareTo(new JID("FOO@BOO/BAR")));
 }
Пример #2
0
 [Test] public void Test_BadCompare()
 {
     try
     {
         JID j = new JID("foo@boo/bar");
         j.CompareTo("foo@boo/bar");
         Assert.IsTrue(false);
     }
     catch (ArgumentException)
     {
         Assert.IsTrue(true);
     }
     catch (Exception)
     {
         Assert.IsTrue(false);
     }
 }
Пример #3
0
 [Test] public void Test_Compare_Less()
 {
     JID j = new JID("foo@bar/baz");
     Assert.AreEqual(-1, j.CompareTo(new JID("foo@bas/baz")));
     Assert.AreEqual(-1, j.CompareTo(new JID("fop@bar/baz")));
     Assert.AreEqual(-1, j.CompareTo(new JID("foo@bar/bazz")));
     j = new JID("foo@bar");
     Assert.AreEqual(-1, j.CompareTo(new JID("foo@bas/baz")));
     Assert.AreEqual(-1, j.CompareTo(new JID("foo@bas")));
     Assert.AreEqual(-1, j.CompareTo(new JID("fop@bar/baz")));
     Assert.AreEqual(-1, j.CompareTo(new JID("fop@bar")));
     Assert.AreEqual(-1, j.CompareTo(new JID("foo@bar/baz")));
     j = new JID("bar");
     Assert.AreEqual(-1, j.CompareTo(new JID("foo@bar/baz")));
     Assert.AreEqual(-1, j.CompareTo(new JID("foo@bar")));
     Assert.AreEqual(-1, j.CompareTo(new JID("bas")));
     Assert.AreEqual(-1, j.CompareTo(new JID("bas/baz")));
     Assert.AreEqual(-1, j.CompareTo(new JID("bar/baz")));
     Assert.AreEqual(true, j < new JID("foo@bar/baz"));
     Assert.AreEqual(true, j <= new JID("foo@bar/baz"));
 }
Пример #4
0
 [Test] public void Test_Compare_Greater()
 {
     JID j = new JID("foo@bar/baz");
     Assert.AreEqual(1, j.CompareTo(new JID("foo@bap/baz")));
     Assert.AreEqual(1, j.CompareTo(new JID("fon@bar/baz")));
     Assert.AreEqual(1, j.CompareTo(new JID("foo@bar/bay")));
     Assert.AreEqual(1, j.CompareTo(new JID("foo@bar")));
     Assert.AreEqual(1, j.CompareTo(new JID("bar")));
     Assert.AreEqual(1, j.CompareTo(new JID("bar/baz")));
     j = new JID("foo@bar");
     Assert.AreEqual(1, j.CompareTo(new JID("foo@bap/baz")));
     Assert.AreEqual(1, j.CompareTo(new JID("fon@bar/baz")));
     Assert.AreEqual(1, j.CompareTo(new JID("bar")));
     Assert.AreEqual(1, j.CompareTo(new JID("bar/baz")));
     Assert.AreEqual(true, j > new JID("foo@bap/baz"));
     Assert.AreEqual(true, j >= new JID("foo@bap/baz"));
     // /me runs out of interest.
 }
Пример #5
0
 [Test] public void Test_Compare_Equal()
 {
     JID j = new JID("foo@bar/baz");
     Assert.AreEqual(0, j.CompareTo(j));
     Assert.AreEqual(0, j.CompareTo(new JID("foo@bar/baz")));
     j = new JID("foo@bar");
     Assert.AreEqual(0, j.CompareTo(j));
     Assert.AreEqual(0, j.CompareTo(new JID("foo@bar")));
     Assert.IsTrue(j == new JID("foo@bar"));
     Assert.IsTrue(j == new JID("foo@BAR"));
     Assert.IsTrue(j == new JID("FOO@BAR"));
     Assert.IsTrue(j == new JID("FOO@bar"));
     Assert.AreEqual(new JID("FOO@bar").GetHashCode(), j.GetHashCode());
     j = new JID("bar");
     Assert.AreEqual(0, j.CompareTo(j));
     Assert.AreEqual(0, j.CompareTo(new JID("bar")));
     j = new JID("foo/bar");
     Assert.AreEqual(0, j.CompareTo(j));
     Assert.AreEqual(0, j.CompareTo(new JID("foo/bar")));
     Assert.AreEqual(true, j >= new JID("foo/bar"));
     Assert.AreEqual(true, j <= new JID("foo/bar"));
 }