Пример #1
0
        public void DetailsNoIdLoadsError()
        {
            //act//
            ViewResult result = (ViewResult)controller.Details(null);

            //assert//
            Assert.AreEqual("Error", result.ViewName);
        }
Пример #2
0
        public void DetailsNoId()
        {
            //act
            var result = (ViewResult)controller.Details(null);

            //assert
            Assert.AreEqual("Error", result.ViewName);
        }
        public void DetailsValidIdLoadsView()
        {
            // act
            var result = (ViewResult)albumsController.Details(10).Result;

            // assert
            Assert.AreEqual("Details", result.ViewName);
        }
Пример #4
0
        public void AlbumControllerDetails()
        {
            var albumController = new AlbumsController(null, null);

            var result = albumController.Details(1);

            Assert.IsNotNull(result);
        }
        public void DetailReturnsErrorWithInvalidId()
        {
            //arrange
            Fakes.FakeAlbumDAL DAL        = new Fakes.FakeAlbumDAL();
            AlbumsController   controller = new AlbumsController(DAL);

            //Act
            ViewResult result = controller.Details(10000) as ViewResult;

            //Assert
            Assert.AreEqual("Error", result.ViewName);
        }
        public void DetailUsesDAL()
        {
            //arrange
            Fakes.FakeAlbumDAL DAL        = new Fakes.FakeAlbumDAL();
            AlbumsController   controller = new AlbumsController(DAL);

            //Act
            controller.Details(5);

            //Assert
            Assert.AreEqual(5, DAL.albumId);
        }
Пример #7
0
        public void IsModelDetailsIsInstanceOfAlbum()
        {
            // Arrange
            AlbumsController controller = new AlbumsController();

            // Act
            ViewResult result = controller.Details(37) as ViewResult;
            Album      xd     = (Album)result.Model;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOf(typeof(Album), result.Model);
        }
Пример #8
0
        public async Task AlbumsDetailsShouldReturnViewWithCorrectModelWithValidId()
        {
            // Arrange
            var albumService = this.AlbumServiceMock();

            var controller = new AlbumsController(albumService.Object);

            // Act
            var result = await controller.Details(1);

            // Assert
            result.Should().BeOfType <ViewResult>();

            var albumModel = result.As <ViewResult>().Model.As <AlbumDetailsServiceModel>();

            albumModel.Should().Match(c => c.As <AlbumDetailsServiceModel>().Id == 1);
        }
Пример #9
0
        public async Task AlbumDetailsShouldReturnNotFoundWithInvalidId()
        {
            // Arrange
            var albumService = this.AlbumServiceMock();

            var controller = new AlbumsController(albumService.Object);

            // Act
            var result = await controller.Details(4);

            // Assert
            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            result
            .Should()
            .BeOfType <RedirectToActionResult>();
            Assert.Equal("NotFoundPage", redirectToActionResult.ActionName);
        }