public void GivenANewCampaign_WhenSaveNewCampaign_ThenNewCampaignIsSaved()
        {
            //given
            var options = new DbContextOptionsBuilder <SwintakeContext>()
                          .UseInMemoryDatabase("swintake" + Guid.NewGuid().ToString("n"))
                          .Options;

            using (var context = new SwintakeContext(options))
            {
                var testCampaign = new CampaignBuilder()
                                   .WithId(Guid.NewGuid())
                                   .WithName("testName")
                                   .WithClient("testClient")
                                   .WithStatus(CampaignStatus.Active)
                                   .WithStartDate(DateTime.Today.AddDays(5))
                                   .WithClassStartDate(DateTime.Today.AddDays(5))
                                   .WithComment("testComment")
                                   .Build();

                IRepository <Campaign> campaignRepository = new CampaignRepository(context);

                //when
                campaignRepository.Save(testCampaign);

                //then
                var foundCampaign = context.Campaigns.SingleOrDefault(camp => camp.Id == testCampaign.Id);
                Assert.Equal(testCampaign.Name, foundCampaign.Name);
            }
        }
        public void GivenACampaign_WhenToDto_ThenReturnCampaignDtoObjectWithSameProperties()
        {
            //given
            var campaign = new CampaignBuilder()
                                .WithId(Guid.NewGuid())
                                .WithName("testName")
                                .WithClient("testClient")
                                .WithStatus(CampaignStatus.Active)
                                .WithStartDate(DateTime.Today.AddDays(5))
                                .WithClassStartDate(DateTime.Today.AddDays(5))
                                .WithComment("testComment")
                                .Build();

            var campaignMapper = new CampaignMapper();

            //when
            var newDto = campaignMapper.ToDto(campaign);

            //then
            Assert.Equal(campaign.Id.ToString(), newDto.Id);
            Assert.Equal(campaign.Name, newDto.Name);
            Assert.Equal(campaign.Client, newDto.Client);
            Assert.Equal(campaign.Status, newDto.Status);
            Assert.Equal(campaign.StartDate, newDto.StartDate);
            Assert.Equal(campaign.ClassStartDate, newDto.ClassStartDate);
            Assert.Equal(campaign.Comment, newDto.Comment);
        }
 public Campaign(CampaignBuilder campaignBuilder) : base(campaignBuilder.Id)
 {
     this.Name           = campaignBuilder.Name;
     this.Client         = campaignBuilder.Client;
     this.Status         = campaignBuilder.Status;
     this.StartDate      = campaignBuilder.StartDate;
     this.ClassStartDate = campaignBuilder.ClassStartDate;
     this.Comment        = campaignBuilder.Comment;
 }
        public async Task ReturnAllOfTheBookings()
        {
            var campaign = new CampaignBuilder().BuildAndAddToContext(DataContext);

            SetupBookingForCampaign(campaign.Id);
            SetupBookingForCampaign(campaign.Id);

            var bookings = await GetCampaignBookings(campaign.Id);

            Assert.Equal(2, bookings.Items.Count);
        }
        public async Task ReturnTheCorrectId()
        {
            var campaign = new CampaignBuilder().BuildAndAddToContext(DataContext);

            var(booking, face) = SetupBookingForCampaign(campaign.Id);

            var response = await GetCampaignBookings(campaign.Id);

            var bookingResponse = Assert.Single(response.Items);

            Assert.Equal(face.Id.ToString(), bookingResponse.FaceId);
        }
        public async Task NotReturnUnrelatedBookings()
        {
            var expectedCampaign = new CampaignBuilder().BuildAndAddToContext(DataContext);
            var otherCampaign    = new CampaignBuilder().BuildAndAddToContext(DataContext);

            var(_, expectedFace) = SetupBookingForCampaign(expectedCampaign.Id);
            SetupBookingForCampaign(otherCampaign.Id);

            var bookings = await GetCampaignBookings(expectedCampaign.Id);

            var bookingResponse = Assert.Single(bookings.Items);

            Assert.Equal(expectedFace.Id.ToString(), bookingResponse.FaceId);
        }
