Ejemplo n.º 1
0
        public void Verify_MapToSearchModel_AssignsSeriesSearchProperties()
        {
            // Arrange
            var mapper = new SeriesMapper();
            var model  = SeriesMockingSetup.DoMockingSetupForSeriesModel();
            // Act
            var searchModel = mapper.MapToSearchModel(model.Object);

            // Assert
            Assert.Equal(model.Object.PublisherId, searchModel.PublisherId);
            Assert.Equal(model.Object.Publisher?.CustomKey, searchModel.PublisherCustomKey);
            Assert.Equal(model.Object.Publisher?.ApiDetailUrl, searchModel.PublisherApiDetailUrl);
            Assert.Equal(model.Object.Publisher?.SiteDetailUrl, searchModel.PublisherSiteDetailUrl);
            Assert.Equal(model.Object.Publisher?.Name, searchModel.PublisherName);
            Assert.Equal(model.Object.Publisher?.ShortDescription, searchModel.PublisherShortDescription);
            Assert.Equal(model.Object.Publisher?.Description, searchModel.PublisherDescription);
            Assert.Equal(model.Object.FirstEpisodeId, searchModel.FirstEpisodeId);
            Assert.Equal(model.Object.FirstEpisode?.CustomKey, searchModel.FirstEpisodeCustomKey);
            Assert.Equal(model.Object.FirstEpisode?.ApiDetailUrl, searchModel.FirstEpisodeApiDetailUrl);
            Assert.Equal(model.Object.FirstEpisode?.SiteDetailUrl, searchModel.FirstEpisodeSiteDetailUrl);
            Assert.Equal(model.Object.FirstEpisode?.Name, searchModel.FirstEpisodeName);
            Assert.Equal(model.Object.FirstEpisode?.ShortDescription, searchModel.FirstEpisodeShortDescription);
            Assert.Equal(model.Object.FirstEpisode?.Description, searchModel.FirstEpisodeDescription);
            Assert.Equal(model.Object.LastEpisodeId, searchModel.LastEpisodeId);
            Assert.Equal(model.Object.LastEpisode?.CustomKey, searchModel.LastEpisodeCustomKey);
            Assert.Equal(model.Object.LastEpisode?.ApiDetailUrl, searchModel.LastEpisodeApiDetailUrl);
            Assert.Equal(model.Object.LastEpisode?.SiteDetailUrl, searchModel.LastEpisodeSiteDetailUrl);
            Assert.Equal(model.Object.LastEpisode?.Name, searchModel.LastEpisodeName);
            Assert.Equal(model.Object.LastEpisode?.ShortDescription, searchModel.LastEpisodeShortDescription);
            Assert.Equal(model.Object.LastEpisode?.Description, searchModel.LastEpisodeDescription);
        }
Ejemplo n.º 2
0
        public void Verify_MapToEntity_WithExistingEntity_AssignsSeriesProperties()
        {
            // Arrange
            var mapper = new SeriesMapper();
            var model  = SeriesMockingSetup.DoMockingSetupForSeriesModel();
            // Act
            ISeries existingEntity = new Series {
                Id = 1
            };

            mapper.MapToEntity(model.Object, ref existingEntity);
            // Assert
            Assert.Equal(model.Object.Startyear, existingEntity.Startyear);
            // Related Objects
            Assert.Equal(model.Object.PublisherId, existingEntity.PublisherId);
            Assert.Equal(model.Object.FirstEpisodeId, existingEntity.FirstEpisodeId);
            Assert.Equal(model.Object.LastEpisodeId, existingEntity.LastEpisodeId);
            // Associated Objects
            model.VerifyGet(x => x.Episodes, Times.Once);
            //Assert.Equal(model.Object.Episodes?.Count, existingEntity.Episodes?.Count);
            model.VerifyGet(x => x.SeriesAliases, Times.Once);
            //Assert.Equal(model.Object.SeriesAliases?.Count, existingEntity.SeriesAliases?.Count);
            model.VerifyGet(x => x.SeriesCharacters, Times.Once);
            //Assert.Equal(model.Object.SeriesCharacters?.Count, existingEntity.SeriesCharacters?.Count);
            model.VerifyGet(x => x.SeriesLocations, Times.Once);
            //Assert.Equal(model.Object.SeriesLocations?.Count, existingEntity.SeriesLocations?.Count);
        }
