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 UnmarkSimRun_OkStatusCode_NoExceptionThrown() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(SimPlanModelDataMocks.MockMarkedSimPlanModelJson) }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.PutAsync(It.IsAny <string>(), It.IsAny <SimRunMarkUpdateModel>())) .ReturnsAsync(httpResponseMessage); var simRunClient = new SimRunClient(httpService.Object); Exception exception = null; try { // Act await simRunClient.UnmarkSimRun(DependantResourceDataMocks.MockDependantResourceModel()); } catch (Exception e) { exception = e; } // Assert Assert.Null(exception); }
public async void UnmarkSimRun_InternalServerErrorStatusCode_ExceptionThrown() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent("") }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.PutAsync(It.IsAny <string>(), It.IsAny <SimRunMarkUpdateModel>())) .ReturnsAsync(httpResponseMessage); var simRunClient = new SimRunClient(httpService.Object); Exception exception = null; try { // Act await simRunClient.UnmarkSimRun(DependantResourceDataMocks.MockDependantResourceModel()); } catch (FailedToUpdateResourceException e) { exception = e; } // Assert Assert.NotNull(exception); }
public async void MarkSimRun_MarkedSimRunModel_ThrowsException() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(SimPlanModelDataMocks.MockMarkedSimPlanModelJson) }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.GetAsync(It.IsAny <string>())) .ReturnsAsync(httpResponseMessage); httpService .Setup(m => m.PutAsync(It.IsAny <string>(), It.IsAny <SimRunModel>())) .ReturnsAsync(httpResponseMessage); var simRunClient = new SimRunClient(httpService.Object); Exception exception = null; try { // Act await simRunClient.MarkSimRun(It.IsAny <string>(), It.IsAny <string>()); } catch (ResourceAlreadyMarkedException e) { exception = e; } // Assert Assert.NotNull(exception); }
public async void DeleteResource_ValidSimRunId_NoExceptionThrown() { // Arrange var projectId = "be69cb8c-45e4-4d80-8d55-419984aa2151"; var dependantResourceModel = new DependantResourceModel { ResourceType = ResourceTypeEnum.SimRun, ResourceId = "5b07ddd052e35100015f04e4" }; var httpService = new HttpService(new HttpClient()); var simRunClient = new SimRunClient(httpService); Exception exception = null; try { // Act await simRunClient.DeleteResource(dependantResourceModel, projectId); } catch (Exception e) { exception = e; } // Assert Assert.Null(exception); }
public async void UnmarkSimRun_MarkedSimRunModel_NoExceptionThrown() { // Arrange var dependantResourceModel = new DependantResourceModel( ResourceTypeEnum.SimRun, "5b07ddd052e35100015f04e4" ); var httpService = new HttpService(new HttpClient()); var simRunClient = new SimRunClient( httpService ); Exception exception = null; try { // Act await simRunClient.UnmarkSimRun(dependantResourceModel); } catch (Exception e) { exception = e; } // Assert Assert.Null(exception); }
public async void GetSimRunsForProject_ValidProjectId_ReturnsSimRunModelList() { // Arrange var projectId = "623be379-ed40-49f3-bdd8-416f8cd0faa6"; var httpService = new HttpService(new HttpClient()); var simRunClient = new SimRunClient( httpService ); // Act var result = await simRunClient.GetSimRunsForProject(projectId); // Assert Assert.NotEmpty(result); }
public async void MarkSimRun_UnmarkedSimRunModel_ReturnsDependantResourceModel() { // Arrange var simRunId = "5b06b85752e35100015f04dc"; var projectId = "73fcb3bf-bc8b-4c8b-801f-8a90d92bf9c2"; var httpService = new HttpService(new HttpClient()); var simRunClient = new SimRunClient( httpService ); // Act var result = await simRunClient.MarkSimRun(simRunId, projectId); // Assert Assert.NotNull(result); }
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 GetSimRunsForSimPlan_OkStatusCode_ReturnsSimRunModelList() { // 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.GetSimRunsForSimPlan(It.IsAny <string>(), It.IsAny <string>()); // Assert Assert.NotEmpty(result); }
public async void MarkSimRun_SimRunModel_ReturnsDependantResourceModel() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("") }; var httpService = new Mock <IHttpService>(); httpService .Setup(m => m.PutAsync(It.IsAny <string>(), It.IsAny <SimRunMarkUpdateModel>())) .ReturnsAsync(httpResponseMessage); var simRunClient = new SimRunClient(httpService.Object); // Act var result = await simRunClient.MarkSimRun(SimRunModelDataMocks.MockSimRunModel(), It.IsAny <string>()); // Assert Assert.NotNull(result); }
public async void GetSimRunsForProject_NotFoundStatusCode_ReturnsEmptyList() { // Arrange var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound, Content = new StringContent("") }; 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.GetSimRunsForProject(It.IsAny <string>()); // Assert Assert.Empty(result); }
public async void DeleteResource_OkStatusCode_NoExceptionThrown() { // Arrange var httpService = new Mock <IHttpService>(); var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("") }; httpService .Setup(m => m.GetAsync(It.IsAny <string>())) .ReturnsAsync(httpResponseMessage); httpService .Setup(m => m.DeleteAsync(It.IsAny <string>())) .ReturnsAsync(httpResponseMessage); var simRunClient = new SimRunClient( httpService.Object ); Exception exception = null; try { // Act await simRunClient.DeleteResource( DependantResourceDataMocks.MockDependantResourceModel(), It.IsAny <string>() ); } catch (Exception e) { exception = e; } // Asset Assert.Null(exception); }