Exemplo n.º 1
0
    public async Task DeleteStubAsync_ShouldDeleteStub()
    {
        // Arrange
        const string stubId = "fallback";
        var          client = new HttPlaceholderClient(CreateHttpClient(mock => mock
                                                                        .When(HttpMethod.Delete, $"{BaseUrl}ph-api/stubs/{stubId}")
                                                                        .Respond(HttpStatusCode.NoContent)));

        // Act / Assert
        await client.DeleteStubAsync(stubId);
    }
Exemplo n.º 2
0
    public async Task DeleteStubAsync_ExceptionInRequest_ShouldThrowHttPlaceholderClientException()
    {
        // Arrange
        const string stubId = "fallback";
        var          client = new HttPlaceholderClient(CreateHttpClient(mock => mock
                                                                        .When(HttpMethod.Delete, $"{BaseUrl}ph-api/stubs/{stubId}")
                                                                        .Respond(HttpStatusCode.BadRequest, "text/plain", "Error occurred!")));

        // Act
        var exception =
            await Assert.ThrowsExceptionAsync <HttPlaceholderClientException>(() =>
                                                                              client.DeleteStubAsync(stubId));

        // Assert
        Assert.AreEqual("Status code '400' returned by HttPlaceholder with message 'Error occurred!'",
                        exception.Message);
    }