-
-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
Milestone
Description
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.