Author : MD TAREQ HASSAN

Points to Note

Autofixure installation

Install-Package AutoFixture

Vanilla Autofixure

var fixture = new Fixture();

var autoGeneratedText = fixture.Create<string>(); // "30a35da1-d681-441b-9db3-77ff51728b58"

// seeded
var generatedTextWithPrefix = fixture.Create("Name"); // "Name30a35da1-d681-441b-9db3-77ff51728b58"

AutoData installation

Install-Package AutoFixture.Xunit2

Using AutoData

AutoData without sut

[Theory]
[AutoData]
public void TestOne(int foo, string bar)
{

}

// both annotation togather
[Theory, AutoData]
public void TestTwo(int foo, string bar)
{

}

AutoData with sut

[Theory]
[AutoData]
public void TestOne(int foo, string bar, MyClass sut)
{

}

Inline AutoData

[Theory]
[InlineAutoData]                  // all args will be provided by autofixture
[InlineAutoData("FOO")]           // BAR & sut will be provided by autofixture
[InlineAutoData("FOO", "BAR")]    // sut will be provided bt autofixture
public void Test(string foo, string bar, MyClass sut)
{

}