Exemplo n.º 7
0
        public void GivenNewJobApplicationWithExistingCampaignIdAndNonCandidateId_whenAddJobApplication_ThenNoCallToJobApplicationRepositoryAndEntityNotFoundException()
        {
            //Given
            var janneke = new CandidateBuilder()
                          .WithId(Guid.NewGuid())
                          .WithFirstName("Janneke")
                          .WithLastName("Janssens")
                          .WithEmail("*****@*****.**")
                          .WithPhoneNumber("0470000000")
                          .WithGitHubUsername("janneke")
                          .WithLinkedIn("janneke")
                          .Build();

            var testCampaign = new CampaignBuilder()
                               .WithId(Guid.NewGuid())
                               .WithName("testName")
                               .WithClient("testClient")
                               .WithStatus(CampaignStatus.Active)
                               .WithStartDate(DateTime.Today.AddDays(5))
                               .WithClassStartDate(DateTime.Today.AddDays(5))
                               .WithComment("testComment")
                               .Build();

            var newJobApplication = new JobApplicationBuilder()
                                    .WithId(Guid.NewGuid())
                                    .WithCandidateId(Guid.NewGuid())
                                    .WithCampaignId(testCampaign.Id)
                                    .WithStatus(StatusJobApplication.Active)
                                    .Build();

            _candidateService.GetCandidateById(newJobApplication.CandidateId.ToString()).Returns(ex => { throw new EntityNotFoundException("test info", "candidate", newJobApplication.CandidateId); });
            _campaignService.GetCampaignByID(newJobApplication.CampaignId.ToString()).Returns(testCampaign);

            //When
            Action act = () => _jobApplicationService.AddJobApplication(newJobApplication);

            //Then
            _jobApplicationRepository.DidNotReceive().Save(newJobApplication);
            Assert.Throws <EntityNotFoundException>(act);
        }
Exemplo n.º 8
0
        public void GivenNewJobApplicationWithExistingCampaignIdAnCandidateId_whenAddJobApplication_ThenCallToJobApplicationRepository()
        {
            //Given
            var janneke = new CandidateBuilder()
                          .WithId(Guid.NewGuid())
                          .WithFirstName("Janneke")
                          .WithLastName("Janssens")
                          .WithEmail("*****@*****.**")
                          .WithPhoneNumber("0470000000")
                          .WithGitHubUsername("janneke")
                          .WithLinkedIn("janneke")
                          .Build();

            var testCampaign = new CampaignBuilder()
                               .WithId(Guid.NewGuid())
                               .WithName("testName")
                               .WithClient("testClient")
                               .WithStatus(CampaignStatus.Active)
                               .WithStartDate(DateTime.Today.AddDays(5))
                               .WithClassStartDate(DateTime.Today.AddDays(5))
                               .WithComment("testComment")
                               .Build();

            var newJobApplication = new JobApplicationBuilder()
                                    .WithId(Guid.NewGuid())
                                    .WithCandidateId(janneke.Id)
                                    .WithCampaignId(testCampaign.Id)
                                    .WithStatus(StatusJobApplication.Active)
                                    .Build();

            _candidateService.GetCandidateById(newJobApplication.CandidateId.ToString()).Returns(janneke);
            _campaignService.GetCampaignByID(newJobApplication.CampaignId.ToString()).Returns(testCampaign);

            //When
            _jobApplicationService.AddJobApplication(newJobApplication);

            //Then
            _jobApplicationRepository.Received().Save(newJobApplication);
        }
Exemplo n.º 9
0
        public void GivenExistingJobApplication_WhenRejectJobApplication_ThenJobApplicationIsRemoved()
        {
            //Given
            var janneke = new CandidateBuilder()
                          .WithId(Guid.NewGuid())
                          .WithFirstName("Janneke")
                          .WithLastName("Janssens")
                          .WithEmail("*****@*****.**")
                          .WithPhoneNumber("0470000000")
                          .WithGitHubUsername("janneke")
                          .WithLinkedIn("janneke")
                          .Build();

            var testCampaign = new CampaignBuilder()
                               .WithId(Guid.NewGuid())
                               .WithName("testName")
                               .WithClient("testClient")
                               .WithStatus(CampaignStatus.Active)
                               .WithStartDate(DateTime.Today.AddDays(5))
                               .WithClassStartDate(DateTime.Today.AddDays(5))
                               .WithComment("testComment")
                               .Build();

            var newJobApplication = new JobApplicationBuilder()
                                    .WithId(Guid.NewGuid())
                                    .WithCandidateId(janneke.Id)
                                    .WithCampaignId(testCampaign.Id)
                                    .WithStatus(StatusJobApplication.Active)
                                    .Build();

            _jobApplicationRepository.Get(newJobApplication.Id).Returns(newJobApplication);

            //When
            var updatedJobapplication = _jobApplicationService.RejectJobApplication(newJobApplication.Id.ToString());

            //Then
            Assert.Equal(StatusJobApplication.Rejected, updatedJobapplication.Status);
        }
Exemplo n.º 10
0
        public static CampaignBuilder WithCajolingInitiation(this CampaignBuilder builder)
        {
            builder.WithInitiationStrategy <CajoleInitiationStrategy>();

            return(builder);
        }
Exemplo n.º 11
0
 public ProductBuilder WithCampaign(DateTime now, CampaignBuilder campaign)
 {
     _campaigns.Add(Tuple.Create(now, campaign.Build()));
     return(this);
 }