Пример #1
0
        public void testList010()
        {
            EmailList el = new EmailList();

            // Using the generic "Wrap" API so that we can use this
            // test against any internationalized version of the ADK
            Email email1 = new Email(EmailType.Wrap("foo"), "*****@*****.**");
            Email email2 = new Email(EmailType.Wrap("foo"), "*****@*****.**");

            el.Add(email1);
            Assert.AreEqual(1, el.ChildCount, "Should have 1 email");

            el.Add(email2);
            Assert.AreEqual(2, el.ChildCount, "Should have 2 emails");

            Email[] children = el.ToArray();
            Assert.AreEqual(2, children.Length, "Should have 2 array elements");

            el.RemoveChild(email2);
            Assert.AreEqual(1, el.ChildCount, "Should have 1 email");

            el.RemoveChild(email1);
            Assert.AreEqual(0, el.ChildCount, "Should have 0 emails");

            children = el.ToArray();
            Assert.AreEqual(0, children.Length, "Should have 0 array elements");
        }
Пример #2
0
        public void testList020()
        {
            EmailList el = new EmailList();

            // Using the generic "Wrap" API so that we can use this
            // test against any internationalized version of the ADK
            Email email1 = new Email(EmailType.Wrap("asdfasdf"), "*****@*****.**");
            Email email2 = new Email(EmailType.Wrap("Primary"), "*****@*****.**");



            el.Add(email1);
            Assert.AreEqual(1, el.ChildCount, "Should have 1 email");

            el.Add(email2);
            Assert.AreEqual(2, el.ChildCount, "Should have 2 emails");


            Email email3 = new Email();

            email3.Type = "Alternate1";
            el.Add(email3);
            Assert.AreEqual(3, el.ChildCount, "Should have 3 emails");



            Email primary = el[EmailType.PRIMARY];

            Assert.IsNotNull(primary);

            primary = el["Primary"];
            Assert.IsNotNull(primary);


            Email secondary = el[EmailType.ALT1];

            Assert.IsNotNull(secondary);

            secondary = el["Alternate1"];
            Assert.IsNotNull(secondary);
        }
Пример #3
0
        public void testList020()
        {
            EmailList el = new EmailList();

            // Using the generic "Wrap" API so that we can use this
            // test against any internationalized version of the ADK
            Email email1 = new Email(EmailType.Wrap("foo"), "*****@*****.**");
            Email email2 = new Email(EmailType.Wrap("foo"), "*****@*****.**");


            el.Add(email1);
            el.Add(email2);

            Assert.IsNotNull(email1.Parent, "Parent should not be null");
            Assert.IsNotNull(email2.Parent, "Parent should not be null");

            el.Clear();
            Assert.AreEqual(0, el.ChildCount, "Should have 0 emails");
            Assert.IsNull(email1.Parent, "Parent should be null");
            Assert.IsNull(email2.Parent, "Parent should be null");
        }
Пример #4
0
        /**
         * Test that overriding equals works as expected
         */

        public void testEqualsOverride()
        {
            String assertedValue = "FOO";

            AddressType testEnum = AddressType.Wrap(assertedValue);

            // objects should be reflexively equal to themselves
            Assert.IsTrue(testEnum.Equals(testEnum), "Reflexive comparison should pass");

            // test with null comparison
            Assert.IsFalse(testEnum.Equals(null), "Null comparison should fail");

            AddressType testEnum2 = AddressType.Wrap(assertedValue);

            Assert.IsTrue(testEnum.Equals(testEnum2));
            Assert.IsTrue(testEnum2.Equals(testEnum));

            // Test with a different enum value
            AddressType testEnum3 = AddressType.MAILING;

            Assert.IsFalse(testEnum3.Equals(testEnum));
            Assert.IsFalse(testEnum.Equals(testEnum3));

            // Test with a different enum type, but same value
            EmailType differentEnum = EmailType.Wrap(assertedValue);

            Assert.IsFalse(differentEnum.Equals(testEnum));
            Assert.IsFalse(testEnum.Equals(differentEnum));

            // Test with two null values
            AddressType nullEnum  = AddressType.Wrap(null);
            AddressType nullEnum2 = AddressType.Wrap(null);

            Assert.IsTrue(nullEnum.Equals(nullEnum2), "Two Enums with null values should match");
            Assert.IsFalse(nullEnum.Equals(testEnum));
            Assert.IsFalse(testEnum.Equals(null));
        }
Пример #5
0
        public void testList030()
        {
            EmailList el = new EmailList();

            // Using the generic "Wrap" API so that we can use this
            // test against any internationalized version of the ADK
            Email email1 = new Email(EmailType.Wrap("foo"), "*****@*****.**");
            Email email2 = new Email(EmailType.Wrap("bar"), "*****@*****.**");

            el.Add(email1);
            el.Add(email2);

            // test the iterator
            int count = 0;

            foreach (Email e in el)
            {
                Assert.IsNotNull(e, "Email should not be null");
                Assert.AreEqual(24, e.TextValue.Length, "Should have email address");
                count++;
            }

            Assert.AreEqual(2, count, "Should have iterated 2 emails");
        }