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.
recyclarr/src/Recyclarr.TestLibrary/AutofacTestExtensions.cs

19 lines
496 B

using Autofac;
namespace Recyclarr.TestLibrary;
public static class AutofacTestExtensions
{
public static void RegisterMockFor<T>(this ContainerBuilder builder) where T : class
{
builder.RegisterInstance(Substitute.For<T>()).As<T>();
}
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>();
}
}