-
Notifications
You must be signed in to change notification settings - Fork 3
/
IocTests.cs
78 lines (65 loc) · 2.24 KB
/
IocTests.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using FluentAssertions.Ioc.Ninject.Sample;
using FluentAssertions.Ioc.Samples.Core;
using FluentAssertions.Ioc.Samples.Interfaces;
using Ninject;
using Ninject.Modules;
using NUnit.Framework;
namespace FluentAssertions.Ioc.Ninject.SampleTests
{
[TestFixture]
public class IocTests
{
[Test]
public void Services_can_be_resolved_with_a_single_instance()
{
// Arrange
var kernel = GetKernel();
var interfaces = FindAssembly.Containing<ISampleService>().GetPublicInterfaces()
.EndingWith("Service");
// Assert
kernel.Should().Resolve(interfaces).WithSingleInstance();
}
[Test]
public void Providers_can_be_resolved_with_at_least_one_instance()
{
// Arrange
var kernel = GetKernel();
var interfaces = FindAssembly.Containing<ISomeProvider>().GetPublicInterfaces()
.EndingWith("Provider");
// Assert
kernel.Should().Resolve(interfaces).WithAtLeastOneInstance();
}
[Test]
public void SampleService_can_be_resolved_with_a_single_instance()
{
// Arrange
var kernel = GetKernel();
// Assert
kernel.Should().Resolve<ISampleService>().WithSingleInstance();
}
[Test]
public void Provider_can_be_resolved_with_at_least_one_instance()
{
// Arrange
var kernel = GetKernel();
// Assert
kernel.Should().Resolve<ISomeProvider>().WithAtLeastOneInstance();
}
[Test]
public void SampleService_resolves_to_expected_implementation()
{
// Arrange
var kernel = GetKernel();
// Assert
kernel.Should().Resolve<ISampleService>().To<SampleService>();
}
private IKernel GetKernel()
{
var modules = new INinjectModule[]
{
new SampleModule()
};
return new StandardKernel(modules);
}
}
}