Skip to content

Testing library for autofac modules

License

Notifications You must be signed in to change notification settings

Romfos/Testing.Autofac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
}