Injector for NUnit tests.
Currently built for Autofac, injecting your system services to test fixtures public properties and fields.
Sinjector/Sinjector.Test/SampleTest.cs
Lines 7 to 42 in cc7bffc
[SinjectorFixture] | |
[MySystem] | |
public class SampleTest | |
{ | |
public MyService Target; | |
[Test] | |
public void ShouldDoStuff() | |
{ | |
Target.DoStuff(); | |
} | |
} | |
public class MySystemAttribute : Attribute, IContainerSetup | |
{ | |
public void ContainerSetup(IContainerSetupContext context) | |
{ | |
context.AddModule(new MySystemModule()); | |
} | |
} | |
public class MySystemModule : Module | |
{ | |
protected override void Load(ContainerBuilder builder) | |
{ | |
builder.RegisterType<MyService>(); | |
} | |
} | |
public class MyService | |
{ | |
public void DoStuff() | |
{ | |
} | |
} |