Beispiel #1
0
        public void Verify_MapToSearchModel_AssignsTeamSearchProperties()
        {
            // Arrange
            var mapper = new TeamMapper();
            var model  = TeamsMockingSetup.DoMockingSetupForTeamModel();
            // 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.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.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);
        }
Beispiel #2
0
        public void Verify_AreEqual_WithDifferentObjects_ReturnsFalse()
        {
            // Arrange
            var mapper = new TeamMapper();
            var model  = TeamsMockingSetup.DoMockingSetupForTeamModel(1);
            var entity = TeamsMockingSetup.DoMockingSetupForTeam(2);
            // Act
            var result = mapper.AreEqual(model.Object, entity.Object);

            // Assert
            Assert.False(result);
        }
Beispiel #3
0
        public void Verify_MapToSearchModelExtension_CallsMapToModel()
        {
            // Arrange
            var mockMapper = new Mock <TeamMapper>();

            mockMapper.Setup(x => x.MapToSearchModel(It.IsAny <ITeamModel>()));
            var mockModel = TeamsMockingSetup.DoMockingSetupForTeamModel(1);

            TeamMapperExtensions.OverrideMapper(mockMapper.Object);
            // Act
            mockModel.Object.MapToSearchModel();
            // Assert
            mockMapper.Verify(x => x.MapToSearchModel(It.IsAny <ITeamModel>()), Times.Once);
        }
Beispiel #4
0
        public void Verify_AreEqualExtension_CallsAreEqual()
        {
            // Arrange
            var mockMapper = new Mock <TeamMapper>();

            mockMapper.Setup(x => x.AreEqual(It.IsAny <ITeamModel>(), It.IsAny <ITeam>()));
            TeamMapperExtensions.OverrideMapper(mockMapper.Object);
            var mockModel  = TeamsMockingSetup.DoMockingSetupForTeamModel(1);
            var mockEntity = TeamsMockingSetup.DoMockingSetupForTeam(1);

            // Act
            mockModel.Object.AreEqual(mockEntity.Object);
            // Assert
            mockMapper.Verify(x => x.AreEqual(It.IsAny <ITeamModel>(), It.IsAny <ITeam>()), Times.Once);
        }
Beispiel #5
0
        public void Verify_MapToEntity_WithExistingEntity_AssignsTeamProperties()
        {
            // Arrange
            var mapper = new TeamMapper();
            var model  = TeamsMockingSetup.DoMockingSetupForTeamModel();
            // Act
            ITeam existingEntity = new Team {
                Id = 1
            };

            mapper.MapToEntity(model.Object, ref existingEntity);
            // Assert
            // <None>
            // Related Objects
            Assert.Equal(model.Object.PrimaryImageFileId, existingEntity.PrimaryImageFileId);
            Assert.Equal(model.Object.FirstIssueAppearanceId, existingEntity.FirstIssueAppearanceId);
            Assert.Equal(model.Object.PublisherId, existingEntity.PublisherId);
            // Associated Objects
            model.VerifyGet(x => x.TeamAliases, Times.Once);
            //Assert.Equal(model.Object.TeamAliases?.Count, existingEntity.TeamAliases?.Count);
            model.VerifyGet(x => x.TeamCharacterEnemies, Times.Once);
            //Assert.Equal(model.Object.TeamCharacterEnemies?.Count, existingEntity.TeamCharacterEnemies?.Count);
            model.VerifyGet(x => x.TeamCharacterFriends, Times.Once);
            //Assert.Equal(model.Object.TeamCharacterFriends?.Count, existingEntity.TeamCharacterFriends?.Count);
            model.VerifyGet(x => x.TeamIssuesAppearedIn, Times.Once);
            //Assert.Equal(model.Object.TeamIssuesAppearedIn?.Count, existingEntity.TeamIssuesAppearedIn?.Count);
            model.VerifyGet(x => x.TeamIssuesDisbandedIn, Times.Once);
            //Assert.Equal(model.Object.TeamIssuesDisbandedIn?.Count, existingEntity.TeamIssuesDisbandedIn?.Count);
            model.VerifyGet(x => x.TeamIssues, Times.Once);
            //Assert.Equal(model.Object.TeamIssues?.Count, existingEntity.TeamIssues?.Count);
            model.VerifyGet(x => x.TeamMembers, Times.Once);
            //Assert.Equal(model.Object.TeamMembers?.Count, existingEntity.TeamMembers?.Count);
            model.VerifyGet(x => x.TeamMovies, Times.Once);
            //Assert.Equal(model.Object.TeamMovies?.Count, existingEntity.TeamMovies?.Count);
            model.VerifyGet(x => x.TeamStoryArcs, Times.Once);
            //Assert.Equal(model.Object.TeamStoryArcs?.Count, existingEntity.TeamStoryArcs?.Count);
            model.VerifyGet(x => x.TeamVolumes, Times.Once);
            //Assert.Equal(model.Object.TeamVolumes?.Count, existingEntity.TeamVolumes?.Count);
        }