-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTypeScanningAssertions_Should.cs
More file actions
55 lines (48 loc) · 1.4 KB
/
TypeScanningAssertions_Should.cs
File metadata and controls
55 lines (48 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Autofac;
using Xunit;
namespace FluentAssertions.Autofac;
// ReSharper disable InconsistentNaming
public class TypeScanningAssertions_Should
{
[Fact]
public void Support_type_scanning()
{
var builder = new ContainerBuilder();
builder.RegisterAssemblyTypes(typeof(IDummy).Assembly)
.Where(t => t.IsAssignableTo<IDummy>())
.Except<Dummy3>()
.AsSelf()
.AsImplementedInterfaces()
.As<IDummy>()
.As(t => t.GetInterfaces()[0]);
var container = builder.Build();
var types =
container.Should().RegisterAssemblyTypes(typeof(IDummy).Assembly)
.Where(t => t.IsAssignableTo<IDummy>())
.Except<Dummy3>()
.AsSelf()
.AsImplementedInterfaces()
.As<IDummy>()
.As(t => t.GetInterfaces()[0])
.Types;
container.Should().RegisterTypes(types)
.AsSelf()
.AsImplementedInterfaces()
.As<IDummy>()
.As(t => t.GetInterfaces()[0]);
} // ReSharper disable ClassNeverInstantiated.Local
private interface IDummy
{
}
// ReSharper disable UnusedType.Local
private class Dummy1 : IDummy
{
}
private class Dummy2 : IDummy
{
}
// ReSharper restore UnusedType.Local
private class Dummy3 : IDummy
{
}
}