예제 #1
0
        public async Task GivenJobApplication_WhenGoingToNextStageInSelectionProcess_ThenReturnJobApplicationWithNewCurrentSelectionStep()
        {
            using (_server)
            {
                var client = await InitClient(_server);

                CreateJobApplicationDto newJobApplicationCreatedDto = await PrepareNewJobApplicationTest(client);

                var response = await CreateJobApplicationWithPost(client, newJobApplicationCreatedDto);

                response.EnsureSuccessStatusCode();
                var creatingResponseString = await response.Content.ReadAsStringAsync();

                var createdJobApplication = JsonConvert.DeserializeObject <JobApplicationDto>(creatingResponseString);

                var comment              = "testComment";
                var contentComment       = JsonConvert.SerializeObject(comment);
                var stringContentComment = new StringContent(contentComment, Encoding.UTF8, "application/json");

                var getResponse = await client.PutAsync("/api/JobApplications/nextStep/" + createdJobApplication.Id,
                                                        stringContentComment);

                var responseString = await getResponse.Content.ReadAsStringAsync();

                var foundJobApplication = JsonConvert.DeserializeObject <JobApplicationDto>(responseString);

                Assert.Single(foundJobApplication.SelectionSteps);
            }
        }
예제 #2
0
        public async Task GivenGetJobApplication_WhenPassingExistingId_ThenReturnJobApplication()
        {
            using (_server)
            {
                var client = await InitClient(_server);

                CreateJobApplicationDto newJobApplicationCreatedDto = await PrepareNewJobApplicationTest(client);

                var response = await CreateJobApplicationWithPost(client, newJobApplicationCreatedDto);

                response.EnsureSuccessStatusCode();
                var creatingResponseString = await response.Content.ReadAsStringAsync();

                var createdJobApplication = JsonConvert.DeserializeObject <JobApplicationDto>(creatingResponseString);

                var getResponse = await client.GetAsync("/api/JobApplications/" + createdJobApplication.Id);

                var responseString = await getResponse.Content.ReadAsStringAsync();

                var foundJobApplication = JsonConvert.DeserializeObject <JobApplicationDto>(responseString);

                Assert.Equal(newJobApplicationCreatedDto.CampaignId, foundJobApplication.CampaignId);
                Assert.Equal(newJobApplicationCreatedDto.CandidateId, foundJobApplication.CandidateId);
            }
        }
        public ActionResult <JobApplicationDto> CreateJobApplication([FromBody] CreateJobApplicationDto jobApplicationDto)
        {
            var newJobApplication = _jobApplicationMapper.ToDto(
                _jobApplicationService.AddJobApplication(
                    _jobApplicationMapper.ToNewDomain(jobApplicationDto)));

            return(Created($"api/jobapplications/{newJobApplication.Id}", newJobApplication));
        }
예제 #4
0
        public async Task GivenNewJobApplicationWithNotExistingCampaignIdAndExistingCandidateId_WhenCreateNewJobApplication_ThenReturnNotFound()
        {
            using (_server)
            {
                var client = await InitClient(_server);

                CreateJobApplicationDto newJobApplicationCreatedDto = await PrepareNewJobApplicationTest(client);

                newJobApplicationCreatedDto.CampaignId = Guid.NewGuid().ToString();
                var responseJobApplication = await CreateJobApplicationWithPost(client, newJobApplicationCreatedDto);

                Assert.Equal("NotFound", responseJobApplication.StatusCode.ToString());
            }
        }
        public void GivenJobApplicationDto_WhenMapTonewDomain_ThenStatusIsActiveAndIdGuidIsCreated()
        {
            //Given
            var newJobApplicationDto = new CreateJobApplicationDto(

                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString()
                );

            //When
            var newJobApplication = _jobApplicationMapper.ToNewDomain(newJobApplicationDto);

            //Then
            Assert.IsType <JobApplication>(newJobApplication);
            Assert.Equal(StatusJobApplication.Active, newJobApplication.Status);
            Assert.IsType <Guid>(newJobApplication.Id);
        }
