public async void GetSimRun_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 simRunClient = new SimRunClient(httpService.Object); Exception exception = null; try { // Act await simRunClient.GetSimRun(It.IsAny <string>(), It.IsAny <string>()); } catch (FailedToGetResourceException e) { exception = e; } // Assert Assert.NotNull(exception); }
public async void GetSimRun_ValidSimRunIdAndProjectId_ReturnsSimRunModel() { // Arrange var simRunId = "5b06acef52e35100015f04da"; var projectId = "623be379-ed40-49f3-bdd8-416f8cd0faa6"; var httpService = new HttpService(new HttpClient()); var simRunClient = new SimRunClient( httpService ); // Act var result = await simRunClient.GetSimRun(simRunId, projectId); // Assert Assert.NotNull(result); }
public async void GetSimRun_OkStatusCode_ReturnsSimRunModel() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(SimRunModelDataMocks.MockSimRunModelListJson) }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.GetAsync(It.IsAny <string>())) .ReturnsAsync(httpResponseMessage); var simRunClient = new SimRunClient(httpService.Object); // Act var result = await simRunClient.GetSimRun(It.IsAny <string>(), It.IsAny <string>()); // Assert Assert.NotNull(result); }