Ejemplo n.º 3
0
        public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse()
        {
            // Arrange
            var mapper = new SeriesMapper();
            var model  = SeriesMockingSetup.DoMockingSetupForSeriesModel(1);
            var entity = SeriesMockingSetup.DoMockingSetupForSeries(2);
            // Act
            var result = mapper.AreEqual(model.Object, entity.Object);

            // Assert
            Assert.False(result);
        }
Ejemplo n.º 4
0
        public void Verify_MapToEntityExtension_CallsMapToEntity()
        {
            // Arrange
            var mockMapper = new Mock <SeriesMapper>();

            mockMapper.Setup(x => x.MapToEntity(It.IsAny <ISeriesModel>(), It.IsAny <int>()));
            var mockModel = SeriesMockingSetup.DoMockingSetupForSeriesModel(1);

            SeriesMapperExtensions.OverrideMapper(mockMapper.Object);
            // Act
            mockModel.Object.MapToEntity();
            // Assert
            mockMapper.Verify(x => x.MapToEntity(It.IsAny <ISeriesModel>(), It.IsAny <int>()), Times.Once);
        }
Ejemplo n.º 5
0
        public void Verify_MapToModelLite_AssignsLiteOnlySeriesProperties()
        {
            // Arrange
            var mapper = new SeriesMapper();
            var entity = SeriesMockingSetup.DoMockingSetupForSeries();
            // Act
            var model = mapper.MapToModelLite(entity.Object);

            // Assert
            Assert.Equal(entity.Object.Startyear, model.Startyear);
            // Related Objects
            Assert.Equal(entity.Object.PublisherId, model.PublisherId);
            Assert.Equal(entity.Object.FirstEpisodeId, model.FirstEpisodeId);
            Assert.Equal(entity.Object.LastEpisodeId, model.LastEpisodeId);
        }
Ejemplo n.º 6
0
        public void Verify_AreEqualExtension_CallsAreEqual()
        {
            // Arrange
            var mockMapper = new Mock <SeriesMapper>();

            mockMapper.Setup(x => x.AreEqual(It.IsAny <ISeriesModel>(), It.IsAny <ISeries>()));
            SeriesMapperExtensions.OverrideMapper(mockMapper.Object);
            var mockModel  = SeriesMockingSetup.DoMockingSetupForSeriesModel(1);
            var mockEntity = SeriesMockingSetup.DoMockingSetupForSeries(1);

            // Act
            mockModel.Object.AreEqual(mockEntity.Object);
            // Assert
            mockMapper.Verify(x => x.AreEqual(It.IsAny <ISeriesModel>(), It.IsAny <ISeries>()), Times.Once);
        }
Ejemplo n.º 7
0
        public void Verify_MapToModel_AssignsSeriesProperties()
        {
            // Arrange
            var mapper = new SeriesMapper();
            var entity = SeriesMockingSetup.DoMockingSetupForSeries();
            // Act
            var model = mapper.MapToModel(entity.Object);

            // Assert
            Assert.Equal(entity.Object.Startyear, model.Startyear);
            // Related Objects
            Assert.Equal(entity.Object.PublisherId, model.PublisherId);
            Assert.Equal(entity.Object.FirstEpisodeId, model.FirstEpisodeId);
            Assert.Equal(entity.Object.LastEpisodeId, model.LastEpisodeId);
            // Associated Objects
            Assert.Equal(entity.Object.Episodes?.Count, model.Episodes?.Count);
            Assert.Equal(entity.Object.SeriesAliases?.Count, model.SeriesAliases?.Count);
            Assert.Equal(entity.Object.SeriesCharacters?.Count, model.SeriesCharacters?.Count);
            Assert.Equal(entity.Object.SeriesLocations?.Count, model.SeriesLocations?.Count);
        }