public void Index_HasCorrectModelType_CatalogList() { //Arrange CatalogsController controller = new CatalogsController(); ViewResult indexView = controller.Index() as ViewResult; //Act var result = indexView.ViewData.Model; //Assert Assert.IsInstanceOfType(result, typeof(List <Catalog>)); }
public async Task Index_ReturnsExpectedCatalogs() { // Arrange serviceMoq.Setup(x => x.GetCatalogsAsync()).ReturnsAsync(GetTestCatalogs); CatalogsController controller = new CatalogsController(serviceMoq.Object); var moqCatalogsCount = GetTestCatalogs().Count; // Act var result = await controller.Index(); var viewResult = result as ViewResult; var model = viewResult.Model as List <Catalog>; // Assert Assert.NotNull(viewResult); Assert.NotNull(model); Assert.Equal(model.Count, moqCatalogsCount); }