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/Trash.Tests/CompositionRootTest.cs

41 lines
1.1 KiB

using System;
using System.Collections;
using System.Linq;
using System.Reflection;
using Autofac;
using CliFx;
using NUnit.Framework;
namespace Trash.Tests
{
[TestFixture]
[Parallelizable(ParallelScope.All)]
public class CompositionRootTest
{
private class ConcreteTypeEnumerator<T> : IEnumerable
{
private readonly Assembly _asm;
public ConcreteTypeEnumerator()
{
_asm = Assembly.GetAssembly(typeof(CompositionRoot)) ?? throw new NullReferenceException();
}
public IEnumerator GetEnumerator()
{
return _asm.DefinedTypes
.Where(t => t.GetInterfaces().Contains(typeof(ICommand)) && !t.IsAbstract)
.GetEnumerator();
}
}
[TestCaseSource(typeof(ConcreteTypeEnumerator<ICommand>))]
public void Resolve_ICommandConcreteClasses(Type concreteCmd)
{
var builder = new ContainerBuilder();
var container = CompositionRoot.Setup(builder);
container.Resolve(concreteCmd);
}
}
}