You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
504 B
19 lines
504 B
2 years ago
|
using Autofac;
|
||
|
|
||
2 years ago
|
namespace Recyclarr.TestLibrary.Autofac;
|
||
2 years ago
|
|
||
|
public static class AutofacTestExtensions
|
||
|
{
|
||
|
public static void RegisterMockFor<T>(this ContainerBuilder builder) where T : class
|
||
|
{
|
||
|
builder.RegisterInstance(Substitute.For<T>()).As<T>();
|
||
|
}
|
||
2 years ago
|
|
||
|
public static void RegisterMockFor<T>(this ContainerBuilder builder, Action<T> mockSetup) where T : class
|
||
|
{
|
||
|
var mock = Substitute.For<T>();
|
||
|
mockSetup(mock);
|
||
|
builder.RegisterInstance(mock).As<T>();
|
||
|
}
|
||
2 years ago
|
}
|