Ejemplo n.º 1
0
        public void GetAllGenre_NoCondition_Returns_OkObjectResult()
        {
            // Arrange
            var genreRepositoryMock = new Mock <IGenreRepository>();
            var genreIMapperMock    = new MapperConfiguration(config =>
            {
                config.AddProfile(new MovieMapper());
            });
            var genreMapper = genreIMapperMock.CreateMapper();
            var logMock     = new Mock <ILogger <GenresController> >();
            ILogger <GenresController> logger = logMock.Object;

            GenresController genreApiController = new
                                                  GenresController(genreRepositoryMock.Object, mapper: genreMapper, logger);
            var genreDto = new GenreDTO()
            {
                Name        = "Comedy",
                DateCreated = DateTime.Parse("15 May 2015"),
                Id          = new Guid()
            };
            var genreModel = new GenreModel()
            {
                Name        = "Adult Content",
                DateCreated = DateTime.Parse("15 May 2015"),
                Id          = Guid.NewGuid()
            };
            List <GenreModel> genres = new List <GenreModel>();

            genres.Add(genreModel);
            ICollection <GenreModel> iCollection = genres;

            genreRepositoryMock.Setup(repo => repo.GetGenre())
            .Returns(iCollection);
            // Act
            var genreResult = genreApiController.GetAllGenre();
            var okResult    = genreResult as OkObjectResult;

            // Assert
            Assert.True(okResult.StatusCode is StatusCodes.Status200OK);
        }