public async Task Index_CreatesViewWithGenres() { // Arrange var dbContext = _serviceProvider.GetRequiredService <MusicStoreContext>(); CreateTestGenres(numberOfGenres: 10, numberOfAlbums: 1, dbContext: dbContext); var controller = new StoreController() { DbContext = dbContext, }; // Act var result = await controller.Index(); // Assert var viewResult = Assert.IsType <ViewResult>(result); Assert.Null(viewResult.ViewName); Assert.NotNull(viewResult.ViewData); var viewModel = Assert.IsType <List <Genre> >(viewResult.ViewData.Model); Assert.Equal(10, viewModel.Count); }
public async Task Index_CreatesViewWithGenres() { // Arrange var dbContext = _serviceProvider.GetRequiredService<MusicStoreContext>(); CreateTestGenres(numberOfGenres: 10, numberOfAlbums: 1, dbContext: dbContext); var controller = new StoreController(dbContext); // Act var result = await controller.Index(); // Assert var viewResult = Assert.IsType<ViewResult>(result); Assert.Null(viewResult.ViewName); Assert.NotNull(viewResult.ViewData); var viewModel = Assert.IsType<List<Genre>>(viewResult.ViewData.Model); Assert.Equal(10, viewModel.Count); }
public async Task Index_CreatesViewWithGenres() { // Arrange var dbContext = _fixture.Context; CreateTestGenres(numberOfGenres: 10, numberOfAlbums: 1, dbContext: dbContext); var controller = new StoreController(dbContext, new TestAppSettings()); // Act var result = await controller.Index(); // Assert var viewResult = Assert.IsType <ViewResult>(result); Assert.Null(viewResult.ViewName); Assert.NotNull(viewResult.ViewData); var viewModel = Assert.IsType <List <Genre> >(viewResult.ViewData.Model); Assert.Equal(10, viewModel.Count); }