コード例 #1
0
        public  void WriteToFileTest()
        {
            //Arrange
            var changeItems = new List<ILoggable>();

            var customer = new Customer(1)
            {
                Email = "*****@*****.**",
                FirstName = "Rich",
                LastName = "Strong",
                AddressList = null
            };

            changeItems.Add(customer as ILoggable);

            var product = new Product(2)
            {
                ProductName = "Beef meat",
                ProductDescription="Scottish beef ",
                CurrentPrice = 8M
            };

            changeItems.Add(product as ILoggable);
            //Act
            LoggingServices.WriteToFile(changeItems);
            
            //Assert
            //Nothing to Assert >>

        }
コード例 #2
0
        public void RetrieveExistingWithAddress()
        {
            //Arrange
            var customerRepository = new CustomersRepository();
            var expected = new Customer(1)
            {
                Email = "*****@*****.**",
                FirstName = "strong",
                LastName = "unknow",

                AddressList = new List<Address>()
                {
                    new Address()
                    {
                        AddressType = 1,
                        StreetLineOne = "Good Year",
                        StreetLineTwo = "Good Harvest",
                        City = "Brigton",
                        State = "Shine",
                        Country = "Central UK",
                        PostCode = "144HU"
                    },

                    new Address()
                    {
                        AddressType = 2,
                        StreetLineOne = "Good Year 2",
                        StreetLineTwo = "Good Harvest 2",
                        City = "London",
                        State = "London",
                        Country = "Central UK 2",
                        PostCode = "144HU 2"
                    }
                }
            };


            //Act
            var actual = customerRepository.Retrieve(1);

            //Assert
            Assert.AreEqual(expected.CustomerID,actual.CustomerID);
            Assert.AreEqual(expected.Email,actual.Email);
            Assert.AreEqual(expected.FirstName,actual.FirstName);
            Assert.AreEqual(expected.LastName, actual.LastName);

            for (int i = 0; i < 1; i++)
            {
                Assert.AreEqual(expected.AddressList[i].AddressType,actual.AddressList[i].AddressType);
                Assert.AreEqual(expected.AddressList[i].StreetLineOne,actual.AddressList[i].StreetLineOne);
                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].Country,actual.AddressList[i].State);
                Assert.AreEqual(expected.AddressList[i].PostCode,actual.AddressList[i].PostCode);

            }

        }
コード例 #3
0
        public void LastNameEmpty()
        {
            Customer customer = new Customer();

            customer.FirstName = "bilbo";
            string expected = "bilbo";

            string actual = "bilbo";

            Assert.AreEqual(expected,actual);
        }
コード例 #4
0
        public void FirstNameEmpty()
        {
            Customer customer = new Customer();

            customer.LastName = " strong";
            string expected = " strong";

            string actual = customer.FullName;

            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void ValidateValid()
        {
            // Arrange
            var customer = new Customer();

            customer.LastName = "strong";
            customer.Email = "*****@*****.**";

            var expected = true;
            // Act
            var actual = customer.Validate();

            // Assert
            Assert.AreEqual(expected,actual);
        }
コード例 #6
0
        public Customer Retrieve(int customerID)
        {
            //Create the instance of the Customer class
            Customer customer = new Customer(customerID);

            customer.AddressList = addressRepository.RetrieveByCustomerID(customerID)
                .ToList();
                
            // to return a populate Customer;
            if (customerID == 1)
            {
                customer.Email = "*****@*****.**";
                customer.FirstName = "unknown";
                customer.LastName = "strong";
            }

            return customer;
        }
コード例 #7
0
        public void StaticTest()
        {
            //Arrange
            var varOne = new Customer();
            varOne.FirstName = "bilbo";
            Customer.InstanceCount += 1;

            var varTwo = new Customer();
            varTwo.FirstName = "strong";
            Customer.InstanceCount += 1;

            var varThree = new Customer();
            varThree.FirstName = "Rosse";
            Customer.InstanceCount += 1;
            //Act

            //Assert
            Assert.AreEqual(3,Customer.InstanceCount);
        }
コード例 #8
0
        public void FuulNameTestValid()
        {
            
            #region Arrange 

            Customer customer = new Customer();
            customer.FirstName = "bilbo";
            customer.LastName = "strong";

            string expected = "strong,bilbo";
            #endregion Arrange

            #region Act
            string actual = customer.FullName;

            #endregion Act
            #region Assert

            Assert.AreEqual(expected,actual);
            #endregion Assert
        }
コード例 #9
0
        public void RetriveExiting()
        {
            //Arrange
            var customerRepository = new CustomersRepository();
            var expected = new Customer(1)
            {
                Email = "*****@*****.**",
                FirstName = "unknown",
                LastName = "strong"
            };

            //Act
            var actual = customerRepository.Retrieve(1);

            //Assert
            //Assert.AreEqual(expected,actual);
            Assert.AreEqual(expected.CustomerID,actual.CustomerID);
            Assert.AreEqual(expected.Email,actual.Email);
            Assert.AreEqual(expected.FirstName,actual.FirstName);
            Assert.AreEqual(expected.LastName,actual.LastName);

        }
コード例 #10
0
        public void ValidateMissingLastName()
        {
            //Arrange
            var customer = new Customer();
            customer.Email = "*****@*****.**";
            //Act
            var expected = false;
            var actual = customer.Validate();
            //Assert
            Assert.AreEqual(expected,actual);

        }