public void StringEnum_Equals_StringEnum_DifferentEnumType()
        {
            StringEnum <SimpleEnum>      first  = SimpleEnum.First;
            StringEnum <DescriptionEnum> second = DescriptionEnum.First;

            Assert.IsFalse(first.Equals(second));
        }
        public void StringEnum_Equals_Null()
        {
            StringEnum <SimpleEnum> first  = SimpleEnum.First;
            StringEnum <SimpleEnum> second = "second";
            StringEnum <SimpleEnum> third  = "invalid";
            StringEnum <SimpleEnum> fourth = null;

            Assert.AreNotEqual(first, null);
            Assert.AreNotEqual(second, null);
            Assert.AreNotEqual(third, null);
            Assert.AreEqual(fourth, null);

            Assert.IsFalse(first == null);
            Assert.IsFalse(second == null);
            Assert.IsFalse(third == null);
            Assert.IsFalse(fourth != null);

            Assert.IsTrue(first != null);
            Assert.IsTrue(second != null);
            Assert.IsTrue(third != null);
            Assert.IsTrue(fourth == null);
            Assert.ReferenceEquals(fourth, null);
            Assert.IsFalse(first.Equals(null));
        }
Exemple #3
0
        public void TestEquals()
        {
            var str = new StringEnum("IMAP4rev1");
              var str2 = str;

              Assert.IsTrue(str.Equals(str2));
              Assert.IsTrue(str.Equals("IMAP4REV1"));
              Assert.IsTrue(str.Equals("imap4rev1"));
              Assert.IsTrue(str.Equals(new StringEnum("IMAP4rev1")));
              Assert.IsTrue(str.Equals(new StringEnum("IMAP4REV1")));
              Assert.IsTrue(str.Equals(new StringEnum("imap4rev1")));

              var str3 = new StringEnum("IMAP4");

              Assert.IsFalse(str.Equals(null));
              Assert.IsFalse(str.Equals(str3));
              Assert.IsFalse(str.Equals("IMAP4"));
              Assert.IsFalse(str.Equals("imap4"));
              Assert.IsFalse(str.Equals(new StringEnum("IMAP4")));
              Assert.IsFalse(str.Equals(new StringEnum("imap4")));
              Assert.IsFalse(str.Equals(ImapCapability.Imap4Rev1));
              Assert.IsFalse(str.Equals(new ImapCapability("IMAP4rev1")));
              Assert.IsFalse(str.Equals(new ImapCapability("IMAP4REV1")));
              Assert.IsFalse(str.Equals(new ImapCapability("imap4rev1")));
        }