public void Verify_MapToEntity_WithExistingEntity_AssignsIssueProperties() { // Arrange var mapper = new IssueMapper(); var model = IssuesMockingSetup.DoMockingSetupForIssueModel(); // Act IIssue existingEntity = new Issue { Id = 1 }; mapper.MapToEntity(model.Object, ref existingEntity); // Assert Assert.Equal(model.Object.HasStaffReview, existingEntity.HasStaffReview); Assert.Equal(model.Object.CoverDate, existingEntity.CoverDate); Assert.Equal(model.Object.StoreDate, existingEntity.StoreDate); Assert.Equal(model.Object.IssueNumber, existingEntity.IssueNumber); // Related Objects Assert.Equal(model.Object.PrimaryImageFileId, existingEntity.PrimaryImageFileId); Assert.Equal(model.Object.VolumeId, existingEntity.VolumeId); // Associated Objects model.VerifyGet(x => x.IssueAliases, Times.Once); //Assert.Equal(model.Object.IssueAliases?.Count, existingEntity.IssueAliases?.Count); model.VerifyGet(x => x.IssueStoryArcs, Times.Once); //Assert.Equal(model.Object.IssueStoryArcs?.Count, existingEntity.IssueStoryArcs?.Count); model.VerifyGet(x => x.IssueWriters, Times.Once); //Assert.Equal(model.Object.IssueWriters?.Count, existingEntity.IssueWriters?.Count); }
public void Verify_MapToSearchModel_AssignsIssueSearchProperties() { // Arrange var mapper = new IssueMapper(); var model = IssuesMockingSetup.DoMockingSetupForIssueModel(); // 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.VolumeId, searchModel.VolumeId); Assert.Equal(model.Object.Volume?.CustomKey, searchModel.VolumeCustomKey); Assert.Equal(model.Object.Volume?.ApiDetailUrl, searchModel.VolumeApiDetailUrl); Assert.Equal(model.Object.Volume?.SiteDetailUrl, searchModel.VolumeSiteDetailUrl); Assert.Equal(model.Object.Volume?.Name, searchModel.VolumeName); Assert.Equal(model.Object.Volume?.ShortDescription, searchModel.VolumeShortDescription); Assert.Equal(model.Object.Volume?.Description, searchModel.VolumeDescription); Assert.Equal(model.Object.HasStaffReview, searchModel.HasStaffReview); }
public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse() { // Arrange var mapper = new IssueMapper(); var model = IssuesMockingSetup.DoMockingSetupForIssueModel(1); var entity = IssuesMockingSetup.DoMockingSetupForIssue(2); // Act var result = mapper.AreEqual(model.Object, entity.Object); // Assert Assert.False(result); }
public void Verify_MapToEntityExtension_CallsMapToEntity() { // Arrange var mockMapper = new Mock <IssueMapper>(); mockMapper.Setup(x => x.MapToEntity(It.IsAny <IIssueModel>(), It.IsAny <int>())); var mockModel = IssuesMockingSetup.DoMockingSetupForIssueModel(1); IssueMapperExtensions.OverrideMapper(mockMapper.Object); // Act mockModel.Object.MapToEntity(); // Assert mockMapper.Verify(x => x.MapToEntity(It.IsAny <IIssueModel>(), It.IsAny <int>()), Times.Once); }
public void Verify_AreEqualExtension_CallsAreEqual() { // Arrange var mockMapper = new Mock <IssueMapper>(); mockMapper.Setup(x => x.AreEqual(It.IsAny <IIssueModel>(), It.IsAny <IIssue>())); IssueMapperExtensions.OverrideMapper(mockMapper.Object); var mockModel = IssuesMockingSetup.DoMockingSetupForIssueModel(1); var mockEntity = IssuesMockingSetup.DoMockingSetupForIssue(1); // Act mockModel.Object.AreEqual(mockEntity.Object); // Assert mockMapper.Verify(x => x.AreEqual(It.IsAny <IIssueModel>(), It.IsAny <IIssue>()), Times.Once); }