https://github.com/atc-net/atc-test
A common library for writing tests using XUnit, AutoFixture, NSubstitute and FluentAssertions.
https://github.com/atc-net/atc-test
autofixture fluentassertions nsubstitute test xunit
Last synced: 5 months ago
JSON representation
A common library for writing tests using XUnit, AutoFixture, NSubstitute and FluentAssertions.
- Host: GitHub
- URL: https://github.com/atc-net/atc-test
- Owner: atc-net
- License: mit
- Created: 2021-01-17T12:16:40.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-15T19:19:28.000Z (8 months ago)
- Last Synced: 2024-09-16T07:10:10.755Z (8 months ago)
- Topics: autofixture, fluentassertions, nsubstitute, test, xunit
- Language: C#
- Homepage: https://atc-net.github.io/repository/atc-test
- Size: 308 KB
- Stars: 0
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/atc.test)
# ATC Test
Common tools for writing tests using XUnit, AutoFixture, NSubstitute and FluentAssertions.
## Test Attributes
| 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.
## Test Helpers
| 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. |## Extensibility
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`](src/Atc.Test/Customizations/Generators/CancellationTokenGenerator.cs) for an example on how to do this.
## How to contribute
[Contribution Guidelines](https://atc-net.github.io/introduction/about-atc#how-to-contribute)
[Coding Guidelines](https://atc-net.github.io/introduction/about-atc#coding-guidelines)