Пример #1
0
        public async Task ShouldBeAbleToGetAQuestion()
        {
            var dbQuestion = await Arranger.CreateQuestion();

            var responseQuestionDto = await ApiClient.GetQuestion(dbQuestion.Id)
                                      .AwaitGetSuccessfulResponse <QuestionDto>();

            responseQuestionDto.ToLikeness(true).ShouldEqual(Mapper.Map <QuestionDto>(dbQuestion));
        }
Пример #2
0
        public async Task ShouldBeAbleToGetCandidate()
        {
            var dbCandidate = await Arranger.CreateCandidate();

            var responseCandidateDto = await ApiClient.GetCandidate(dbCandidate.Id)
                                       .AwaitGetSuccessfulResponse <CandidateDto>();

            responseCandidateDto.ToLikeness(true).ShouldEqual(Mapper.Map <CandidateDto>(dbCandidate));
        }
        public async Task ShouldBeAbleToGetAllInterviewTemplates()
        {
            var dbInterviewTemplates = await Arranger.CreateInterviewTemplates();

            var responseInteviewTemplateDtos = await ApiClient.GetInterviewTemplates()
                                               .AwaitGetSuccessfulResponse <IEnumerable <InterviewTemplateDto> >();

            responseInteviewTemplateDtos
            .CompareCollectionsUsingLikeness(
                Mapper.Map <IEnumerable <InterviewTemplateDto> >(dbInterviewTemplates));
        }
Пример #4
0
        public async Task ShouldBeAbleToGetAllCandidates()
        {
            var dbCandidates = await Arranger.CreateCandidates();

            var responseCandidateDtos = await ApiClient.GetAllCandidates()
                                        .AwaitGetSuccessfulResponse <IEnumerable <CandidateDto> >();

            var responseCandidates = Mapper.Map <IEnumerable <Candidate> >(responseCandidateDtos);

            responseCandidates = responseCandidates.Where(rc => dbCandidates.Any(dc => dc.Id == rc.Id));

            Assert.IsTrue(responseCandidates.CompareCollectionsUsingLikeness(dbCandidates));
        }
Пример #5
0
        public async Task ShouldBeAbleToCreateInterviewFromTemplate()
        {
            var dbInterviewTemplate = await Arranger.CreateInterviewTemplate();

            var requestInterview = Stubber.StubInterviewDto();

            var responseInterview = await ApiClient.PostInterview(requestInterview, dbInterviewTemplate.Id)
                                    .AwaitGetSuccessfulResponse <InterviewDto>();

            var dbInterviewTemplateDto = Mapper.Map <IEnumerable <QuestionDto> >(dbInterviewTemplate.Questions);

            Assert.IsTrue(responseInterview.Questions.CompareCollectionsUsingLikeness(dbInterviewTemplateDto));
        }
Пример #6
0
        public async Task ShouldBeAbleToGetAllQuestions()
        {
            var dbQuestions = await Arranger.CreateQuestions();

            var responseQuestionDtos = await ApiClient.GetAllQuestions()
                                       .AwaitGetSuccessfulResponse <IEnumerable <QuestionDto> >();

            var responseQuestions = Mapper.Map <IEnumerable <Question> >(responseQuestionDtos);

            responseQuestions = responseQuestions.Where(rq => dbQuestions.Any(dq => dq.Id == rq.Id));

            Assert.IsTrue(responseQuestions.CompareCollectionsUsingLikeness(dbQuestions));
        }
        public async Task ShouldBeAbleToGetAnInterviewTemplate()
        {
            var dbInterviewTemplate = await Arranger.CreateInterviewTemplate();

            var responseInterviewTemplate = await ApiClient.GetInterviewTemplate(dbInterviewTemplate.Id)
                                            .AwaitGetSuccessfulResponse <InterviewTemplateDto>();

            var dbInterviewTemplateDto = Mapper.Map <InterviewTemplateDto>(dbInterviewTemplate);

            responseInterviewTemplate
            .ToLikeness(true)
            .WithCollectionSequenceEquals(o => o.QuestionIds)
            .ShouldEqual(dbInterviewTemplateDto);
        }
Пример #8
0
        public async Task ShouldBeABleToUpdateQuestion()
        {
            var questionDto = Mapper.Map <QuestionDto>(await Arranger.CreateQuestion());

            var questionPatchRequest = Stubber.StubQuestionPatchRequest();

            questionPatchRequest.ApplyTo(questionDto);

            await ApiClient.PatchQuestion(questionDto.Id, questionPatchRequest);

            var updatedQuestionDto = Mapper.Map <QuestionDto>(await Arranger.GetQuestion(questionDto.Id));

            questionDto.ToLikeness(true).ShouldEqual(updatedQuestionDto);
        }
Пример #9
0
        public async Task ShouldBeAbleToGetAllInterviews()
        {
            var dbInterviews = await Arranger.CreateInterviews();

            var responseInterviewDtos = await ApiClient.GetAllInterviews()
                                        .AwaitGetSuccessfulResponse <IEnumerable <InterviewDto> >();

            responseInterviewDtos = responseInterviewDtos.Where(i => dbInterviews.Any(di => di.Id == i.Id));

            Assert.IsTrue(responseInterviewDtos.CompareCollectionsUsingLikeness(
                              Mapper.Map <IEnumerable <InterviewDto> >(dbInterviews),
                              i => i
                              .WithInnerLikeness(o => o.Candidate, o => o.Candidate)
                              .Without(o => o.Questions)));
        }
