Common tools for writing tests using XUnit, AutoFixture, NSubstitute and FluentAssertions.
Version Notes:
If you are using theMemberAutoNSubstituteData
attribute, ensure that bothxunit
andxunit.extensibility.core
packages are set to version 2.9.0. This is because the latest versions of xUnit are currently incompatible withMemberAutoNSubstituteData
due to an unresolved issue. Although xunit/xunit#3031 has been closed, the problem remains unresolved.
Upgrading beyond version 2.9.0 may result in test failures or unexpected behavior.
Name | Description |
---|---|
AutoNSubstituteData |
Provides auto-generated data specimens generated by AutoFixture and NSubstitute as an extension to XUnit's [Theory] attribute. |
InlineAutoNSubstituteData |
Provides a data source for a data theory, with the data coming from inline values combined with auto-generated data specimens generated by AutoFixture and NSubstitute. |
MemberAutoNSubstituteData |
Provides a data source for a data theory, with the data coming from one of the following sources and combined with auto-generated data specimens generated by AutoFixture and NSubstitute. |
Note: NSubstitute is used when the type being created is abstract, or when the
[Substitute]
is applied.
Name | Description |
---|---|
EquivalencyAssertionOptionsExtensions |
Extensions for FluentAssertions to compare dates with a precision when using .BeEquivalentTo() . |
FixtureFactory |
Static factory for creating AutoFixture Fixture instances. |
ObjectExtensions |
Extensions calling protected members on an object. |
SubstituteExtensions |
Extensions for NSubstitutes to wait for calls and get arguments of a received call. |
TaskExtensions |
Extensions for Tasks to add timeouts when awaiting. |
The default Fixture
returned by the FixtrueFactory.Create()
method is used for all the Attributes
mentioned above.
To add customizations to this, you can add the AutoRegisterAttribute
to any custom ICustomization
or ISpecimenBuilder
to have it automatically added to the Fixture.
See CancellationTokenGenerator
for an example on how to do this.