Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step 8 Incorrect expectation, assertion and block layout in Consumer/tests/ApiTest.cs #2

Open
hwilliams-bod opened this issue Nov 22, 2021 · 0 comments

Comments

@hwilliams-bod
Copy link

hwilliams-bod commented Nov 22, 2021

Braces are laid out incorrectly
ProductDoesNotExist - Expectation incorrect
GetProductMissingAuthHeader - Assertion incorrect

Consumer/tests/ApiTest.cs:

[Fact]
public async void ProductDoesNotExist()
{
    // Arange
    pact.UponReceiving("A valid request for a product")
            .Given("product with ID 11 does not exist")
            .WithRequest(HttpMethod.Get, "/api/products/11")
            .WithHeader("Authorization", Match.Regex("Bearer 2019-01-14T11:34:18.045Z", "Bearer \\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z"))
        .WillRespond()
            .WithStatus(HttpStatusCode.Unauthorized); 
//Should be  .WithStatus(HttpStatusCode.NotFound);

    await pact.VerifyAsync(async ctx => {
        var response = await ApiClient.GetProduct(11);
        Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
    });

    [Fact]
    public async void GetProductMissingAuthHeader()
    {
        // Arange
        pact.UponReceiving("A valid request for a product")
                .Given("No auth token is provided")
                .WithRequest(HttpMethod.Get, "/api/products/10")
            .WillRespond()
                .WithStatus(HttpStatusCode.Unauthorized);

        await pact.VerifyAsync(async ctx => {
            var response = await ApiClient.GetProduct(10);
            Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
//Should be  Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);

        });
    }
}
@hwilliams-bod hwilliams-bod changed the title Incorrect assertion and block layout in Consumer/tests/ApiTest.cs Incorrect expectation, assertion and block layout in Consumer/tests/ApiTest.cs Nov 22, 2021
@hwilliams-bod hwilliams-bod changed the title Incorrect expectation, assertion and block layout in Consumer/tests/ApiTest.cs Step 6 Incorrect expectation, assertion and block layout in Consumer/tests/ApiTest.cs Nov 28, 2021
@hwilliams-bod hwilliams-bod changed the title Step 6 Incorrect expectation, assertion and block layout in Consumer/tests/ApiTest.cs Step 8 Incorrect expectation, assertion and block layout in Consumer/tests/ApiTest.cs Nov 28, 2021
YOU54F added a commit to YOU54F/pact-workshop-dotnet that referenced this issue Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant