public void Browse_ReturnsViewResult_WithAllAlbumsForGenre()
        {
            //arrange
            int genreId = 1;

            _albumRepoMock.Setup(m => m.GetByGenre((genreId))).Returns(_albumRepoMock.Object.GetByGenre(genreId));

            //act
            var viewResult = (ViewResult)_sut.Browse(genreId);

            //assert
            Assert.That(viewResult, Is.Not.Null);
            Assert.That(viewResult, Is.InstanceOf <IActionResult>());
            Assert.That(viewResult.Model, Is.SameAs(_albumRepoMock.Object.GetByGenre(genreId)));
        }
Exemplo n.º 2
0
        public void MSTest_TestStoreController_Browse()
        {
            Mock <MusicStoreEntities> MusicStoreEntitiesMoq = CreateMockGenres();
            var controller = new StoreController(MusicStoreEntitiesMoq.Object);
            var result     = controller.Browse("Test") as ViewResult;
            //expecting defautl view to be returned.
            var viewDataType = result.ViewData.Model.GetType();

            Assert.IsTrue(viewDataType == typeof(MvcMusicStore.Models.Genre));
        }
Exemplo n.º 3
0
        public async Task Browse_ReturnsViewWithGenre()
        {
            using (var context = CreateContext())
            {
                using (Fixture.BeginTransaction(context))
                {
                    const string genreName = "Genre 1";
                    CreateTestGenres(numberOfGenres: 3, numberOfAlbums: 3, context: context);

                    var controller = new StoreController(context);

                    var result = await controller.Browse(genreName);

                    Assert.Equal(genreName, result.Name);
                    Assert.NotNull(result.Albums);
                    Assert.Equal(3, result.Albums.Count);
                }
            }
        }
Exemplo n.º 4
0
        public virtual async Task Browse_ReturnsViewWithGenre()
        {
            using var context = CreateContext();
            await context.Database.CreateExecutionStrategy().ExecuteAsync(
                async() =>
            {
                using (Fixture.BeginTransaction(context))
                {
                    const string genreName = "Genre 1";
                    CreateTestGenres(numberOfGenres: 3, numberOfAlbums: 3, context: context);

                    var controller = new StoreController(context);

                    var result = await controller.Browse(genreName);

                    Assert.Equal(genreName, result.Name);
                    Assert.NotNull(result.Albums);
                    Assert.Equal(3, result.Albums.Count);
                }
            });
        }