示例#1
0
        public void RetrieveOrderDisplayTest()
        {
            var orderRepository = new OrderRepository();
            var exprected       = new OrderDisplay()
            {
                FirstName       = "Bilbo",
                LastName        = "Baggins",
                OrderDate       = new DateTimeOffset(2014, 4, 14, 10, 00, 00, new TimeSpan(7, 0, 0)),
                ShippingAddress = new Address()
                {
                    AddressType = 1,
                    StreetLine1 = "Bag End",
                    StreetLine2 = "BagShot row",
                    City        = "Hobbiton",
                    State       = "Shire",
                    Country     = "Middle Earth",
                    PostalCode  = "144"
                },
                OrderDisplayItemList = new List <OrderDisplayItem>()
                {
                    new OrderDisplayItem()
                    {
                        OrderQuantity = 2,
                        ProductName   = "Sunflowers",
                        PurchasePrice = 15.96M
                    },
                    new OrderDisplayItem()
                    {
                        OrderQuantity = 3,
                        ProductName   = "Sunflowers1",
                        PurchasePrice = 145.96M
                    }
                }
            };

            var actual = orderRepository.RetrieveOderDisplay(10);
        }
示例#2
0
        public void SaveTestMissingOrderDatee()
        {
            //-- Arrange
            var orderRepository = new OrderRepository();
            var updateOrder     = new Order(2)
            {
                OrderDate  = null,
                OrderItems = new List <OrderItem>
                {
                    new OrderItem
                    {
                        ProductId     = 1,
                        PurchasePrice = 12m,
                        Quantity      = 2
                    }
                },
                HasChanges = true
            };
            //--Act
            var actual = orderRepository.Save(updateOrder);

            //Assert
            Assert.AreEqual(false, actual);
        }
示例#3
0
        public void SaveTestValid()
        {
            //-- Arrange
            var orderRepository = new OrderRepository();
            var updateOrder     = new Order(2)
            {
                OrderDate  = new DateTime(2020, 10, 09),
                OrderItems = new List <OrderItem>
                {
                    new OrderItem
                    {
                        ProductId     = 1,
                        PurchasePrice = 12m,
                        Quantity      = 2
                    }
                },
                HasChanges = true
            };
            //--Act
            var actual = orderRepository.Save(updateOrder);

            //Assert
            Assert.AreEqual(true, actual);
        }
示例#4
0
        public void RetrieveOrderDisplayTest()
        {
            // Arrange
            var orderRepository = new OrderRepository();
            var expected        = new OrderDisplay()
            {
                FirstName       = "Bilbo",
                LastName        = "Baggins",
                OrderDate       = new DateTimeOffset(2015, 7, 29, 10, 00, 00, new TimeSpan()),
                ShippingAddress = new Address()
                {
                    AddressType = 1,
                    StreetLine1 = "Bag End",
                    StreetLine2 = "Bagshot Row",
                    City        = "Hobbiton",
                    State       = "Shire",
                    Country     = "Middle Earth",
                    PostalCode  = "144"
                },
                orderDisplayItemList = new List <OrderDisplayItem>()
                {
                    new OrderDisplayItem()
                    {
                        ProductName   = "Sunflowers",
                        PurchasePrice = 15.96M,
                        OrderQuantity = 2
                    },
                    new OrderDisplayItem()
                    {
                        ProductName   = "Rake",
                        PurchasePrice = 6M,
                        OrderQuantity = 1
                    }
                }
            };

            // Actual
            // *Had fun with this one.  Good bug hunting experience.
            // OrderRepository above was set as = new OrderDisplay();
            // *Below was unable to locate the reference orderRepository.???
            // *Now corrected to be var orderRepository = new OrderRepository();
            // #RememberingTheGoodTimes!
            var actual = orderRepository.RetrieveOrderDisplay(10);

            // Assertion
            Assert.AreEqual(expected.FirstName, actual.FirstName);
            Assert.AreEqual(expected.LastName, actual.LastName);
            Assert.AreEqual(expected.OrderDate, actual.OrderDate);

            Assert.AreEqual(expected.ShippingAddress.AddressType, actual.ShippingAddress.AddressType);
            Assert.AreEqual(expected.ShippingAddress.StreetLine1, actual.ShippingAddress.StreetLine1);
            Assert.AreEqual(expected.ShippingAddress.City, actual.ShippingAddress.City);
            Assert.AreEqual(expected.ShippingAddress.State, actual.ShippingAddress.State);
            Assert.AreEqual(expected.ShippingAddress.Country, actual.ShippingAddress.Country);
            Assert.AreEqual(expected.ShippingAddress.PostalCode, actual.ShippingAddress.PostalCode);

            for (int i = 0; i < 1; i++)
            {
                Assert.AreEqual(expected.orderDisplayItemList[i].OrderQuantity, actual.orderDisplayItemList[i].OrderQuantity);
                Assert.AreEqual(expected.orderDisplayItemList[i].ProductName, actual.orderDisplayItemList[i].ProductName);
                Assert.AreEqual(expected.orderDisplayItemList[i].PurchasePrice, actual.orderDisplayItemList[i].PurchasePrice);
            }
        }
