Index() public method

public Index ( ) : Task
return Task
Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }