public void Verify_MapToSearchModelExtension_CallsMapToModel()
        {
            // Arrange
            var mockMapper = new Mock <MovieMapper>();

            mockMapper.Setup(x => x.MapToSearchModel(It.IsAny <IMovieModel>()));
            var mockModel = MoviesMockingSetup.DoMockingSetupForMovieModel(1);

            MovieMapperExtensions.OverrideMapper(mockMapper.Object);
            // Act
            mockModel.Object.MapToSearchModel();
            // Assert
            mockMapper.Verify(x => x.MapToSearchModel(It.IsAny <IMovieModel>()), Times.Once);
        }
        public void Verify_MapToModelListingExtension_CallsMapToModel()
        {
            // Arrange
            var mockMapper = new Mock <MovieMapper>();

            mockMapper.Setup(x => x.MapToModelListing(It.IsAny <IMovie>(), It.IsAny <int>()));
            var mockEntity = MoviesMockingSetup.DoMockingSetupForMovie(1);

            MovieMapperExtensions.OverrideMapper(mockMapper.Object);
            // Act
            mockEntity.Object.MapToModelListing();
            // Assert
            mockMapper.Verify(x => x.MapToModelListing(It.IsAny <IMovie>(), It.IsAny <int>()), Times.Once);
        }
        public void Verify_AreEqualExtension_CallsAreEqual()
        {
            // Arrange
            var mockMapper = new Mock <MovieMapper>();

            mockMapper.Setup(x => x.AreEqual(It.IsAny <IMovieModel>(), It.IsAny <IMovie>()));
            MovieMapperExtensions.OverrideMapper(mockMapper.Object);
            var mockModel  = MoviesMockingSetup.DoMockingSetupForMovieModel(1);
            var mockEntity = MoviesMockingSetup.DoMockingSetupForMovie(1);

            // Act
            mockModel.Object.AreEqual(mockEntity.Object);
            // Assert
            mockMapper.Verify(x => x.AreEqual(It.IsAny <IMovieModel>(), It.IsAny <IMovie>()), Times.Once);
        }
        public void Verify_MapToSearchModel_AssignsMovieSearchProperties()
        {
            // Arrange
            var mapper = new MovieMapper();
            var model  = MoviesMockingSetup.DoMockingSetupForMovieModel();
            // Act
            var searchModel = mapper.MapToSearchModel(model.Object);

            // Assert
            Assert.Equal(model.Object.PrimaryImageFileId, searchModel.PrimaryImageFileId);
            Assert.Equal(model.Object.PrimaryImageFile?.CustomKey, searchModel.PrimaryImageFileCustomKey);
            Assert.Equal(model.Object.PrimaryImageFile?.ApiDetailUrl, searchModel.PrimaryImageFileApiDetailUrl);
            Assert.Equal(model.Object.PrimaryImageFile?.SiteDetailUrl, searchModel.PrimaryImageFileSiteDetailUrl);
            Assert.Equal(model.Object.PrimaryImageFile?.Name, searchModel.PrimaryImageFileName);
            Assert.Equal(model.Object.PrimaryImageFile?.ShortDescription, searchModel.PrimaryImageFileShortDescription);
            Assert.Equal(model.Object.PrimaryImageFile?.Description, searchModel.PrimaryImageFileDescription);
            Assert.Equal(model.Object.HasStaffReview, searchModel.HasStaffReview);
            Assert.Equal(model.Object.Distributor, searchModel.Distributor);
        }
        public void Verify_MapToEntity_WithExistingEntity_AssignsMovieProperties()
        {
            // Arrange
            var mapper = new MovieMapper();
            var model  = MoviesMockingSetup.DoMockingSetupForMovieModel();
            // Act
            IMovie existingEntity = new Movie {
                Id = 1
            };

            mapper.MapToEntity(model.Object, ref existingEntity);
            // Assert
            Assert.Equal(model.Object.HasStaffReview, existingEntity.HasStaffReview);
            Assert.Equal(model.Object.Distributor, existingEntity.Distributor);
            Assert.Equal(model.Object.BoxOfficeRevenue, existingEntity.BoxOfficeRevenue);
            Assert.Equal(model.Object.TotalRevenue, existingEntity.TotalRevenue);
            Assert.Equal(model.Object.Budget, existingEntity.Budget);
            Assert.Equal(model.Object.Rating, existingEntity.Rating);
            Assert.Equal(model.Object.ReleaseDate, existingEntity.ReleaseDate);
            Assert.Equal(model.Object.RunTime, existingEntity.RunTime);
            // Related Objects
            Assert.Equal(model.Object.PrimaryImageFileId, existingEntity.PrimaryImageFileId);
            // Associated Objects
            model.VerifyGet(x => x.MovieCharacters, Times.Once);
            //Assert.Equal(model.Object.MovieCharacters?.Count, existingEntity.MovieCharacters?.Count);
            model.VerifyGet(x => x.MovieConcepts, Times.Once);
            //Assert.Equal(model.Object.MovieConcepts?.Count, existingEntity.MovieConcepts?.Count);
            model.VerifyGet(x => x.MovieLocations, Times.Once);
            //Assert.Equal(model.Object.MovieLocations?.Count, existingEntity.MovieLocations?.Count);
            model.VerifyGet(x => x.MovieObjects, Times.Once);
            //Assert.Equal(model.Object.MovieObjects?.Count, existingEntity.MovieObjects?.Count);
            model.VerifyGet(x => x.MovieProducers, Times.Once);
            //Assert.Equal(model.Object.MovieProducers?.Count, existingEntity.MovieProducers?.Count);
            model.VerifyGet(x => x.MovieStoryArcs, Times.Once);
            //Assert.Equal(model.Object.MovieStoryArcs?.Count, existingEntity.MovieStoryArcs?.Count);
            model.VerifyGet(x => x.MovieStudios, Times.Once);
            //Assert.Equal(model.Object.MovieStudios?.Count, existingEntity.MovieStudios?.Count);
            model.VerifyGet(x => x.MovieTeams, Times.Once);
            //Assert.Equal(model.Object.MovieTeams?.Count, existingEntity.MovieTeams?.Count);
            model.VerifyGet(x => x.MovieWriters, Times.Once);
            //Assert.Equal(model.Object.MovieWriters?.Count, existingEntity.MovieWriters?.Count);
        }
        public void Verify_MapToModelLite_AssignsLiteOnlyMovieProperties()
        {
            // Arrange
            var mapper = new MovieMapper();
            var entity = MoviesMockingSetup.DoMockingSetupForMovie();
            // Act
            var model = mapper.MapToModelLite(entity.Object);

            // Assert
            Assert.Equal(entity.Object.HasStaffReview, model.HasStaffReview);
            Assert.Equal(entity.Object.Distributor, model.Distributor);
            Assert.Equal(entity.Object.BoxOfficeRevenue, model.BoxOfficeRevenue);
            Assert.Equal(entity.Object.TotalRevenue, model.TotalRevenue);
            Assert.Equal(entity.Object.Budget, model.Budget);
            Assert.Equal(entity.Object.Rating, model.Rating);
            Assert.Equal(entity.Object.ReleaseDate, model.ReleaseDate);
            Assert.Equal(entity.Object.RunTime, model.RunTime);
            // Related Objects
            Assert.Equal(entity.Object.PrimaryImageFileId, model.PrimaryImageFileId);
        }