Skip to content

Better AutoFixture support? #32

@Kralizek

Description

@Kralizek

Hi!

AutoFixture is a great library for quickly building tests by assemblying test data.

One of the paradigms they support is the usage of test parameters as a way to receive the different parts of the test.

Here is an example

public class SomeHttpService
{
    public SomeHttpService(HttpClient client) { }

    public Task DoSomethingAsync() { }
}

[TestFixture]
public class SomeHttpServiceTests
{
    [Test, MyAutoData]
    public void A_test([Frozen] FakeHttpMessageHandler handler, SomeHttpService sut)
    {
        // customize options
        handler.Options.Add(new ...);

        sut.DoSomethingAsync();

        // verify sent request
        Assert.That(handler.Options[0].RequestUri, Is.EqualTo(something)
    }
}

Basically with this pattern, there is no direct access to the constructor and the FakeHttpMessageHandler can only be customized when it gets constructed.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions