Ejemplo n.º 1
0
        public async Task TestAddProductSuccess()
        {
            //Should update Catalog by adding a product to its list
            var result = await controller.AddProduct(1, 1);

            Assert.IsType <OkObjectResult>(result);

            OkObjectResult new_res = (OkObjectResult)await controller.GetCatalog(1);

            CatalogDTO new_dto = (CatalogDTO)new_res.Value;

            //Information inside the retrived CatalogDTO should be updated
            Assert.Equal("Test_Catalog", new_dto.CatalogName);
            Assert.Equal("This is a mock Catalog", new_dto.CatalogDescription);
            Assert.Equal("06/01/2019", new_dto.Date);
            Assert.True(1 == new_dto.CatalogId);
            Assert.True(1 == new_dto.products.Count);

            //The product inside the list should the intended
            ProductDTO pdto = new_dto.products.Find(p => p.name == "Test_Product");

            Assert.Equal("Test_Product", pdto.name);
            Assert.Equal("This is a mock Product", pdto.description);
            Assert.True(1 == pdto.ProductId);
        }