public void Verify_MapToEntity_WithExistingEntity_AssignsLocationProperties() { // Arrange var mapper = new LocationMapper(); var model = LocationsMockingSetup.DoMockingSetupForLocationModel(); // Act ILocation existingEntity = new Location { Id = 1 }; mapper.MapToEntity(model.Object, ref existingEntity); // Assert Assert.Equal(model.Object.StartYear, existingEntity.StartYear); // Related Objects Assert.Equal(model.Object.FirstIssueAppearanceId, existingEntity.FirstIssueAppearanceId); Assert.Equal(model.Object.PrimaryImageFileId, existingEntity.PrimaryImageFileId); // Associated Objects model.VerifyGet(x => x.LocationAliases, Times.Once); //Assert.Equal(model.Object.LocationAliases?.Count, existingEntity.LocationAliases?.Count); model.VerifyGet(x => x.LocationAppearedInIssues, Times.Once); //Assert.Equal(model.Object.LocationAppearedInIssues?.Count, existingEntity.LocationAppearedInIssues?.Count); model.VerifyGet(x => x.LocationIssues, Times.Once); //Assert.Equal(model.Object.LocationIssues?.Count, existingEntity.LocationIssues?.Count); model.VerifyGet(x => x.LocationMovies, Times.Once); //Assert.Equal(model.Object.LocationMovies?.Count, existingEntity.LocationMovies?.Count); model.VerifyGet(x => x.LocationStoryArcs, Times.Once); //Assert.Equal(model.Object.LocationStoryArcs?.Count, existingEntity.LocationStoryArcs?.Count); model.VerifyGet(x => x.LocationVolumes, Times.Once); //Assert.Equal(model.Object.LocationVolumes?.Count, existingEntity.LocationVolumes?.Count); }
public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse() { // Arrange var mapper = new LocationMapper(); var model = LocationsMockingSetup.DoMockingSetupForLocationModel(1); var entity = LocationsMockingSetup.DoMockingSetupForLocation(2); // Act var result = mapper.AreEqual(model.Object, entity.Object); // Assert Assert.False(result); }
public void Verify_MapToEntityExtension_CallsMapToEntity() { // Arrange var mockMapper = new Mock <LocationMapper>(); mockMapper.Setup(x => x.MapToEntity(It.IsAny <ILocationModel>(), It.IsAny <int>())); var mockModel = LocationsMockingSetup.DoMockingSetupForLocationModel(1); LocationMapperExtensions.OverrideMapper(mockMapper.Object); // Act mockModel.Object.MapToEntity(); // Assert mockMapper.Verify(x => x.MapToEntity(It.IsAny <ILocationModel>(), It.IsAny <int>()), Times.Once); }
public void Verify_MapToModelLite_AssignsLiteOnlyLocationProperties() { // Arrange var mapper = new LocationMapper(); var entity = LocationsMockingSetup.DoMockingSetupForLocation(); // Act var model = mapper.MapToModelLite(entity.Object); // Assert Assert.Equal(entity.Object.StartYear, model.StartYear); // Related Objects Assert.Equal(entity.Object.FirstIssueAppearanceId, model.FirstIssueAppearanceId); Assert.Equal(entity.Object.PrimaryImageFileId, model.PrimaryImageFileId); }
public void Verify_AreEqualExtension_CallsAreEqual() { // Arrange var mockMapper = new Mock <LocationMapper>(); mockMapper.Setup(x => x.AreEqual(It.IsAny <ILocationModel>(), It.IsAny <ILocation>())); LocationMapperExtensions.OverrideMapper(mockMapper.Object); var mockModel = LocationsMockingSetup.DoMockingSetupForLocationModel(1); var mockEntity = LocationsMockingSetup.DoMockingSetupForLocation(1); // Act mockModel.Object.AreEqual(mockEntity.Object); // Assert mockMapper.Verify(x => x.AreEqual(It.IsAny <ILocationModel>(), It.IsAny <ILocation>()), Times.Once); }
public void Verify_MapToModel_AssignsLocationProperties() { // Arrange var mapper = new LocationMapper(); var entity = LocationsMockingSetup.DoMockingSetupForLocation(); // Act var model = mapper.MapToModel(entity.Object); // Assert Assert.Equal(entity.Object.StartYear, model.StartYear); // Related Objects Assert.Equal(entity.Object.FirstIssueAppearanceId, model.FirstIssueAppearanceId); Assert.Equal(entity.Object.PrimaryImageFileId, model.PrimaryImageFileId); // Associated Objects Assert.Equal(entity.Object.LocationAliases?.Count, model.LocationAliases?.Count); Assert.Equal(entity.Object.LocationAppearedInIssues?.Count, model.LocationAppearedInIssues?.Count); Assert.Equal(entity.Object.LocationIssues?.Count, model.LocationIssues?.Count); Assert.Equal(entity.Object.LocationMovies?.Count, model.LocationMovies?.Count); Assert.Equal(entity.Object.LocationStoryArcs?.Count, model.LocationStoryArcs?.Count); Assert.Equal(entity.Object.LocationVolumes?.Count, model.LocationVolumes?.Count); }
public void Verify_MapToSearchModel_AssignsLocationSearchProperties() { // Arrange var mapper = new LocationMapper(); var model = LocationsMockingSetup.DoMockingSetupForLocationModel(); // Act var searchModel = mapper.MapToSearchModel(model.Object); // Assert Assert.Equal(model.Object.FirstIssueAppearanceId, searchModel.FirstIssueAppearanceId); Assert.Equal(model.Object.FirstIssueAppearance?.CustomKey, searchModel.FirstIssueAppearanceCustomKey); Assert.Equal(model.Object.FirstIssueAppearance?.ApiDetailUrl, searchModel.FirstIssueAppearanceApiDetailUrl); Assert.Equal(model.Object.FirstIssueAppearance?.SiteDetailUrl, searchModel.FirstIssueAppearanceSiteDetailUrl); Assert.Equal(model.Object.FirstIssueAppearance?.Name, searchModel.FirstIssueAppearanceName); Assert.Equal(model.Object.FirstIssueAppearance?.ShortDescription, searchModel.FirstIssueAppearanceShortDescription); Assert.Equal(model.Object.FirstIssueAppearance?.Description, searchModel.FirstIssueAppearanceDescription); 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); }