Exemple #1
0
        public async Task DetailsTest()
        {
            DatabaseContext context = GetNewInMemoryDbWithData();

            var controller = new ThemeProductsController(context);

            var result = await controller.Details(4);

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <ThemeProduct>(viewResult.ViewData.Model);

            //Check if the Theme with id 4 has the correct values
            Assert.Equal(4, model.Theme.ThemeId);
            Assert.Equal("Waterpolo", model.Theme.ThemeName);
            Assert.Equal("Nat", model.Theme.Description);
            Assert.Equal("\\images\\themes\\turkey.jpg", model.Theme.ImageUrl);

            //Check if the Product with id 4 has the correct values
            Assert.Equal(4, model.Product.Id);
            Assert.Equal("Test product4", model.Product.Title);
            Assert.Equal("Mooie omschrijving", model.Product.Description);
            Assert.Equal("\\images\\products\\fish.jpg", model.Product.ImageUrl);
        }