public void ThenAllTheAnswersShouldBeMatch() { var reponses = _scenarioContext.Get <IEnumerable <SuitabilityResponse> >("Responses"); foreach (var expectedResponse in reponses) { var displayedAnswer = GetMethods.GetText(By.CssSelector($"#{expectedResponse.QuestionKey} strong"), _browserContext); if (expectedResponse.Answer == AnswerType.NotSure) { displayedAnswer.Should().Be("I'm not sure"); } else { displayedAnswer.Should().Be(expectedResponse.Answer.ToString()); } if (!string.IsNullOrEmpty(expectedResponse.Details?.Trim())) { var displayedNotes = GetMethods.GetText(By.CssSelector($"#{expectedResponse.QuestionKey}_Notes span"), _browserContext); displayedNotes.Should().Be(expectedResponse.Details.ToString()); } } //Verify the expected data by comparing them against database var request = _testContext.Get($"persons/username/{_testContext.TestUserSecrets.Representative}/suitability-answers"); var response = _testContext.Client().Execute(request); var model = ApiRequestHelper.DeserialiseSnakeCaseJsonToResponse <List <PersonSuitabilityAnswerResponse> >(response.Content); var answers = model.First(h => h.Hearing_id.ToString() == _testContext.HearingId).Answers; foreach (var expectedResponse in reponses) { var answer = answers.Single(a => a.Key == expectedResponse.QuestionKey); switch (expectedResponse.Answer) { case AnswerType.Yes: answer.Answer.Should().Be(answer.Key == RepresentativeQuestionKeys.AboutYourComputer ? "Yes" : "true"); break; case AnswerType.No: answer.Answer.Should().Be(answer.Key == RepresentativeQuestionKeys.AboutYourComputer ? "Yes" : "false"); break; case AnswerType.NotSure: answer.Answer.Should().Be("Not sure"); break; } if (!string.IsNullOrEmpty(expectedResponse.Details?.Trim())) { answer.Extended_answer.Should().Be(expectedResponse.Details.Trim().ToString()); } } }
private string UseMyCameraAndMicrophoneAccordion() { SetMethods.ClickElement(UseMyCameraAndMicrophone, BrowserContext); return(GetMethods.GetText(UseMyCameraAndMicrophone, BrowserContext)); }