예제 #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);
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
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);
        }