-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathContainerRegistrationAssertions_Should.cs
52 lines (46 loc) · 1.39 KB
/
ContainerRegistrationAssertions_Should.cs
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
using System;
using System.Diagnostics.CodeAnalysis;
using Autofac;
using Xunit;
namespace FluentAssertions.Autofac;
// ReSharper disable InconsistentNaming
public class ContainerRegistrationAssertions_Should
{
[Fact]
public void RegisterType()
{
var sut = Configure(builder => builder.RegisterType<Dummy>()).Should().Have();
sut.Registered<Dummy>();
sut.Registered(typeof(Dummy));
}
[Fact]
public void RegisterInstance()
{
var instance = new Dummy();
var container = Configure(builder => builder.RegisterInstance(instance));
container.Should().Have().Registered(instance);
}
[Fact]
public void NotRegister()
{
var sut = Configure().Should().Have();
sut.NotRegistered<IDisposable>();
sut.NotRegistered(typeof(IDisposable));
sut.NotRegistered<IDisposable>("foo");
sut.NotRegistered("bar", typeof(IDisposable));
sut.NotRegistered<IDisposable>(42);
sut.NotRegistered(42, typeof(IDisposable));
}
private static IContainer Configure(Action<ContainerBuilder> arrange = null)
{
var builder = new ContainerBuilder();
arrange?.Invoke(builder);
return builder.Build();
}
[ExcludeFromCodeCoverage]
// ReSharper disable ClassNeverInstantiated.Local
private class Dummy : IDisposable
{
public void Dispose() { }
}
}