test: introduce AutoFixture library and support code

pull/47/head
Robert Dailey 3 years ago
parent d8eac2e381
commit 6820e785d9

@ -35,6 +35,9 @@
</ItemGroup>
<ItemGroup Condition="$(ProjectName.EndsWith('.Tests'))">
<PackageReference Include="AutoFixture" />
<PackageReference Include="AutoFixture.AutoNSubstitute" />
<PackageReference Include="AutoFixture.NUnit3" />
<PackageReference Include="AutofacContrib.NSubstitute" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="FluentAssertions.Json" />

@ -1,5 +1,8 @@
<Project>
<ItemGroup>
<PackageReference Update="AutoFixture" Version="4.*" />
<PackageReference Update="AutoFixture.AutoNSubstitute" Version="4.*" />
<PackageReference Update="AutoFixture.NUnit3" Version="4.*" />
<PackageReference Update="AutoMapper" Version="10.*" />
<PackageReference Update="Autofac" Version="6.*" />
<PackageReference Update="Autofac.Extensions.DependencyInjection" Version="7.*" />

@ -0,0 +1,11 @@
using AutoFixture.NUnit3;
namespace TestLibrary.AutoFixture;
public class AutoMockDataAttribute : AutoDataAttribute
{
public AutoMockDataAttribute()
: base(NSubstituteFixture.Create)
{
}
}

@ -0,0 +1,14 @@
using System.Diagnostics.CodeAnalysis;
using AutoFixture.NUnit3;
namespace TestLibrary.AutoFixture;
public class InlineAutoMockDataAttribute : InlineAutoDataAttribute
{
[SuppressMessage("Design", "CA1019", MessageId = "Define accessors for attribute arguments",
Justification = "The parameter is forwarded to the base class and not used directly")]
public InlineAutoMockDataAttribute(params object[] parameters)
: base(NSubstituteFixture.Create, parameters)
{
}
}

@ -0,0 +1,22 @@
using AutoFixture;
using AutoFixture.AutoNSubstitute;
namespace TestLibrary.AutoFixture;
public static class NSubstituteFixture
{
public static Fixture Create()
{
var fixture = new Fixture()
{
OmitAutoProperties = true
};
fixture.Customize(new AutoNSubstituteCustomization
{
ConfigureMembers = true
});
return fixture;
}
}

@ -2,10 +2,13 @@
<PropertyGroup>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" />
<PackageReference Include="AutoFixture" />
<PackageReference Include="AutoFixture.AutoNSubstitute" />
<PackageReference Include="AutoFixture.NUnit3" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="FluentAssertions.Json" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="NUnit" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />

Loading…
Cancel
Save