public void Verify_MapToEntity_WithExistingEntity_AssignsVideoProperties() { // Arrange var mapper = new VideoMapper(); var model = VideosMockingSetup.DoMockingSetupForVideoModel(); // Act IVideo existingEntity = new Video { Id = 1 }; mapper.MapToEntity(model.Object, ref existingEntity); // Assert Assert.Equal(model.Object.LowUrl, existingEntity.LowUrl); Assert.Equal(model.Object.HighUrl, existingEntity.HighUrl); Assert.Equal(model.Object.HdUrl, existingEntity.HdUrl); Assert.Equal(model.Object.Url, existingEntity.Url); Assert.Equal(model.Object.LengthSeconds, existingEntity.LengthSeconds); Assert.Equal(model.Object.PublishDate, existingEntity.PublishDate); // Related Objects Assert.Equal(model.Object.PrimaryImageFileId, existingEntity.PrimaryImageFileId); Assert.Equal(model.Object.AuthorId, existingEntity.AuthorId); Assert.Equal(model.Object.VideoTypeId, existingEntity.VideoTypeId); // Associated Objects // <None> }
public void Verify_MapToSearchModel_AssignsVideoSearchProperties() { // Arrange var mapper = new VideoMapper(); var model = VideosMockingSetup.DoMockingSetupForVideoModel(); // 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.AuthorId, searchModel.AuthorId); Assert.Equal(model.Object.Author?.CustomKey, searchModel.AuthorCustomKey); Assert.Equal(model.Object.Author?.ApiDetailUrl, searchModel.AuthorApiDetailUrl); Assert.Equal(model.Object.Author?.SiteDetailUrl, searchModel.AuthorSiteDetailUrl); Assert.Equal(model.Object.Author?.Name, searchModel.AuthorName); Assert.Equal(model.Object.Author?.ShortDescription, searchModel.AuthorShortDescription); Assert.Equal(model.Object.Author?.Description, searchModel.AuthorDescription); Assert.Equal(model.Object.VideoTypeId, searchModel.VideoTypeId); Assert.Equal(model.Object.VideoType?.CustomKey, searchModel.VideoTypeCustomKey); Assert.Equal(model.Object.VideoType?.ApiDetailUrl, searchModel.VideoTypeApiDetailUrl); Assert.Equal(model.Object.VideoType?.SiteDetailUrl, searchModel.VideoTypeSiteDetailUrl); Assert.Equal(model.Object.VideoType?.Name, searchModel.VideoTypeName); Assert.Equal(model.Object.VideoType?.ShortDescription, searchModel.VideoTypeShortDescription); Assert.Equal(model.Object.VideoType?.Description, searchModel.VideoTypeDescription); }
public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse() { // Arrange var mapper = new VideoMapper(); var model = VideosMockingSetup.DoMockingSetupForVideoModel(1); var entity = VideosMockingSetup.DoMockingSetupForVideo(2); // Act var result = mapper.AreEqual(model.Object, entity.Object); // Assert Assert.False(result); }
public void Verify_MapToEntityExtension_CallsMapToEntity() { // Arrange var mockMapper = new Mock <VideoMapper>(); mockMapper.Setup(x => x.MapToEntity(It.IsAny <IVideoModel>(), It.IsAny <int>())); var mockModel = VideosMockingSetup.DoMockingSetupForVideoModel(1); VideoMapperExtensions.OverrideMapper(mockMapper.Object); // Act mockModel.Object.MapToEntity(); // Assert mockMapper.Verify(x => x.MapToEntity(It.IsAny <IVideoModel>(), It.IsAny <int>()), Times.Once); }
public void Verify_AreEqualExtension_CallsAreEqual() { // Arrange var mockMapper = new Mock <VideoMapper>(); mockMapper.Setup(x => x.AreEqual(It.IsAny <IVideoModel>(), It.IsAny <IVideo>())); VideoMapperExtensions.OverrideMapper(mockMapper.Object); var mockModel = VideosMockingSetup.DoMockingSetupForVideoModel(1); var mockEntity = VideosMockingSetup.DoMockingSetupForVideo(1); // Act mockModel.Object.AreEqual(mockEntity.Object); // Assert mockMapper.Verify(x => x.AreEqual(It.IsAny <IVideoModel>(), It.IsAny <IVideo>()), Times.Once); }