Exemplo n.º 1
0
        public void Map_DomainContributorTeamAsParam_MappedToViewModel()
        {
            var contributors = new List <Contributor>
            {
                new Contributor
                {
                    Id   = 1,
                    Name = "FirstNameA",
                    ContributorTeamId = 1
                },
                new Contributor
                {
                    Id   = 2,
                    Name = "FirstNameB",
                    ContributorTeamId = 1
                },
                new Contributor
                {
                    Id   = 3,
                    Name = "FirstNameC",
                    ContributorTeamId = 1
                }
            };

            // Arrange
            var testViewModel = new ContributorTeamMvcViewModelBuilder()
                                .WithId(1)
                                .WithName("FirstName")
                                .WithCourseDirection("Course")
                                .WithContributors(contributors)
                                .Build();

            var testDomainModel = new ContributorTeamBuilder()
                                  .WithId(1)
                                  .WithName("FirstName")
                                  .WithcourseDirection("Course")
                                  .Withcontributors(contributors)
                                  .Build();

            // Act
            var actual = ContributorsTeamViewModel.Map(testDomainModel);

            // Assert
            Assert.Equal <ContributorsTeamViewModel>(testViewModel, actual, new ContributorTeamViewModelComparer());
        }
        public void ToDomain_ContributorTeamViewModel_MappedToDomain()
        {
            // Arrange
            var testViewModel = new ContributorTeamMvcViewModelBuilder()
                                .WithId(1)
                                .WithName("First")
                                .WithCourseDirection("Course")
                                .WithContributors(new List <Contributor>
            {
                new Contributor
                {
                    Id   = 1,
                    Name = "FirstNameA",
                    ContributorTeamId = 1
                },
                new Contributor
                {
                    Id   = 2,
                    Name = "FirstNameB",
                    ContributorTeamId = 1
                },
                new Contributor
                {
                    Id   = 3,
                    Name = "FirstNameC",
                    ContributorTeamId = 1
                }
            })
                                .Build();

            var testDomainModel = new ContributorTeamBuilder()
                                  .WithId(1)
                                  .WithName("First")
                                  .WithcourseDirection("Course")
                                  .Withcontributors(new List <Contributor>
            {
                new Contributor
                {
                    Id   = 1,
                    Name = "FirstNameA",
                    ContributorTeamId = 1
                },
                new Contributor
                {
                    Id   = 2,
                    Name = "FirstNameB",
                    ContributorTeamId = 1
                },
                new Contributor
                {
                    Id   = 3,
                    Name = "FirstNameC",
                    ContributorTeamId = 1
                }
            })
                                  .Build();

            // Act
            var actual = testViewModel.ToDomain();

            // Assert
            Assert.Equal <ContributorTeam>(testDomainModel, actual, new ContributorTeamComparer());
        }