Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public void AddProductToList_Passes_InputIsCorrect()
        {
            // Arrange
            var provider = new Provider();

            // Act
            provider.AddProductToList(new Product {
                Provider = provider, Price = 100, Category = GoodsCategory.AutomotiveAndTransport, Name = "Test"
            });

            // Assert
            Assert.Single(provider.GoodsList);
        }
Exemplo n.º 3
0
        public void AddProductToList_ThrowsArgumentNullException_ProductsIsNull()
        {
            // Arrange
            var provider = new Provider();

            //Act

            void Result()
            {
                provider.AddProductToList(null);
            }

            // Assert

            Assert.Throws <ArgumentNullException>(Result);
        }
Exemplo n.º 4
0
        public void SendGoodsToWarehouse_ThrowsArgumentNullException_WareHouseIsNull()
        {
            // Arrange
            var provider = new Provider();

            provider.AddProductToList(new Product {
                Provider = provider, Price = 100, Category = GoodsCategory.AutomotiveAndTransport, Name = "Test"
            });
            //Act

            void Result()
            {
                provider.SendGoodsToWarehouse(null, provider.GoodsList.Last(), 5);
            }

            // Assert

            Assert.Throws <ArgumentNullException>(Result);
        }
Exemplo n.º 5
0
        public void SendGoodsToWarehouse_ThrowsArgumentOutOfRangeException_AmountIsNegative()
        {
            // Arrange
            var warehouse = new Warehouse();
            var provider  = new Provider();

            provider.AddProductToList(new Product {
                Provider = provider, Price = 100, Category = GoodsCategory.AutomotiveAndTransport, Name = "Test"
            });
            //Act

            void Result()
            {
                provider.SendGoodsToWarehouse(warehouse, provider.GoodsList.Last(), -5);
            }

            // Assert

            Assert.Throws <ArgumentOutOfRangeException>(Result);
        }
Exemplo n.º 6
0
        public void SendGoodsToWarehouse_Passes_InputIsCorrect()
        {
            // Arrange
            var warehouse = new Warehouse();
            var provider  = new Provider();

            provider.AddProductToList(new Product {
                Provider = provider, Price = 100, Category = GoodsCategory.AutomotiveAndTransport, Name = "Test"
            });

            // Act

            provider.SendGoodsToWarehouse(warehouse, new Dictionary <Product, int>
            {
                {
                    provider.GoodsList.Last(), 5
                }
            });

            // Assert
            Assert.Single(warehouse.GetShopList());
        }