public void ViewModelGetsQuestionnaireTitleFromExternalService() { // Arrange var questionnaireController = new QuestionnaireController(StubFactory.GetHttpClientContainer()); // Act var result = (QuestionnaireViewModel)questionnaireController.Index().Result.ViewData.Model; // Assert Assert.That(result.QuestionnaireTitle, Is.EqualTo("Test questionnaire title")); }
public void ErrorResponseInApiThrows503() { // Arrange var httpResponseMessage = StubFactory.GetStatusCodeResponseMessage(HttpStatusCode.NotFound); var questionnaireController = new QuestionnaireController(StubFactory.GetHttpClientContainer(httpResponseMessage)); // Act var result = (ErrorViewModel)questionnaireController.Index().Result.ViewData.Model; // Assert Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.ServiceUnavailable)); Assert.That(result.Message, Is.EqualTo("An underlying service is now unavailable. Please try again later.")); }
public void ViewModelGetsQuestionsFromExternalService() { // Arrange var questionnaireController = new QuestionnaireController(StubFactory.GetHttpClientContainer()); // Act var result = (QuestionnaireViewModel)questionnaireController.Index().Result.ViewData.Model; // Assert Assert.That(result.QuestionsText.Count, Is.EqualTo(2)); Assert.That(result.QuestionsText[0], Is.EqualTo("Question 1")); Assert.That(result.QuestionsText[1], Is.EqualTo("Question 2")); }