예제 #1
0
        public void TestErrorInResponse()
        {
            // Create non complete xml.
            string xml = XML_START;
            Stream s = GenerateStreamFromString(xml);
            ConventusAddressWrapper caw = new ConventusAddressWrapper();
            List<ConventusMedlem> result = null;

            Boolean xmlexceptionOccured = false;

            try
            {
                result = caw.getMembersFromXml(s);
            }
            catch (System.Xml.XmlException)
            {
                // Expected
                xmlexceptionOccured = true;

            }

            if (!xmlexceptionOccured)
            {
                Assert.Fail("XMLException should have occured");
            }
        }
예제 #2
0
        public void TestAllFieldsOneMember()
        {
            string xml = XML_START + XML_ALL_FIELDS_DEFINED + XML_END;

            Stream s = GenerateStreamFromString(xml);
            ConventusAddressWrapper caw = new ConventusAddressWrapper();
            List<ConventusMedlem> result = null;

            try
            {
                result = caw.getMembersFromXml(s);
            }
            catch (Exception e)
            {
                throw new AssertFailedException("Exception should not occur", e);
            }

            CollectionAssert.AllItemsAreNotNull(result);
            CollectionAssert.AllItemsAreUnique(result);
            Assert.IsTrue(result.Count == 1, "Only one result expected");

            ConventusMedlem m = result[0];

            Assert.AreEqual("Gammelgang 10", m.Adresse1);
            Assert.AreEqual("Testhus", m.Adresse2);
            Assert.AreEqual(137, m.AltID);
            Assert.AreEqual("*****@*****.**", m.Email, "Email is wrong");
            Assert.AreEqual(new DateTime(1974, 2, 14), m.Foedselsdato);
            Assert.AreEqual(1002282, m.Id);
            Assert.AreEqual(ConventusMedlem.KoenTypes.Mand, m.Koen);
            Assert.AreEqual("22720203", m.Mobilnummer);
            Assert.AreEqual("Svend Frydenlund", m.Navn);
            Assert.IsTrue(m.OffentligAdresse, "offentlig adresse");
            Assert.IsTrue(m.OffentligEmail, "Offentlig email");
            Assert.IsTrue(m.OffentligTelefon, "Offentlig telefon");
            Assert.IsTrue(m.OfffentligNavn, "Offentlig navn");
            Assert.AreEqual("2300", m.Postnummer);
            Assert.AreEqual("København S", m.PostnummerBy);
            Assert.IsFalse(m.Slettet, "Slettet");
            Assert.AreEqual("35373691", m.Telefonnummer);
        }
예제 #3
0
        public void TestMultipleMembers()
        {
            string xml = XML_START + XML_ALL_FIELDS_DEFINED + XML_ONLY_ID_DEFINED + XML_END;
            Stream s = GenerateStreamFromString(xml);
            ConventusAddressWrapper caw = new ConventusAddressWrapper();
            List<ConventusMedlem> result = null;

            try
            {
                result = caw.getMembersFromXml(s);
            }
            catch (Exception e)
            {
                throw new AssertFailedException("Exception should not occur", e);
            }

            CollectionAssert.AllItemsAreNotNull(result);
            CollectionAssert.AllItemsAreUnique(result);
            Assert.IsTrue(result.Count == 2, "2 results expected");
        }
예제 #4
0
        public void TestXmlWithOnlyIdSet()
        {
            string xml = XML_START + XML_ONLY_ID_DEFINED + XML_END;
            Stream s = GenerateStreamFromString(xml);

            ConventusAddressWrapper caw = new ConventusAddressWrapper();

            List<ConventusMedlem> result = null;

            try {result = caw.getMembersFromXml(s);
            } catch (Exception e) {
                throw new AssertFailedException("Exception should not occur", e);
            }

            CollectionAssert.AllItemsAreNotNull(result);
            CollectionAssert.AllItemsAreUnique(result);
            Assert.IsTrue(result.Count == 1, "Only one result expected");
            Assert.AreEqual(1234, result[0].Id, "id not as expected");
        }
예제 #5
0
        public void TestPostnummerEmailTelefonWithZeroValues()
        {
            string xml = XML_START + "<medlem><id>1234</id><postnr>0</postnr><email>0</email><tlf>0</tlf></medlem>" + XML_END;
            Stream s = GenerateStreamFromString(xml);

            ConventusAddressWrapper caw = new ConventusAddressWrapper();

            List<ConventusMedlem> result = null;

            try
            {
                result = caw.getMembersFromXml(s);
            }
            catch (Exception e)
            {
                throw new AssertFailedException("Exception should not occur", e);
            }

            CollectionAssert.AllItemsAreNotNull(result);
            CollectionAssert.AllItemsAreUnique(result);
            Assert.IsTrue(result.Count == 1, "Only one result expected");

            Assert.AreEqual(string.Empty, result[0].Postnummer, "Postnummer should be empty");
            Assert.AreEqual(string.Empty, result[0].Email, "Email should be empty");
            Assert.AreEqual(string.Empty, result[0].Telefonnummer, "Telefonnummer should be empty");
        }