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); }
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); }
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); }
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); }