public async void SimRunClient_InternalServerErrorStatusCode_ThrowsException() { // Arrange var httpService = new Mock <IHttpService>(); var httpResponseMessage = new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent("") }; httpService .Setup(m => m.GetAsync(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 (FailedToGetResourceException 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 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); }