Exemplo n.º 1
0
        public void TestsGetProductsInSectionWithEmptySection()
        {
            fakeApi = new FakeApiRequestSend();
            var controller = new ApiController(fakeApi);

            Assert.Throws <Exception>(() => controller.GetProductsInSection(""));
        }
Exemplo n.º 2
0
        public void TestsGetMostExpensiveProduct()
        {
            fakeApi = new FakeApiRequestSend();
            var controller      = new ApiController(fakeApi);
            var expectedProduct = new Product {
                Id = 2, Price = 40, ProductName = "Lamp", Section = "B", Weight = 5
            };

            var actualProduct = controller.GetMostExpensiveProduct();

            Assert.Equal(expectedProduct, actualProduct);
        }
Exemplo n.º 3
0
        public void TestsGetProductsInSectionWithRealSection()
        {
            fakeApi = new FakeApiRequestSend();
            var            controller       = new ApiController(fakeApi);
            List <Product> expectedProducts = new List <Product>()
            {
                new Product {
                    Id = 1, Price = 32, ProductName = "Table", Section = "B", Weight = 57
                },
                new Product {
                    Id = 2, Price = 40, ProductName = "Lamp", Section = "B", Weight = 5
                }
            };

            List <Product> actualProducts = controller.GetProductsInSection("B").ToList();

            Assert.Equal(expectedProducts, actualProducts);
        }