public void Details_ReturnsViewResult_WithDetailsOfAlbum()
        {
            //arrange
            int albumId = 1;

            _albumRepoMock.Setup(m => m.GetById((albumId))).Returns(_albumRepoMock.Object.GetById(albumId));

            //act
            var viewResult = (ViewResult)_sut.Details(albumId);

            //assert
            Assert.That(viewResult, Is.Not.Null);
            Assert.That(viewResult, Is.InstanceOf <IActionResult>());
            Assert.That(viewResult.Model, Is.SameAs(_albumRepoMock.Object.GetById(albumId)));
        }
        public async Task Details_ReturnsAlbumDetail()
        {
            using (var context = CreateContext())
            {
                await context.Database.CreateExecutionStrategy().ExecuteAsync(
                    async() =>
                {
                    using (Fixture.BeginTransaction(context))
                    {
                        var genres  = CreateTestGenres(numberOfGenres: 3, numberOfAlbums: 3, context: context);
                        var albumId = genres.First().Albums[2].AlbumId;

                        var controller = new StoreController(context);

                        var result = await controller.Details(albumId);

                        Assert.NotNull(result.Genre);
                        var genre = genres.SingleOrDefault(g => g.GenreId == result.GenreId);
                        Assert.NotNull(genre);
                        Assert.NotNull(genre.Albums.SingleOrDefault(a => a.AlbumId == albumId));
                        Assert.NotNull(result.Artist);
                        Assert.NotEqual(0, result.ArtistId);
                    }
                });
            }
        }
Ejemplo n.º 3
0
        public void CanViewDetails()
        {
            //ACT
            var result = _storeController.Details(1);
            var model  = result.Model;

            //Assert

            Assert.IsInstanceOf <ViewResult>(result);
            Assert.IsInstanceOf <Store>(model);

            Assert.IsNotNullOrEmpty(((Store)model).Name);
        }
Ejemplo n.º 4
0
        public void DetailsValidStore()
        {
            var actual = (Store)controller.Details(1).Model;

            Assert.AreEqual(stores.ToList()[0], actual);
        }