https://github.com/romfos/testing.autofac
Testing library for autofac modules
https://github.com/romfos/testing.autofac
autofac moq nsubstitute testing unit-test
Last synced: 7 months ago
JSON representation
Testing library for autofac modules
- Host: GitHub
- URL: https://github.com/romfos/testing.autofac
- Owner: Romfos
- License: mit
- Created: 2022-11-03T15:15:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-08T10:19:44.000Z (8 months ago)
- Last Synced: 2025-02-08T11:24:47.338Z (8 months ago)
- Topics: autofac, moq, nsubstitute, testing, unit-test
- Language: C#
- Homepage:
- Size: 92.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Testing.Autofac
Small testing library for autofac modules
[](https://github.com/Romfos/Testing.Autofac/actions/workflows/verify.yml)
# Nuget
[](https://www.nuget.org/packages/Testing.Autofac.NSubstitute)
# Usage
1. Create TestContainerBuilder
2. Register autofac modules
3. Register mocks (NSubstitute or Moq)
4. Resolve test services# Usage example (NSubstitute)
```csharp
[TestMethod]
public void ExampleTest()
{
// arrange
new TestContainerBuilder()
.Module()
.Mock(out IBar bar)
.Resolve(out IFoo underTest);bar.Value().Returns(2);
// act
var actual = underTest.Add(1);// assert
Assert.AreEqual(3, actual);
}
```