public async void GetScenario_InternalServerErrorStatusCode_ThrowsException() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent("") }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.GetAsync(It.IsAny <string>())) .ReturnsAsync(httpResponseMessage); var scenarioClient = new ScenarioClient(httpService.Object); Exception exception = null; try { // Act await scenarioClient.GetScenario(It.IsAny <string>()); } catch (FailedToGetResourceException e) { exception = e; } // Assert Assert.NotNull(exception); }
public async void GetScenario_ValidScenarioId_ReturnsScenarioModel() { // Assert var scenarioId = "6c40eb45-1e21-435e-81c8-895e55c6c5d8"; var httpService = new HttpService(new HttpClient()); var scenarioClient = new ScenarioClient( httpService ); // Act var result = await scenarioClient.GetScenario(scenarioId); // Assert Assert.NotNull(result); }
public async void GetScenario_OkStatusCode_ReturnsScenarioModel() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(ScenarioModelDataMocks.MockMarkedScenarioModelJson) }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.GetAsync(It.IsAny <string>())) .ReturnsAsync(httpResponseMessage); var scenarioClient = new ScenarioClient(httpService.Object); // Act var result = await scenarioClient.GetScenario(It.IsAny <string>()); // Assert Assert.NotNull(result); }