public async Task TestDeleteWithoutIdReturnsNotFound() { //Get a test controller GameContext context = GetTestContext("activeciv_delete_get_no_id"); ActiveCivsController testController = new ActiveCivsController(context); //Run the controller's Details() without an Id IActionResult result = await testController.Delete(null); Assert.IsType <NotFoundResult>(result); }
public async Task TestDeleteWithOutOfRangeIdReturnsNotFound() { //Get a test controller GameContext context = GetTestContext("activeciv_delete_get_oob_id"); ActiveCivsController testController = new ActiveCivsController(context); //Run the controller's Details() with an Id that isn't present in the database IActionResult result = await testController.Delete(context.ActiveCivs.Count() + 20); Assert.IsType <NotFoundResult>(result); }
public async Task CanGetDelete() { int testActiveCivId = 1; //Get a test controller GameContext gameContext = GetTestContext("activeciv_delete_get"); ActiveCivsController testController = new ActiveCivsController(gameContext); //Run the controller's Details() IActionResult result = await testController.Delete(testActiveCivId); //Assert that... //...we got a view back ViewResult viewResult = Assert.IsType <ViewResult>(result); //...the view model is an ActiveCiv Assert.IsAssignableFrom <ActiveCiv>(viewResult.ViewData.Model); }