public void Verify_MapToEntity_AssignsVolumeProperties() { // Arrange var mapper = new VolumeMapper(); var model = VolumesMockingSetup.DoMockingSetupForVolumeModel(); // Act var entity = mapper.MapToEntity(model.Object); // Assert Assert.Equal(model.Object.Startyear, entity.Startyear); // Related Objects Assert.Equal(model.Object.PrimaryImageFileId, entity.PrimaryImageFileId); Assert.Equal(model.Object.FirstIssueId, entity.FirstIssueId); Assert.Equal(model.Object.LastIssueId, entity.LastIssueId); Assert.Equal(model.Object.PublisherId, entity.PublisherId); // Associated Objects //Assert.Equal(model.Object.Issues?.Count, entity.Issues?.Count); model.VerifyGet(x => x.Issues, Times.Once); //Assert.Equal(model.Object.VolumeAliases?.Count, entity.VolumeAliases?.Count); model.VerifyGet(x => x.VolumeAliases, Times.Once); //Assert.Equal(model.Object.VolumeCharacters?.Count, entity.VolumeCharacters?.Count); model.VerifyGet(x => x.VolumeCharacters, Times.Once); //Assert.Equal(model.Object.VolumeConcepts?.Count, entity.VolumeConcepts?.Count); model.VerifyGet(x => x.VolumeConcepts, Times.Once); //Assert.Equal(model.Object.VolumeLocations?.Count, entity.VolumeLocations?.Count); model.VerifyGet(x => x.VolumeLocations, Times.Once); //Assert.Equal(model.Object.VolumeObjects?.Count, entity.VolumeObjects?.Count); model.VerifyGet(x => x.VolumeObjects, Times.Once); //Assert.Equal(model.Object.VolumeTeams?.Count, entity.VolumeTeams?.Count); model.VerifyGet(x => x.VolumeTeams, Times.Once); //Assert.Equal(model.Object.VolumeWriters?.Count, entity.VolumeWriters?.Count); model.VerifyGet(x => x.VolumeWriters, Times.Once); }
public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse() { // Arrange var mapper = new VolumeMapper(); var model = VolumesMockingSetup.DoMockingSetupForVolumeModel(1); var entity = VolumesMockingSetup.DoMockingSetupForVolume(2); // Act var result = mapper.AreEqual(model.Object, entity.Object); // Assert Assert.False(result); }
public void Verify_MapToSearchModelExtension_CallsMapToModel() { // Arrange var mockMapper = new Mock <VolumeMapper>(); mockMapper.Setup(x => x.MapToSearchModel(It.IsAny <IVolumeModel>())); var mockModel = VolumesMockingSetup.DoMockingSetupForVolumeModel(1); VolumeMapperExtensions.OverrideMapper(mockMapper.Object); // Act mockModel.Object.MapToSearchModel(); // Assert mockMapper.Verify(x => x.MapToSearchModel(It.IsAny <IVolumeModel>()), Times.Once); }
public void Verify_AreEqualExtension_CallsAreEqual() { // Arrange var mockMapper = new Mock <VolumeMapper>(); mockMapper.Setup(x => x.AreEqual(It.IsAny <IVolumeModel>(), It.IsAny <IVolume>())); VolumeMapperExtensions.OverrideMapper(mockMapper.Object); var mockModel = VolumesMockingSetup.DoMockingSetupForVolumeModel(1); var mockEntity = VolumesMockingSetup.DoMockingSetupForVolume(1); // Act mockModel.Object.AreEqual(mockEntity.Object); // Assert mockMapper.Verify(x => x.AreEqual(It.IsAny <IVolumeModel>(), It.IsAny <IVolume>()), Times.Once); }
public void Verify_MapToSearchModel_AssignsVolumeSearchProperties() { // Arrange var mapper = new VolumeMapper(); var model = VolumesMockingSetup.DoMockingSetupForVolumeModel(); // 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.FirstIssueId, searchModel.FirstIssueId); Assert.Equal(model.Object.FirstIssue?.CustomKey, searchModel.FirstIssueCustomKey); Assert.Equal(model.Object.FirstIssue?.ApiDetailUrl, searchModel.FirstIssueApiDetailUrl); Assert.Equal(model.Object.FirstIssue?.SiteDetailUrl, searchModel.FirstIssueSiteDetailUrl); Assert.Equal(model.Object.FirstIssue?.Name, searchModel.FirstIssueName); Assert.Equal(model.Object.FirstIssue?.ShortDescription, searchModel.FirstIssueShortDescription); Assert.Equal(model.Object.FirstIssue?.Description, searchModel.FirstIssueDescription); Assert.Equal(model.Object.LastIssueId, searchModel.LastIssueId); Assert.Equal(model.Object.LastIssue?.CustomKey, searchModel.LastIssueCustomKey); Assert.Equal(model.Object.LastIssue?.ApiDetailUrl, searchModel.LastIssueApiDetailUrl); Assert.Equal(model.Object.LastIssue?.SiteDetailUrl, searchModel.LastIssueSiteDetailUrl); Assert.Equal(model.Object.LastIssue?.Name, searchModel.LastIssueName); Assert.Equal(model.Object.LastIssue?.ShortDescription, searchModel.LastIssueShortDescription); Assert.Equal(model.Object.LastIssue?.Description, searchModel.LastIssueDescription); 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); }