예제 #6
0
        private async Task <CreateJobApplicationDto> PrepareNewJobApplicationTest(HttpClient client)
        {
            var newDTOCreatedCandidate = new CandidateDto()
            {
                FirstName      = "Peter",
                LastName       = "Parker",
                Email          = "*****@*****.**",
                PhoneNumber    = "0470000000",
                GitHubUsername = "******",
                LinkedIn       = "peterparker"
            };

            var contentCandidate       = JsonConvert.SerializeObject(newDTOCreatedCandidate);
            var stringContentCandidate = new StringContent(contentCandidate, Encoding.UTF8, "application/json");

            var responseCandidate = await client.PostAsync("api/Candidates", stringContentCandidate);

            var responseStringCandidate = await responseCandidate.Content.ReadAsStringAsync();

            var createdCandidate = JsonConvert.DeserializeObject <CandidateDto>(responseStringCandidate);

            var newDTOCreatedCampaign = new CreateCampaignDto()
            {
                Name           = "testCampaign",
                Client         = "testClient",
                ClassStartDate = DateTime.Today.AddDays(6),
                StartDate      = DateTime.Today.AddDays(5),
                Comment        = "testComment"
            };

            var contentCampaign       = JsonConvert.SerializeObject(newDTOCreatedCampaign);
            var stringContentCampaign = new StringContent(contentCampaign, Encoding.UTF8, "application/json");
            var responseCampaign      = await client.PostAsync("api/campaigns", stringContentCampaign);

            var responseStringCampaign = await responseCampaign.Content.ReadAsStringAsync();

            var createdCampaign = JsonConvert.DeserializeObject <CampaignDto>(responseStringCampaign);

            var newJobApplicationCreatedDto = new CreateJobApplicationDto(
                createdCandidate.Id,
                createdCampaign.Id
                );

            return(newJobApplicationCreatedDto);
        }
예제 #7
0
        public async Task GivenJobApplication_WhenGoingEndOfInSelectionProcess_ThenSelectionStepStayUnchanged()
        {
            using (_server)
            {
                var client = await InitClient(_server);

                CreateJobApplicationDto newJobApplicationCreatedDto = await PrepareNewJobApplicationTest(client);

                var response = await CreateJobApplicationWithPost(client, newJobApplicationCreatedDto);

                response.EnsureSuccessStatusCode();
                var creatingResponseString = await response.Content.ReadAsStringAsync();

                var createdJobApplication = JsonConvert.DeserializeObject <JobApplicationDto>(creatingResponseString);


                var comment              = "testComment";
                var contentComment       = JsonConvert.SerializeObject(comment);
                var stringContentComment = new StringContent(contentComment, Encoding.UTF8, "application/json");
                HttpResponseMessage getResponse;

                for (int i = 0; i < SelectionStep.CountofStepsInSelectionProcess + 1; i++)
                {
                    getResponse = await client.PutAsync("/api/JobApplications/nextStep/" + createdJobApplication.Id,
                                                        stringContentComment);
                }
                getResponse = await client.PutAsync("/api/JobApplications/nextStep/" + createdJobApplication.Id,
                                                    stringContentComment);

                var responseString = await getResponse.Content.ReadAsStringAsync();

                var foundJobApplication = JsonConvert.DeserializeObject <JobApplicationDto>(responseString);

                Assert.Equal(SelectionStep.CountofStepsInSelectionProcess, foundJobApplication.SelectionSteps.Count);
            }
        }
예제 #8
0
        private async Task <HttpResponseMessage> CreateJobApplicationWithPost(HttpClient client, CreateJobApplicationDto newJobApplicationCreatedDto)
        {
            var contentJobApplication       = JsonConvert.SerializeObject(newJobApplicationCreatedDto);
            var stringContentJobApplication = new StringContent(contentJobApplication, Encoding.UTF8, "application/json");

            return(await client.PostAsync("api/jobapplications", stringContentJobApplication));
        }