public void Verify_MapToEntity_WithExistingEntity_AssignsObjectProperties()
        {
            // Arrange
            var mapper = new ObjectMapper();
            var model  = ObjectsMockingSetup.DoMockingSetupForObjectModel();
            // Act
            IObject existingEntity = new Object {
                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.ObjectAliases, Times.Once);
            //Assert.Equal(model.Object.ObjectAliases?.Count, existingEntity.ObjectAliases?.Count);
            model.VerifyGet(x => x.ObjectIssuesAppearedIn, Times.Once);
            //Assert.Equal(model.Object.ObjectIssuesAppearedIn?.Count, existingEntity.ObjectIssuesAppearedIn?.Count);
            model.VerifyGet(x => x.ObjectIssues, Times.Once);
            //Assert.Equal(model.Object.ObjectIssues?.Count, existingEntity.ObjectIssues?.Count);
            model.VerifyGet(x => x.ObjectMovies, Times.Once);
            //Assert.Equal(model.Object.ObjectMovies?.Count, existingEntity.ObjectMovies?.Count);
            model.VerifyGet(x => x.ObjectStoryArcs, Times.Once);
            //Assert.Equal(model.Object.ObjectStoryArcs?.Count, existingEntity.ObjectStoryArcs?.Count);
            model.VerifyGet(x => x.ObjectVolumes, Times.Once);
            //Assert.Equal(model.Object.ObjectVolumes?.Count, existingEntity.ObjectVolumes?.Count);
        }
        public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse()
        {
            // Arrange
            var mapper = new ObjectMapper();
            var model  = ObjectsMockingSetup.DoMockingSetupForObjectModel(1);
            var entity = ObjectsMockingSetup.DoMockingSetupForObject(2);
            // Act
            var result = mapper.AreEqual(model.Object, entity.Object);

            // Assert
            Assert.False(result);
        }
        public void Verify_MapToEntityExtension_CallsMapToEntity()
        {
            // Arrange
            var mockMapper = new Mock <ObjectMapper>();

            mockMapper.Setup(x => x.MapToEntity(It.IsAny <IObjectModel>(), It.IsAny <int>()));
            var mockModel = ObjectsMockingSetup.DoMockingSetupForObjectModel(1);

            ObjectMapperExtensions.OverrideMapper(mockMapper.Object);
            // Act
            mockModel.Object.MapToEntity();
            // Assert
            mockMapper.Verify(x => x.MapToEntity(It.IsAny <IObjectModel>(), It.IsAny <int>()), Times.Once);
        }
        public void Verify_MapToModelLite_AssignsLiteOnlyObjectProperties()
        {
            // Arrange
            var mapper = new ObjectMapper();
            var entity = ObjectsMockingSetup.DoMockingSetupForObject();
            // 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_MapToModel_AssignsObjectProperties()
        {
            // Arrange
            var mapper = new ObjectMapper();
            var entity = ObjectsMockingSetup.DoMockingSetupForObject();
            // 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.ObjectAliases?.Count, model.ObjectAliases?.Count);
            Assert.Equal(entity.Object.ObjectIssuesAppearedIn?.Count, model.ObjectIssuesAppearedIn?.Count);
            Assert.Equal(entity.Object.ObjectIssues?.Count, model.ObjectIssues?.Count);
            Assert.Equal(entity.Object.ObjectMovies?.Count, model.ObjectMovies?.Count);
            Assert.Equal(entity.Object.ObjectStoryArcs?.Count, model.ObjectStoryArcs?.Count);
            Assert.Equal(entity.Object.ObjectVolumes?.Count, model.ObjectVolumes?.Count);
        }
        public void Verify_MapToSearchModel_AssignsObjectSearchProperties()
        {
            // Arrange
            var mapper = new ObjectMapper();
            var model  = ObjectsMockingSetup.DoMockingSetupForObjectModel();
            // 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);
        }