public async Task CreateTest() { DatabaseContext context = GetNewInMemoryDbWithData(); var controller = new ThemeProductsController(context); //Create a new ThemeProduct to add ThemeProduct NewThemeProduct = new ThemeProduct() { ThemeProductId = 7, Product = new Product { Id = 7, Title = "Nieuw Product", Category = "Create", Contents = "Nieuw Product beschrijving", ImageUrl = "\\images\\products\\fishxd.jpg", Description = "Product create omschrijving", DownloadLink = "productCreation.pdf", }, Theme = new Theme { ThemeId = 7, ThemeName = "Nieuw Thema", Description = "Thema create omschrijving", ImageUrl = "\\images\\themes\\beakers.jpg" } }; //Create the new ThemeProduct var result = await controller.Create(NewThemeProduct); //Make sure it has the correct ThemeProductId Assert.Equal(7, context.ThemeProducts.Find(7).ThemeProductId); //Make sure the Product has all the correct values Assert.Equal(7, context.ThemeProducts.Find(7).Product.Id); Assert.Equal("Nieuw Product", context.ThemeProducts.Find(7).Product.Title); Assert.Equal("Create", context.ThemeProducts.Find(7).Product.Category); Assert.Equal("Nieuw Product beschrijving", context.ThemeProducts.Find(7).Product.Contents); Assert.Equal("\\images\\products\\fishxd.jpg", context.ThemeProducts.Find(7).Product.ImageUrl); Assert.Equal("Product create omschrijving", context.ThemeProducts.Find(7).Product.Description); Assert.Equal("productCreation.pdf", context.ThemeProducts.Find(7).Product.DownloadLink); //Make sure the Theme has all the correct values Assert.Equal(7, context.ThemeProducts.Find(7).Theme.ThemeId); Assert.Equal("Nieuw Thema", context.ThemeProducts.Find(7).Theme.ThemeName); Assert.Equal("Thema create omschrijving", context.ThemeProducts.Find(7).Theme.Description); Assert.Equal("\\images\\themes\\beakers.jpg", context.ThemeProducts.Find(7).Theme.ImageUrl); var viewResult = Assert.IsType <RedirectToActionResult>(result); Assert.Null(viewResult.ControllerName); Assert.Equal("Index", viewResult.ActionName); }