Exemplo n.º 1
0
        public void Verify_MapToEntity_WithExistingEntity_AssignsPublisherProperties()
        {
            // Arrange
            var mapper = new PublisherMapper();
            var model  = PublishersMockingSetup.DoMockingSetupForPublisherModel();
            // Act
            IPublisher existingEntity = new Publisher {
                Id = 1
            };

            mapper.MapToEntity(model.Object, ref existingEntity);
            // Assert
            Assert.Equal(model.Object.LocationAddress, existingEntity.LocationAddress);
            Assert.Equal(model.Object.LocationCity, existingEntity.LocationCity);
            Assert.Equal(model.Object.LocationState, existingEntity.LocationState);
            // Related Objects
            Assert.Equal(model.Object.PrimaryImageFileId, existingEntity.PrimaryImageFileId);
            // Associated Objects
            model.VerifyGet(x => x.CharactersPublished, Times.Once);
            //Assert.Equal(model.Object.CharactersPublished?.Count, existingEntity.CharactersPublished?.Count);
            model.VerifyGet(x => x.PublisherAliases, Times.Once);
            //Assert.Equal(model.Object.PublisherAliases?.Count, existingEntity.PublisherAliases?.Count);
            model.VerifyGet(x => x.SeriesPublished, Times.Once);
            //Assert.Equal(model.Object.SeriesPublished?.Count, existingEntity.SeriesPublished?.Count);
            model.VerifyGet(x => x.StoryArcsPublished, Times.Once);
            //Assert.Equal(model.Object.StoryArcsPublished?.Count, existingEntity.StoryArcsPublished?.Count);
            model.VerifyGet(x => x.TeamsPublished, Times.Once);
            //Assert.Equal(model.Object.TeamsPublished?.Count, existingEntity.TeamsPublished?.Count);
            model.VerifyGet(x => x.VolumesPublished, Times.Once);
            //Assert.Equal(model.Object.VolumesPublished?.Count, existingEntity.VolumesPublished?.Count);
        }
Exemplo n.º 2
0
        public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse()
        {
            // Arrange
            var mapper = new PublisherMapper();
            var model  = PublishersMockingSetup.DoMockingSetupForPublisherModel(1);
            var entity = PublishersMockingSetup.DoMockingSetupForPublisher(2);
            // Act
            var result = mapper.AreEqual(model.Object, entity.Object);

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

            mockMapper.Setup(x => x.MapToEntity(It.IsAny <IPublisherModel>(), It.IsAny <int>()));
            var mockModel = PublishersMockingSetup.DoMockingSetupForPublisherModel(1);

            PublisherMapperExtensions.OverrideMapper(mockMapper.Object);
            // Act
            mockModel.Object.MapToEntity();
            // Assert
            mockMapper.Verify(x => x.MapToEntity(It.IsAny <IPublisherModel>(), It.IsAny <int>()), Times.Once);
        }
Exemplo n.º 4
0
        public void Verify_MapToModelLite_AssignsLiteOnlyPublisherProperties()
        {
            // Arrange
            var mapper = new PublisherMapper();
            var entity = PublishersMockingSetup.DoMockingSetupForPublisher();
            // Act
            var model = mapper.MapToModelLite(entity.Object);

            // Assert
            Assert.Equal(entity.Object.LocationAddress, model.LocationAddress);
            Assert.Equal(entity.Object.LocationCity, model.LocationCity);
            Assert.Equal(entity.Object.LocationState, model.LocationState);
            // Related Objects
            Assert.Equal(entity.Object.PrimaryImageFileId, model.PrimaryImageFileId);
        }
Exemplo n.º 5
0
        public void Verify_MapToSearchModel_AssignsPublisherSearchProperties()
        {
            // Arrange
            var mapper = new PublisherMapper();
            var model  = PublishersMockingSetup.DoMockingSetupForPublisherModel();
            // 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);
        }
Exemplo n.º 6
0
        public void Verify_MapToModel_AssignsPublisherProperties()
        {
            // Arrange
            var mapper = new PublisherMapper();
            var entity = PublishersMockingSetup.DoMockingSetupForPublisher();
            // Act
            var model = mapper.MapToModel(entity.Object);

            // Assert
            Assert.Equal(entity.Object.LocationAddress, model.LocationAddress);
            Assert.Equal(entity.Object.LocationCity, model.LocationCity);
            Assert.Equal(entity.Object.LocationState, model.LocationState);
            // Related Objects
            Assert.Equal(entity.Object.PrimaryImageFileId, model.PrimaryImageFileId);
            // Associated Objects
            Assert.Equal(entity.Object.CharactersPublished?.Count, model.CharactersPublished?.Count);
            Assert.Equal(entity.Object.PublisherAliases?.Count, model.PublisherAliases?.Count);
            Assert.Equal(entity.Object.SeriesPublished?.Count, model.SeriesPublished?.Count);
            Assert.Equal(entity.Object.StoryArcsPublished?.Count, model.StoryArcsPublished?.Count);
            Assert.Equal(entity.Object.TeamsPublished?.Count, model.TeamsPublished?.Count);
            Assert.Equal(entity.Object.VolumesPublished?.Count, model.VolumesPublished?.Count);
        }