public void API_ReturnsNullModels_WhenApiIdIsInvalid(string apiDescriptionId) { HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute("Default", "{controller}/{id}", new { id = RouteParameter.Optional }); HelpController controller = new HelpController(config); ViewResult result = Assert.IsType <ViewResult>(controller.Api(apiDescriptionId)); ViewResult result2 = Assert.IsType <ViewResult>(controller.Api(apiDescriptionId)); Assert.Null(result.Model); Assert.Null(result2.Model); }
public void API_ReturnsCachedModels(string apiDescriptionId) { HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute("Default", "{controller}/{id}", new { id = RouteParameter.Optional }); HelpController controller = new HelpController(config); ViewResult result = Assert.IsType <ViewResult>(controller.Api(apiDescriptionId)); ViewResult result2 = Assert.IsType <ViewResult>(controller.Api(apiDescriptionId)); Assert.NotNull(result.Model); Assert.NotNull(result2.Model); // Make sure the model is cached Assert.Same(config.GetHelpPageApiModel(apiDescriptionId), result.Model); Assert.Same(result.Model, result2.Model); }