public async Task DeleteRouteWithGuid_ReturnsTrue_WhenStatusCodeIs202() { var fakeAppGuid = "my fake guid"; string expectedPath = _fakeCfApiAddress + CfApiClient.DeleteRoutesPath + $"/{fakeAppGuid}"; MockedRequest cfDeleteRouteRequest = _mockHttp.Expect(expectedPath) .Respond(HttpStatusCode.Accepted); _sut = new CfApiClient(_mockUaaClient.Object, _mockHttp.ToHttpClient()); Exception resultException = null; bool routeWasDeleted = false; try { routeWasDeleted = await _sut.DeleteRouteWithGuid(_fakeCfApiAddress, _fakeAccessToken, fakeAppGuid); } catch (Exception e) { resultException = e; } Assert.AreEqual(1, _mockHttp.GetMatchCount(cfDeleteRouteRequest)); Assert.IsNull(resultException); Assert.IsTrue(routeWasDeleted); }
public async Task DeleteRouteWithGuid_ThrowsException_WhenStatusCodeIsNot202() { Exception expectedException = null; var fakeAppGuid = "my fake guid"; string expectedPath = _fakeCfApiAddress + CfApiClient.DeleteRoutesPath + $"/{fakeAppGuid}"; MockedRequest cfDeleteRouteRequest = _mockHttp.Expect(expectedPath) .Respond(HttpStatusCode.BadRequest); _sut = new CfApiClient(_mockUaaClient.Object, _mockHttp.ToHttpClient()); try { await _sut.DeleteRouteWithGuid(_fakeCfApiAddress, _fakeAccessToken, fakeAppGuid); } catch (Exception e) { expectedException = e; } Assert.AreEqual(1, _mockHttp.GetMatchCount(cfDeleteRouteRequest)); Assert.IsNotNull(expectedException); }