public async Task TestDetailsWithOutOfRangeIdReturnsNotFound() { //Get a test controller GameContext context = GetTestContext("activeciv_details_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.Details(context.ActiveCivs.Count() + 20); Assert.IsType <NotFoundResult>(result); }
public async Task TestDetailsWithoutIdReturnsNotFound() { //Get a test controller GameContext context = GetTestContext("activeciv_details_no_id"); ActiveCivsController testController = new ActiveCivsController(context); //Run the controller's Details() without an Id IActionResult result = await testController.Details(null); //Assert that we got a not found result Assert.IsType <NotFoundResult>(result); }
public async Task CanGetDetails() { int testActiveCivId = 1; //Get a test controller GameContext gameContext = GetTestContext("activeciv_details"); ActiveCivsController testController = new ActiveCivsController(gameContext); //Run the controller's Details() IActionResult result = await testController.Details(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); }