Beispiel #1
0
        public void Verify_MapToModel_AssignsVolumeProperties()
        {
            // Arrange
            var mapper = new VolumeMapper();
            var entity = VolumesMockingSetup.DoMockingSetupForVolume();
            // Act
            var model = mapper.MapToModel(entity.Object);

            // Assert
            Assert.Equal(entity.Object.Startyear, model.Startyear);
            // Related Objects
            Assert.Equal(entity.Object.PrimaryImageFileId, model.PrimaryImageFileId);
            Assert.Equal(entity.Object.FirstIssueId, model.FirstIssueId);
            Assert.Equal(entity.Object.LastIssueId, model.LastIssueId);
            Assert.Equal(entity.Object.PublisherId, model.PublisherId);
            // Associated Objects
            Assert.Equal(entity.Object.Issues?.Count, model.Issues?.Count);
            Assert.Equal(entity.Object.VolumeAliases?.Count, model.VolumeAliases?.Count);
            Assert.Equal(entity.Object.VolumeCharacters?.Count, model.VolumeCharacters?.Count);
            Assert.Equal(entity.Object.VolumeConcepts?.Count, model.VolumeConcepts?.Count);
            Assert.Equal(entity.Object.VolumeLocations?.Count, model.VolumeLocations?.Count);
            Assert.Equal(entity.Object.VolumeObjects?.Count, model.VolumeObjects?.Count);
            Assert.Equal(entity.Object.VolumeTeams?.Count, model.VolumeTeams?.Count);
            Assert.Equal(entity.Object.VolumeWriters?.Count, model.VolumeWriters?.Count);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        public void Verify_MapToModelListingExtension_CallsMapToModel()
        {
            // Arrange
            var mockMapper = new Mock <VolumeMapper>();

            mockMapper.Setup(x => x.MapToModelListing(It.IsAny <IVolume>(), It.IsAny <int>()));
            var mockEntity = VolumesMockingSetup.DoMockingSetupForVolume(1);

            VolumeMapperExtensions.OverrideMapper(mockMapper.Object);
            // Act
            mockEntity.Object.MapToModelListing();
            // Assert
            mockMapper.Verify(x => x.MapToModelListing(It.IsAny <IVolume>(), It.IsAny <int>()), Times.Once);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        public void Verify_MapToModelLite_AssignsLiteOnlyVolumeProperties()
        {
            // Arrange
            var mapper = new VolumeMapper();
            var entity = VolumesMockingSetup.DoMockingSetupForVolume();
            // Act
            var model = mapper.MapToModelLite(entity.Object);

            // Assert
            Assert.Equal(entity.Object.Startyear, model.Startyear);
            // Related Objects
            Assert.Equal(entity.Object.PrimaryImageFileId, model.PrimaryImageFileId);
            Assert.Equal(entity.Object.FirstIssueId, model.FirstIssueId);
            Assert.Equal(entity.Object.LastIssueId, model.LastIssueId);
            Assert.Equal(entity.Object.PublisherId, model.PublisherId);
        }
Beispiel #8
0
        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);
        }