Browse() публичный Метод

public Browse ( string genre ) : Task
genre string
Результат Task
Пример #1
0
        public async Task Browse_ReturnsViewWithGenre()
        {
            // Arrange
            var genreName = "Genre 1";

            var dbContext = _fixture.Context;

            CreateTestGenres(numberOfGenres: 3, numberOfAlbums: 3, dbContext: dbContext);

            var controller = new StoreController(dbContext, new TestAppSettings());

            // Act
            var result = await controller.Browse(genreName);

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.Null(viewResult.ViewName);

            Assert.NotNull(viewResult.ViewData);
            var viewModel = Assert.IsType <Genre>(viewResult.ViewData.Model);

            Assert.Equal(genreName, viewModel.Name);
            Assert.NotNull(viewModel.Albums);
            Assert.Equal(3, viewModel.Albums.Count);
        }
Пример #2
0
        public async Task Browse_ReturnsViewWithGenre()
        {
            // Arrange
            var genreName = "Genre 1";

            var dbContext = _serviceProvider.GetRequiredService<MusicStoreContext>();
            CreateTestGenres(numberOfGenres: 3, numberOfAlbums: 3, dbContext: dbContext);

            var controller = new StoreController()
            {
                DbContext = dbContext,
            };

            // Act
            var result = await controller.Browse(genreName);

            // Assert
            var viewResult = Assert.IsType<ViewResult>(result);
            Assert.Null(viewResult.ViewName);

            Assert.NotNull(viewResult.ViewData);
            var viewModel = Assert.IsType<Genre>(viewResult.ViewData.Model);
            Assert.Equal(genreName, viewModel.Name);
            Assert.NotNull(viewModel.Albums);
            Assert.Equal(3, viewModel.Albums.Count);
        }
Пример #3
0
        public async Task Browse_ReturnsViewWithGenre()
        {
            // Arrange
            var genreName = "Genre 1";

            var dbContext = _serviceProvider.GetRequiredService <MusicStoreContext>();

            CreateTestGenres(numberOfGenres: 3, numberOfAlbums: 3, dbContext: dbContext);

            var controller = new StoreController(dbContext);

            // Act
            var result = await controller.Browse(genreName);

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.Null(viewResult.ViewName);

            Assert.NotNull(viewResult.ViewData);
            var viewModel = Assert.IsType <Genre>(viewResult.ViewData.Model);

            Assert.Equal(genreName, viewModel.Name);
            Assert.NotNull(viewModel.Albums);
            Assert.Equal(3, viewModel.Albums.Count);
        }
Пример #4
0
        public async Task Browse_ReturnsHttpNotFoundWhenNoGenreData()
        {
            // Arrange
            var controller = new StoreController(_serviceProvider.GetRequiredService<MusicStoreContext>());

            // Act
            var result = await controller.Browse(string.Empty);

            // Assert
            Assert.IsType<NotFoundResult>(result);
        }
Пример #5
0
        public async Task Browse_ReturnsHttpNotFoundWhenNoGenreData()
        {
            // Arrange
            var controller = new StoreController(_serviceProvider.GetRequiredService <MusicStoreContext>());

            // Act
            var result = await controller.Browse(string.Empty);

            // Assert
            Assert.IsType <HttpNotFoundResult>(result);
        }
Пример #6
0
        public async Task Browse_ReturnsHttpNotFoundWhenNoGenreData()
        {
            // Arrange
            var controller = new StoreController(
                _fixture.Context,
                new TestAppSettings());

            // Act
            var result = await controller.Browse(string.Empty);

            // Assert
            Assert.IsType <NotFoundResult>(result);
        }