JasperFx / alba

Easy integration testing for ASP.NET Core applications
https://jasperfx.github.io/alba
Apache License 2.0
406 stars 39 forks source link

InvalidOperationException throw in HeaderMultiValueAssertion #128

Closed kvpt closed 1 year ago

kvpt commented 1 year ago

Hi,

Following the update to Alba 7.2.0 I have some tests that fail with an InvalidOperationException.

My test has this form

[Fact]
public async Task ShouldGetLastVersion()
{
    await Api.Scenario(s =>
    {
        s.Head
            .Url("version/last");

        s.StatusCodeShouldBe(HttpStatusCode.OK);

        s.Header(HeaderNames.ETag).ShouldHaveValues();
    });
}

The issue seems to be in the HeaderMultiValueAssertion, the excepted is empty and cause the aggregate to throw. image

Hawxy commented 1 year ago

Hey, thanks for reporting this. ShouldHaveValues() was actually never intentionally designed to work with no values passed in, so the fact this worked to begin with was a happy accident. I've added a new overload for this scenario that uses a different assertion in v7.2.1.