Пример #1
0
        public void Should_Map()
        {
            // Arrange
            Entities.Project sourceProject   = FakeProjects.RockingXMas;
            Entities.Project expectedProject = FakeProjects.RockingXMas;
            expectedProject.SetProperty(nameof(Entities.Project.Description), expectedProject.Description + " modified");
            expectedProject.SetProperty(nameof(Entities.Project.Title), expectedProject.Title + " modified");
            var command = new Modify.Command
            {
                Id          = sourceProject.Id,
                Title       = expectedProject.Title,
                ShortTitle  = expectedProject.ShortTitle,
                Description = expectedProject.Description,
                Code        = expectedProject.Code,
                TypeId      = expectedProject.TypeId,
                GenreId     = expectedProject.GenreId,
                StartDate   = expectedProject.StartDate,
                EndDate     = expectedProject.EndDate,
                StateId     = expectedProject.StateId,
                ParentId    = expectedProject.ParentId,
                IsCompleted = expectedProject.IsCompleted,
            };

            // Act
            Entities.Project project = _mapper.Map(command, sourceProject);

            // Assert
            project.Should().BeEquivalentTo(expectedProject, opt => opt.Excluding(dto => dto.Urls));
            project.Urls.Should().BeEquivalentTo(expectedProject.Urls, opt => opt.Excluding(dto => dto.UrlRoles));
        }
Пример #2
0
        public void Should_Map()
        {
            // Arrange
            var dto = new MusicianProfileModifyDto
            {
                Id   = Guid.NewGuid(),
                Body = new MusicianProfileModifyBodyDto
                {
                    IsMainProfile = true,
                    IsDeactivated = false,

                    LevelAssessmentInner   = 1,
                    LevelAssessmentTeam    = 2,
                    ProfilePreferenceInner = 3,
                    ProfilePreferenceTeam  = 4,

                    BackgroundInner = "Performer gave some background",
                    BackgroundTeam  = "Staff gave some background",
                    SalaryComment   = "Perfomer only accepty PayPal",

                    QualificationId      = Guid.NewGuid(),
                    SalaryId             = Guid.NewGuid(),
                    InquiryStatusInnerId = Guid.NewGuid(),
                    InquiryStatusTeamId  = Guid.NewGuid(),

                    // ToDo for collections
                }
            };
            var expectedCommand = new Modify.Command
            {
                Id            = dto.Id,
                IsMainProfile = dto.Body.IsMainProfile,
                IsDeactivated = dto.Body.IsDeactivated,

                LevelAssessmentInner   = dto.Body.LevelAssessmentInner,
                LevelAssessmentTeam    = dto.Body.LevelAssessmentTeam,
                ProfilePreferenceInner = dto.Body.ProfilePreferenceInner,
                ProfilePreferenceTeam  = dto.Body.ProfilePreferenceTeam,

                BackgroundInner = dto.Body.BackgroundInner,
                BackgroundTeam  = dto.Body.BackgroundTeam,
                SalaryComment   = dto.Body.SalaryComment,

                QualificationId      = dto.Body.QualificationId,
                SalaryId             = dto.Body.SalaryId,
                InquiryStatusInnerId = dto.Body.InquiryStatusInnerId,
                InquiryStatusTeamId  = dto.Body.InquiryStatusTeamId,

                // ToDo for collections
            };

            // Act
            Modify.Command command = _mapper.Map <Modify.Command>(dto);

            // Assert
            command.Should().BeEquivalentTo(expectedCommand);
        }
Пример #3
0
        public void Should_Map()
        {
            // Arrange
            var dto = new MyUserProfileModifyDto
            {
                Email       = UserTestSeedData.Performer.Email,
                GivenName   = "Orsi",
                Surname     = "Aner",
                PhoneNumber = "123456"
            };

            // Act
            Modify.Command command = _mapper.Map <Modify.Command>(dto);

            // Assert
            command.Should().BeEquivalentTo(dto);
        }
Пример #4
0
        public void Should_Map()
        {
            // Arrange
            var regionDto = new RegionModifyDto {
                Id = Guid.NewGuid(), Body = new RegionModifyBodyDto {
                    Name = "Name"
                }
            };
            var expectedCommand = new Modify.Command {
                Id = regionDto.Id, Name = regionDto.Body.Name
            };

            // Act
            Modify.Command command = _mapper.Map <Modify.Command>(regionDto);

            // Assert
            command.Should().BeEquivalentTo(expectedCommand);
        }
Пример #5
0
        public void Should_Map()
        {
            // Arrange
            var dto = new ProjectModifyDto
            {
                Id   = Guid.NewGuid(),
                Body = new ProjectModifyBodyDto
                {
                    Title       = "Title",
                    ShortTitle  = "Short Title",
                    Description = "Description",
                    Code        = "0815ABC",
                    TypeId      = Guid.NewGuid(),
                    GenreId     = Guid.NewGuid(),
                    StartDate   = new DateTime(2022, 03, 03),
                    EndDate     = new DateTime(2022, 04, 04),
                    StateId     = Guid.NewGuid(),
                    ParentId    = Guid.NewGuid(),
                    IsCompleted = true
                }
            };
            var expectedCommand = new Modify.Command
            {
                Id          = dto.Id,
                Title       = dto.Body.Title,
                ShortTitle  = dto.Body.ShortTitle,
                Description = dto.Body.Description,
                Code        = dto.Body.Code,
                TypeId      = dto.Body.TypeId,
                GenreId     = dto.Body.GenreId,
                StartDate   = dto.Body.StartDate,
                EndDate     = dto.Body.EndDate,
                StateId     = dto.Body.StateId,
                ParentId    = dto.Body.ParentId,
                IsCompleted = dto.Body.IsCompleted
            };

            // Act
            Modify.Command command = _mapper.Map <Modify.Command>(dto);

            // Assert
            command.Should().BeEquivalentTo(expectedCommand);
        }
Пример #6
0
        public void Should_Map()
        {
            // Arrange
            Entities.Url sourceUrl   = FakeUrls.ArpaWebsite;
            Entities.Url expectedUrl = FakeUrls.ArpaWebsite;
            expectedUrl.SetProperty(nameof(Entities.Url.Href), expectedUrl.Href + "/modified");
            expectedUrl.SetProperty(nameof(Entities.Url.AnchorText), expectedUrl.AnchorText + " modified");
            var command = new Modify.Command
            {
                Id         = expectedUrl.Id,
                Href       = expectedUrl.Href,
                AnchorText = expectedUrl.AnchorText,
            };

            // Act
            Entities.Url url = _mapper.Map(command, sourceUrl);

            // Assert
            url.Should().BeEquivalentTo(expectedUrl, opt => opt.Excluding(dto => dto.UrlRoles));
        }
Пример #7
0
        public void Should_Map()
        {
            // Arrange
            var dto = new AppointmentModifyDto
            {
                Id   = Guid.NewGuid(),
                Body = new AppointmentModifyBodyDto
                {
                    InternalDetails = "Internal Details",
                    PublicDetails   = "Public Details",
                    Name            = "Name",
                    StartTime       = DateTime.Now,
                    EndTime         = DateTime.Now.AddHours(2),
                    CategoryId      = Guid.NewGuid(),
                    SalaryId        = Guid.NewGuid(),
                    SalaryPatternId = Guid.NewGuid(),
                    StatusId        = Guid.NewGuid()
                }
            };
            var expectedCommand = new Modify.Command
            {
                Id = dto.Id,
                InternalDetails = dto.Body.InternalDetails,
                PublicDetails   = dto.Body.PublicDetails,
                Name            = dto.Body.Name,
                StartTime       = dto.Body.StartTime,
                EndTime         = dto.Body.EndTime,
                CategoryId      = dto.Body.CategoryId,
                SalaryId        = dto.Body.SalaryId,
                SalaryPatternId = dto.Body.SalaryPatternId,
                StatusId        = dto.Body.StatusId
            };

            // Act
            Modify.Command command = _mapper.Map <Modify.Command>(dto);

            // Assert
            command.Should().BeEquivalentTo(expectedCommand);
        }
Пример #8
0
 public async Task <ActionResult <Unit> > Edit(Modify.Command command)
 {
     return(await _mediator.Send(command));
 }