示例#5
0
        public void RetrieveOrderDisplayTest()
        {
            //-- Arrange
            var orderRepositoy = new OrderRepository();
            var expected       = new OrderDisplay()
            {
                FirstName       = "Bilbo",
                LastName        = "Baggins",
                OrderDate       = new DateTimeOffset(2014, 4, 14, 10, 00, 00, TimeSpan.FromHours(1)),
                ShippingAddress = new Address()
                {
                    AddressType = 1,
                    StreetLine1 = "Bad End",
                    StreetLine2 = "Bagshot Row",
                    City        = "Nobbiton",
                    State       = "Shire",
                    Country     = "Middle Earth",
                    PostalCode  = "144"
                },
                orderDisplayItemList = new List <OrderDisplayItem>()
                {
                    new OrderDisplayItem()
                    {
                        ProductName   = "Sunfliwers",
                        PurchasePrice = 15.96M,
                        OrderQuantity = 2
                    },


                    new OrderDisplayItem()
                    {
                        ProductName   = "Rake",
                        PurchasePrice = 6M,
                        OrderQuantity = 1
                    }
                }
            };

            //-- Act

            var actual = orderRepositoy.RetrieveOrderDisplay(10);

            //-- Assert
            Assert.AreEqual(expected.FirstName, actual.FirstName);
            Assert.AreEqual(expected.LastName, actual.LastName);
            Assert.AreEqual(expected.OrderDate, actual.OrderDate);

            Assert.AreEqual(expected.ShippingAddress.AddressType, actual.ShippingAddress.AddressType);
            Assert.AreEqual(expected.ShippingAddress.StreetLine1, actual.ShippingAddress.StreetLine1);
            Assert.AreEqual(expected.ShippingAddress.StreetLine2, actual.ShippingAddress.StreetLine2);
            Assert.AreEqual(expected.ShippingAddress.City, actual.ShippingAddress.City);
            Assert.AreEqual(expected.ShippingAddress.State, actual.ShippingAddress.State);
            Assert.AreEqual(expected.ShippingAddress.Country, actual.ShippingAddress.Country);
            Assert.AreEqual(expected.ShippingAddress.PostalCode, actual.ShippingAddress.PostalCode);

            for (int i = 0; i < 1; i++)
            {
                Assert.AreEqual(expected.orderDisplayItemList[i].OrderQuantity, actual.orderDisplayItemList[i].OrderQuantity);
                Assert.AreEqual(expected.orderDisplayItemList[i].ProductName, actual.orderDisplayItemList[i].ProductName);
                Assert.AreEqual(expected.orderDisplayItemList[i].PurchasePrice, actual.orderDisplayItemList[i].PurchasePrice);
            }
        }
示例#6
0
        public void RetrieveOrderDisplayTest()
        {
            //--Arrange
            var orderRepository = new OrderRepository();
            var expected        = new OrderDisplay()
            {
                FirstName       = "Bilbo",
                Lastname        = "Baggins",
                OrderDate       = new DateTimeOffset(2018, 6, 18, 12, 00, 00, new TimeSpan(07, 0, 0)),
                ShippingAddress = new Address()
                {
                    AddressType = 1,
                    StreetLine1 = "Bag End",
                    StreetLine2 = "Bagshot Row",
                    City        = "Hobbiton",
                    State       = "Shire",
                    PostalCode  = "144",
                    Country     = "Middle Earth"
                },
                OderDisplayItemList = new List <OrderDisplayItem>()
                {
                    new OrderDisplayItem()
                    {
                        OderQuantity  = 2,
                        ProductName   = "SunFlowers",
                        PurchasePrice = 15.99M
                    },
                    new OrderDisplayItem()
                    {
                        OderQuantity  = 2,
                        ProductName   = "Rake",
                        PurchasePrice = 12.99M,
                    }
                }
            };



            //--Act

            var actual = orderRepository.RetrieveOrderDisplay(10);



            //--Assert
            Assert.AreEqual(expected.FirstName, actual.FirstName);
            Assert.AreEqual(expected.Lastname, actual.Lastname);
            Assert.AreEqual(expected.OrderDate, actual.OrderDate);

            Assert.AreEqual(expected.ShippingAddress.AddressType, actual.ShippingAddress.AddressType);
            Assert.AreEqual(expected.ShippingAddress.StreetLine1, actual.ShippingAddress.StreetLine1);
            Assert.AreEqual(expected.ShippingAddress.StreetLine2, actual.ShippingAddress.StreetLine2);
            Assert.AreEqual(expected.ShippingAddress.State, actual.ShippingAddress.State);
            Assert.AreEqual(expected.ShippingAddress.City, actual.ShippingAddress.City);
            Assert.AreEqual(expected.ShippingAddress.Country, actual.ShippingAddress.Country);
            Assert.AreEqual(expected.ShippingAddress.PostalCode, actual.ShippingAddress.PostalCode);

            for (int i = 0; i < 1; i++)
            {
                Assert.AreEqual(expected.OderDisplayItemList[i].OderQuantity, actual.OderDisplayItemList[i].OderQuantity);
                Assert.AreEqual(expected.OderDisplayItemList[i].ProductName, actual.OderDisplayItemList[i].ProductName);
                Assert.AreEqual(expected.OderDisplayItemList[i].PurchasePrice, actual.OderDisplayItemList[i].PurchasePrice);
            }
        }