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.
20 lines
507 B
20 lines
507 B
using System.Reflection;
|
|
using Autofac;
|
|
using AutoFixture.Kernel;
|
|
|
|
namespace Recyclarr.TestLibrary.AutoFixture;
|
|
|
|
public class AutofacSpecimenBuilder(ILifetimeScope container) : ISpecimenBuilder
|
|
{
|
|
public object Create(object request, ISpecimenContext context)
|
|
{
|
|
if (request is not ParameterInfo paramInfo)
|
|
{
|
|
return new NoSpecimen();
|
|
}
|
|
|
|
var instance = container.ResolveOptional(paramInfo.ParameterType);
|
|
return instance ?? new NoSpecimen();
|
|
}
|
|
}
|