Ejemplo n.º 1
0
        public void RetrieveExistingaddress()
        {
            //--Arrange
            var customerRepository = new CustomerRepository();
            var expected = new customer(1)
            {
                emailAddress = "*****@*****.**",
                FirstName = "Frodo",
                LastName = "Baggins",
                AddressList = new List<address>()
            {
                new address() {
                       addressType = 1,
                streetLine1 = "zulfiqar",
                streetLine2 = "12",
                city = "karachi",
                state = "sindh",
                country = "pakistan",
                postalCode = "75500"

                },
                new address() {

                addressType = 1,
                streetLine1 = "valencia",
                streetLine2 = "c-block",
                city = "lahore",
                state = "punjab",
                country = "pakistan",
                postalCode = "755"
                }

            }//address list closed
            };//object closed

            //--act
            var actual = customerRepository.Retrieve(1);

            //-- Assert

            //this assert check customer object names
            Assert.AreEqual(expected.customerID, actual.customerID);
            Assert.AreEqual(expected.emailAddress, actual.emailAddress);
            Assert.AreEqual(expected.FirstName, actual.FirstName);
            Assert.AreEqual(expected.LastName, actual.LastName);

            //this assert checks the addreses in the address list
            for (int i = 0; i < 1; i++)
            {
                Assert.AreEqual( expected.AddressList[i].addressType , actual.AddressList[i].addressType );
                Assert.AreEqual( expected.AddressList[i].streetLine1 , actual.AddressList[i].streetLine1 );
                Assert.AreEqual( expected.AddressList[i].streetLine2 , actual.AddressList[i].streetLine2 );
                Assert.AreEqual( expected.AddressList[i].city        , actual.AddressList[i].city        );
                Assert.AreEqual( expected.AddressList[i].state       , actual.AddressList[i].state       );
                Assert.AreEqual( expected.AddressList[i].postalCode  , actual.AddressList[i].postalCode  );
            }
        }
Ejemplo n.º 2
0
        public void RetrieveExisting()
        {
            //--Arrange
            var customerRepository = new CustomerRepository();
            var expected = new customer(1)
            {
                emailAddress = "*****@*****.**",
                FirstName = "Frodo",
                LastName = "Baggins"
            };

            //-- ACT
            var actual = customerRepository.Retrieve(1);

            //--Assert
            //here expected was another opbject and actual was another object of customer *see defination
            //so now we will compare indicidual values
            //Assert.AreEqual(expected, actual); -----------cant use this in Objects case

              /*Match ID's*/      Assert.AreEqual(expected.customerID, actual.customerID);
              /*Match Email*/      Assert.AreEqual(expected.emailAddress, actual.emailAddress);
              /*Match First_Name*/      Assert.AreEqual(expected.FirstName, actual.FirstName);
              /*Match Last_Name*/      Assert.AreEqual(expected.LastName, actual.LastName);
        }