-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathContainerAssertions_Should.cs
43 lines (36 loc) · 1.42 KB
/
ContainerAssertions_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
using System;
using Autofac;
using NSubstitute;
using Xunit;
namespace FluentAssertions.Autofac;
// ReSharper disable InconsistentNaming
public class ContainerAssertions_Should
{
[Fact]
public void Provide_assertions()
{
var builder = new ContainerBuilder();
builder.RegisterInstance(Substitute.For<IDisposable>());
builder.RegisterType<AutoActivateService>().AutoActivate();
builder.RegisterType<AutoActivateService2>().AsImplementedInterfaces();
var container = builder.Build();
var containerShould = container.Should();
containerShould.ShouldBeOfType<ContainerAssertions>();
containerShould.Have().ShouldBeOfType<ContainerRegistrationAssertions>();
containerShould.Resolve<IDisposable>().ShouldBeOfType<ResolveAssertions>();
containerShould.Resolve(typeof(IDisposable)).ShouldBeOfType<ResolveAssertions>();
containerShould.AutoActivate<AutoActivateService>();
//containerShould.AutoActivate<AutoActivateService2>();
containerShould.Resolve<IStartable>().As<AutoActivateService2>();
containerShould.Have().Registered<AutoActivateService2>().As<IStartable>();
}
// ReSharper disable ClassNeverInstantiated.Local
private class AutoActivateService
{
}
private class AutoActivateService2 : IStartable
{
// ReSharper restore ClassNeverInstantiated.Local
public void Start() { }
}
}