public void Verify_MapToModel_AssignsEpisodeProperties()
        {
            // Arrange
            var mapper = new EpisodeMapper();
            var entity = EpisodesMockingSetup.DoMockingSetupForEpisode();
            // Act
            var model = mapper.MapToModel(entity.Object);

            // Assert
            Assert.Equal(entity.Object.HasStaffReview, model.HasStaffReview);
            Assert.Equal(entity.Object.AirDate, model.AirDate);
            Assert.Equal(entity.Object.EpisodeCode, model.EpisodeCode);
            Assert.Equal(entity.Object.SeasonNumber, model.SeasonNumber);
            Assert.Equal(entity.Object.EpisodeNumber, model.EpisodeNumber);
            // Related Objects
            Assert.Equal(entity.Object.PrimaryImageFileId, model.PrimaryImageFileId);
            Assert.Equal(entity.Object.SeriesId, model.SeriesId);
            // Associated Objects
            Assert.Equal(entity.Object.EpisodeAliases?.Count, model.EpisodeAliases?.Count);
            Assert.Equal(entity.Object.EpisodeCharacters?.Count, model.EpisodeCharacters?.Count);
            Assert.Equal(entity.Object.EpisodeCharactersDied?.Count, model.EpisodeCharactersDied?.Count);
            Assert.Equal(entity.Object.EpisodeCharacterFirstAppearances?.Count, model.EpisodeCharacterFirstAppearances?.Count);
            Assert.Equal(entity.Object.EpisodeConcepts?.Count, model.EpisodeConcepts?.Count);
            Assert.Equal(entity.Object.EpisodeConceptFirstAppearances?.Count, model.EpisodeConceptFirstAppearances?.Count);
            Assert.Equal(entity.Object.EpisodeLocations?.Count, model.EpisodeLocations?.Count);
            Assert.Equal(entity.Object.EpisodeLocationFirstAppearances?.Count, model.EpisodeLocationFirstAppearances?.Count);
            Assert.Equal(entity.Object.EpisodeObjects?.Count, model.EpisodeObjects?.Count);
            Assert.Equal(entity.Object.EpisodeObjectFirstAppearances?.Count, model.EpisodeObjectFirstAppearances?.Count);
            Assert.Equal(entity.Object.EpisodePeople?.Count, model.EpisodePeople?.Count);
            Assert.Equal(entity.Object.EpisodeStoryArcs?.Count, model.EpisodeStoryArcs?.Count);
            Assert.Equal(entity.Object.EpisodeStoryArcFirstAppearances?.Count, model.EpisodeStoryArcFirstAppearances?.Count);
            Assert.Equal(entity.Object.EpisodeTeams?.Count, model.EpisodeTeams?.Count);
            Assert.Equal(entity.Object.EpisodeTeamFirstAppearances?.Count, model.EpisodeTeamFirstAppearances?.Count);
        }
        public void Verify_MapToSearchModel_AssignsEpisodeSearchProperties()
        {
            // Arrange
            var mapper = new EpisodeMapper();
            var model  = EpisodesMockingSetup.DoMockingSetupForEpisodeModel();
            // 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.SeriesId, searchModel.SeriesId);
            Assert.Equal(model.Object.Series?.CustomKey, searchModel.SeriesCustomKey);
            Assert.Equal(model.Object.Series?.ApiDetailUrl, searchModel.SeriesApiDetailUrl);
            Assert.Equal(model.Object.Series?.SiteDetailUrl, searchModel.SeriesSiteDetailUrl);
            Assert.Equal(model.Object.Series?.Name, searchModel.SeriesName);
            Assert.Equal(model.Object.Series?.ShortDescription, searchModel.SeriesShortDescription);
            Assert.Equal(model.Object.Series?.Description, searchModel.SeriesDescription);
            Assert.Equal(model.Object.HasStaffReview, searchModel.HasStaffReview);
        }
        public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse()
        {
            // Arrange
            var mapper = new EpisodeMapper();
            var model  = EpisodesMockingSetup.DoMockingSetupForEpisodeModel(1);
            var entity = EpisodesMockingSetup.DoMockingSetupForEpisode(2);
            // Act
            var result = mapper.AreEqual(model.Object, entity.Object);

            // Assert
            Assert.False(result);
        }
        public void Verify_MapToEntity_WithExistingEntity_AssignsEpisodeProperties()
        {
            // Arrange
            var mapper = new EpisodeMapper();
            var model  = EpisodesMockingSetup.DoMockingSetupForEpisodeModel();
            // Act
            IEpisode existingEntity = new Episode {
                Id = 1
            };

            mapper.MapToEntity(model.Object, ref existingEntity);
            // Assert
            Assert.Equal(model.Object.HasStaffReview, existingEntity.HasStaffReview);
            Assert.Equal(model.Object.AirDate, existingEntity.AirDate);
            Assert.Equal(model.Object.EpisodeCode, existingEntity.EpisodeCode);
            Assert.Equal(model.Object.SeasonNumber, existingEntity.SeasonNumber);
            Assert.Equal(model.Object.EpisodeNumber, existingEntity.EpisodeNumber);
            // Related Objects
            Assert.Equal(model.Object.PrimaryImageFileId, existingEntity.PrimaryImageFileId);
            Assert.Equal(model.Object.SeriesId, existingEntity.SeriesId);
            // Associated Objects
            model.VerifyGet(x => x.EpisodeAliases, Times.Once);
            //Assert.Equal(model.Object.EpisodeAliases?.Count, existingEntity.EpisodeAliases?.Count);
            model.VerifyGet(x => x.EpisodeCharacters, Times.Once);
            //Assert.Equal(model.Object.EpisodeCharacters?.Count, existingEntity.EpisodeCharacters?.Count);
            model.VerifyGet(x => x.EpisodeCharactersDied, Times.Once);
            //Assert.Equal(model.Object.EpisodeCharactersDied?.Count, existingEntity.EpisodeCharactersDied?.Count);
            model.VerifyGet(x => x.EpisodeCharacterFirstAppearances, Times.Once);
            //Assert.Equal(model.Object.EpisodeCharacterFirstAppearances?.Count, existingEntity.EpisodeCharacterFirstAppearances?.Count);
            model.VerifyGet(x => x.EpisodeConcepts, Times.Once);
            //Assert.Equal(model.Object.EpisodeConcepts?.Count, existingEntity.EpisodeConcepts?.Count);
            model.VerifyGet(x => x.EpisodeConceptFirstAppearances, Times.Once);
            //Assert.Equal(model.Object.EpisodeConceptFirstAppearances?.Count, existingEntity.EpisodeConceptFirstAppearances?.Count);
            model.VerifyGet(x => x.EpisodeLocations, Times.Once);
            //Assert.Equal(model.Object.EpisodeLocations?.Count, existingEntity.EpisodeLocations?.Count);
            model.VerifyGet(x => x.EpisodeLocationFirstAppearances, Times.Once);
            //Assert.Equal(model.Object.EpisodeLocationFirstAppearances?.Count, existingEntity.EpisodeLocationFirstAppearances?.Count);
            model.VerifyGet(x => x.EpisodeObjects, Times.Once);
            //Assert.Equal(model.Object.EpisodeObjects?.Count, existingEntity.EpisodeObjects?.Count);
            model.VerifyGet(x => x.EpisodeObjectFirstAppearances, Times.Once);
            //Assert.Equal(model.Object.EpisodeObjectFirstAppearances?.Count, existingEntity.EpisodeObjectFirstAppearances?.Count);
            model.VerifyGet(x => x.EpisodePeople, Times.Once);
            //Assert.Equal(model.Object.EpisodePeople?.Count, existingEntity.EpisodePeople?.Count);
            model.VerifyGet(x => x.EpisodeStoryArcs, Times.Once);
            //Assert.Equal(model.Object.EpisodeStoryArcs?.Count, existingEntity.EpisodeStoryArcs?.Count);
            model.VerifyGet(x => x.EpisodeStoryArcFirstAppearances, Times.Once);
            //Assert.Equal(model.Object.EpisodeStoryArcFirstAppearances?.Count, existingEntity.EpisodeStoryArcFirstAppearances?.Count);
            model.VerifyGet(x => x.EpisodeTeams, Times.Once);
            //Assert.Equal(model.Object.EpisodeTeams?.Count, existingEntity.EpisodeTeams?.Count);
            model.VerifyGet(x => x.EpisodeTeamFirstAppearances, Times.Once);
            //Assert.Equal(model.Object.EpisodeTeamFirstAppearances?.Count, existingEntity.EpisodeTeamFirstAppearances?.Count);
        }
        public void Verify_MapToSearchModelExtension_CallsMapToModel()
        {
            // Arrange
            var mockMapper = new Mock <EpisodeMapper>();

            mockMapper.Setup(x => x.MapToSearchModel(It.IsAny <IEpisodeModel>()));
            var mockModel = EpisodesMockingSetup.DoMockingSetupForEpisodeModel(1);

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

            mockMapper.Setup(x => x.MapToModelListing(It.IsAny <IEpisode>(), It.IsAny <int>()));
            var mockEntity = EpisodesMockingSetup.DoMockingSetupForEpisode(1);

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

            mockMapper.Setup(x => x.AreEqual(It.IsAny <IEpisodeModel>(), It.IsAny <IEpisode>()));
            EpisodeMapperExtensions.OverrideMapper(mockMapper.Object);
            var mockModel  = EpisodesMockingSetup.DoMockingSetupForEpisodeModel(1);
            var mockEntity = EpisodesMockingSetup.DoMockingSetupForEpisode(1);

            // Act
            mockModel.Object.AreEqual(mockEntity.Object);
            // Assert
            mockMapper.Verify(x => x.AreEqual(It.IsAny <IEpisodeModel>(), It.IsAny <IEpisode>()), Times.Once);
        }
        public void Verify_MapToModelLite_AssignsLiteOnlyEpisodeProperties()
        {
            // Arrange
            var mapper = new EpisodeMapper();
            var entity = EpisodesMockingSetup.DoMockingSetupForEpisode();
            // Act
            var model = mapper.MapToModelLite(entity.Object);

            // Assert
            Assert.Equal(entity.Object.HasStaffReview, model.HasStaffReview);
            Assert.Equal(entity.Object.AirDate, model.AirDate);
            Assert.Equal(entity.Object.EpisodeCode, model.EpisodeCode);
            Assert.Equal(entity.Object.SeasonNumber, model.SeasonNumber);
            Assert.Equal(entity.Object.EpisodeNumber, model.EpisodeNumber);
            // Related Objects
            Assert.Equal(entity.Object.PrimaryImageFileId, model.PrimaryImageFileId);
            Assert.Equal(entity.Object.SeriesId, model.SeriesId);
        }