Beispiel #1
0
        public void CreateShopCart_Passes_InputIsCorrect()
        {
            // Arrange
            var buyer     = new Buyer();
            var warehouse = new Warehouse();

            // Act& Assert

            buyer.CreateShopCart(warehouse);
        }
Beispiel #2
0
        private static void Main()
        {
            var warehouse = new Warehouse();

            var toyota = new Provider();

            toyota.AddProductToList(new Product {
                Price = 200, Name = "Mx5", Category = GoodsCategory.AutomotiveAndTransport, Provider = toyota
            });
            toyota.AddProductToList(new Product {
                Price = 150, Name = "Mx6", Category = GoodsCategory.AutomotiveAndTransport, Provider = toyota
            });
            toyota.AddProductToList(new Product {
                Price = 270, Name = "Mx7", Category = GoodsCategory.AutomotiveAndTransport, Provider = toyota
            });

            var cocaCola = new Provider();

            cocaCola.AddProductToList(new Product {
                Price = 3, Name = "1L", Category = GoodsCategory.FoodAndBeverage, Provider = cocaCola
            });
            cocaCola.AddProductToList(new Product {
                Price = 2, Name = "0.5L", Category = GoodsCategory.FoodAndBeverage, Provider = cocaCola
            });
            cocaCola.AddProductToList(new Product {
                Price = 4, Name = "1.5L", Category = GoodsCategory.FoodAndBeverage, Provider = cocaCola
            });


            toyota.SendGoodsToWarehouse(warehouse, toyota.GoodsList[0], 2);
            toyota.SendGoodsToWarehouse(warehouse, toyota.GoodsList[1], 20);
            toyota.SendGoodsToWarehouse(warehouse, toyota.GoodsList[2], 7);

            cocaCola.SendGoodsToWarehouse(warehouse, cocaCola.GoodsList[0], 200);
            cocaCola.SendGoodsToWarehouse(warehouse, cocaCola.GoodsList[1], 20);
            cocaCola.SendGoodsToWarehouse(warehouse, cocaCola.GoodsList[2], 700);

            var buyer = new Buyer {
                Name = "Vasya"
            };

            buyer.AddMoney(1000);
            buyer.CreateShopCart(warehouse);

            buyer.AddGoodsToCart(warehouse.GetShopList()[0], 2);
            buyer.AddGoodsToCart(warehouse.GetShopList()[1], 2);

            buyer.BuyGoods();
            Console.WriteLine(buyer.GetMoney());
            // var unused = warehouse.GetProductsByCategory(GoodsCategory.FoodAndBeverage);
        }
Beispiel #3
0
        public void AddGoodsToCart_Passes_InputIsCorrect()
        {
            // Arrange
            var buyer     = new Buyer();
            var warehouse = new Warehouse();

            buyer.CreateShopCart(warehouse);

            // Act
            buyer.AddGoodsToCart(new Product {
                Provider = null, Price = 100, Category = GoodsCategory.AutomotiveAndTransport, Name = "Test"
            }, 5);

            // Assert
            Assert.NotEmpty(buyer.GetShoppingCart());
        }
Beispiel #4
0
        public void CreateShopCart_ThrowsArgumentNullException_WareHouseIsNull()
        {
            // Arrange

            var buyer = new Buyer();

            //Act

            void Result()
            {
                buyer.CreateShopCart(null);
            }

            // Assert

            Assert.Throws <ArgumentNullException>(Result);
        }
Beispiel #5
0
        public void GetTotalPrice_Passes_InputIsCorrect()
        {
            // Arrange
            var buyer     = new Buyer();
            var warehouse = new Warehouse();

            buyer.CreateShopCart(warehouse);
            buyer.AddGoodsToCart(new Product {
                Provider = null, Price = 100, Category = GoodsCategory.AutomotiveAndTransport, Name = "Test"
            }, 5);

            // Act
            var result = Buyer.GetTotalPrice(buyer.GetShoppingCart());

            // Assert
            Assert.IsType <decimal>(result);
        }
Beispiel #6
0
        public void AddGoodsToCart_ThrowsArgumentNullException_ProductIsNull()
        {
            // Arrange

            var buyer     = new Buyer();
            var warehouse = new Warehouse();

            buyer.CreateShopCart(warehouse);

            //Act

            void Result()
            {
                buyer.AddGoodsToCart(null, 10);
            }

            // Assert

            Assert.Throws <ArgumentNullException>(Result);
        }
Beispiel #7
0
        public void AddGoodsToCart_ThrowsArgumentOutOfRangeException_AmountIsLessThatZero()
        {
            // Arrange

            var buyer     = new Buyer();
            var warehouse = new Warehouse();

            buyer.CreateShopCart(warehouse);

            //Act

            void Result()
            {
                buyer.AddGoodsToCart(new Product {
                    Provider = null, Price = 100, Category = GoodsCategory.AutomotiveAndTransport, Name = "Test"
                }, -5);
            }

            // Assert

            Assert.Throws <ArgumentOutOfRangeException>(Result);
        }