Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 934 Bytes

README.md

File metadata and controls

38 lines (27 loc) · 934 Bytes

Testing.Autofac

Small testing library for autofac modules

.github/workflows/verify.yml

Nuget

Testing.Autofac.NSubstitute

Usage

  1. Create TestContainerBuilder
  2. Register autofac modules
  3. Register mocks (NSubstitute or Moq)
  4. Resolve test services

Usage example (NSubstitute)

[TestMethod]
public void ExampleTest()
{
    // arrange
    new TestContainerBuilder()
        .Module<TestModule>()
        .Mock(out IBar bar)
        .Resolve(out IFoo underTest);

    bar.Value().Returns(2);

    // act
    var actual = underTest.Add(1);

    // assert
    Assert.AreEqual(3, actual);
}