Пример #10
0
        public async Task ShouldBeAbleToUpdateCandidate()
        {
            var candidateDto = Mapper.Map <CandidateDto>(await Arranger.CreateCandidate());

            var patchRequest = Stubber.StubCandidatePatchRequest();

            patchRequest.ApplyTo(candidateDto);

            (await ApiClient.PatchCandidate(candidateDto.Id, patchRequest))
            .EnsureSuccessStatusCode();

            var updatedCandidateDto = Mapper.Map <CandidateDto>(await Arranger.GetCandidate(candidateDto.Id));

            candidateDto.ToLikeness(true)
            .ShouldEqual(updatedCandidateDto);
        }
Пример #11
0
        public async Task ShouldBeAbleToCreateInterviewWithCandidate()
        {
            var requestInterviewDto = Stubber.StubInterviewDto();

            var dbCandidate = await Arranger.CreateCandidate();

            requestInterviewDto.Candidate = Mapper.Map <CandidateDto>(dbCandidate);

            var responseInterviewDto = await ApiClient.PostInterview(requestInterviewDto, candidateId : dbCandidate.Id)
                                       .AwaitGetSuccessfulResponse <InterviewDto>();

            responseInterviewDto
            .ToLikeness()
            .WithInnerLikeness(o => o.Candidate, o => o.Candidate)
            .ShouldEqual(requestInterviewDto);
        }
        public async Task ShouldBeAbleToCreateAnInterviewTemplateWithQuestions()
        {
            var requestInterviewTemplate = Stubber.StubInterviewTemplateDto();

            var questions = await Arranger.CreateQuestions();

            requestInterviewTemplate.QuestionIds = questions.Select(q => q.Id);

            var responseInterviewTemplate = await ApiClient.PostInterviewTemplate(requestInterviewTemplate)
                                            .AwaitGetSuccessfulResponse <InterviewTemplateDto>();

            responseInterviewTemplate
            .ToLikeness()
            .WithCollectionSequenceEquals(o => o.QuestionIds)
            .ShouldEqual(requestInterviewTemplate);
        }
Пример #13
0
        public async Task ShouldBeAbleToGetAnInterview()
        {
            var dbInterview = await Arranger.CreateInterview();

            var responseInterviewDto = await ApiClient.GetInterview(dbInterview.Id)
                                       .AwaitGetSuccessfulResponse <InterviewDto>();

            var dbInterviewDto = Mapper.Map <InterviewDto>(dbInterview);

            responseInterviewDto
            .ToLikeness(true)
            .WithInnerLikeness(o => o.Candidate, o => o.Candidate)
            .WithCollectionInnerLikeness(
                o => o.Questions,
                o => o.Questions)
            .ShouldEqual(dbInterviewDto);
        }
        public async Task ShouldBeAbleToPatchAnInterviewTemplate()
        {
            var interviewTemplateDto = Mapper.Map <InterviewTemplateDto>(await Arranger.CreateInterviewTemplate());

            var patchRequest = Stubber.StubInterviewTemplatePatchRequest();

            patchRequest.ApplyTo(interviewTemplateDto);

            (await ApiClient.PatchInterviewTemplate(interviewTemplateDto.Id, patchRequest))
            .EnsureSuccessStatusCode();

            var updatedInterviewTemplateDto = Mapper.Map <InterviewTemplateDto>(
                await Arranger.GetInterviewTemplate(interviewTemplateDto.Id));

            interviewTemplateDto
            .ToLikeness()
            .Without(o => o.QuestionIds)
            .ShouldEqual(updatedInterviewTemplateDto);
        }
Пример #15
0
        public void Setup()
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile("appSettings.json");

            var configuration = builder.Build();

            ServiceProvider = new ServiceCollection()
                              .AddOptions()
                              .Configure <AppSettings>(configuration)
                              .AddSingleton <IQuestionRepository, QuestionRepository>()
                              .AddSingleton <IInterviewRepository, InterviewRepository>()
                              .AddSingleton <IInterviewTemplateRepository, InterviewTemplateRepository>()
                              .AddSingleton <ICandidateRepository, CandidateRepository>()
                              .AddSingleton <IMapper>(new Mapper(new MapperConfiguration(c => c.AddProfile(new MappingProfile()))))
                              .AddSingleton <Arranger, Arranger>()
                              .AddSingleton <Stubber, Stubber>()
                              .AddSingleton <ApiClient, ApiClient>()
                              .BuildServiceProvider();

            var appSettings = ServiceProvider.GetService <IOptions <AppSettings> >().Value;

            HttpClient             = new HttpClient();
            HttpClient.BaseAddress = new Uri(appSettings.ApiUri);

            Arranger  = ServiceProvider.GetService <Arranger>();
            Stubber   = ServiceProvider.GetService <Stubber>();
            ApiClient = ServiceProvider.GetService <ApiClient>();

            _Fixture = new Fixture();

            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <MappingProfile>();
            });

            Mapper = config.CreateMapper();
        }