Skip to content

Commit d432f6a

Browse files
committed
Rename ResolveInterfaces methods so it's clear they can be used with types too
1 parent 836bc45 commit d432f6a

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

src/FluentAssertions.Ioc.Ninject.SampleTests/IocTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void Services_can_be_resolved_with_a_single_instance()
2323
.EndingWith("Service");
2424

2525
// Assert
26-
kernel.Should().ResolveInterfaces(interfaces).WithSingleInstance();
26+
kernel.Should().Resolve(interfaces).WithSingleInstance();
2727
}
2828

2929
[Test]
@@ -35,7 +35,7 @@ public void Providers_can_be_resolved_with_at_least_one_instance()
3535
.EndingWith("Provider");
3636

3737
// Assert
38-
kernel.Should().ResolveInterfaces(interfaces).WithAtLeastOneInstance();
38+
kernel.Should().Resolve(interfaces).WithAtLeastOneInstance();
3939
}
4040

4141
private IKernel GetKernel()

src/FluentAssertions.Ioc.Ninject.Tests/KernelAssertionTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void Should_succeed_when_asserting_interfaces_can_be_resolved_with_a_sing
1919
.EndingWith("Service");
2020

2121
// Act
22-
Action act = () => kernel.Should().ResolveInterfaces(interfaces).WithSingleInstance();
22+
Action act = () => kernel.Should().Resolve(interfaces).WithSingleInstance();
2323

2424
// Assert
2525
act.ShouldNotThrow<AssertionException>();
@@ -34,7 +34,7 @@ public void Should_fail_when_asserting_interfaces_can_be_resolved_with_a_single_
3434
.EndingWith("Factory");
3535

3636
// Act
37-
Action act = () => kernel.Should().ResolveInterfaces(interfaces).WithSingleInstance();
37+
Action act = () => kernel.Should().Resolve(interfaces).WithSingleInstance();
3838

3939
// Assert
4040
act.ShouldThrow<AssertionException>();
@@ -47,7 +47,7 @@ public void Should_succeed_when_asserting_an_interface_can_be_resolved_with_a_si
4747
var kernel = GetKernel();
4848

4949
// Act
50-
Action act = () => kernel.Should().ResolveInterface<ISampleService>().WithSingleInstance();
50+
Action act = () => kernel.Should().Resolve<ISampleService>().WithSingleInstance();
5151

5252
// Assert
5353
act.ShouldNotThrow<AssertionException>();
@@ -60,7 +60,7 @@ public void Should_fail_when_asserting_an_interface_can_be_resolved_with_a_singl
6060
var kernel = GetKernel();
6161

6262
// Act
63-
Action act = () => kernel.Should().ResolveInterface<ISomeFactory>().WithSingleInstance();
63+
Action act = () => kernel.Should().Resolve<ISomeFactory>().WithSingleInstance();
6464

6565
// Assert
6666
act.ShouldThrow<AssertionException>();
@@ -75,7 +75,7 @@ public void Should_succeed_when_asserting_interfaces_can_be_resolved_with_at_lea
7575
.EndingWith("Provider");
7676

7777
// Act
78-
Action act = () => kernel.Should().ResolveInterfaces(interfaces).WithAtLeastOneInstance();
78+
Action act = () => kernel.Should().Resolve(interfaces).WithAtLeastOneInstance();
7979

8080
// Assert
8181
act.ShouldNotThrow<AssertionException>();
@@ -90,7 +90,7 @@ public void Should_fail_when_asserting_interfaces_can_be_resolved_with_at_least_
9090
.EndingWith("Factory");
9191

9292
// Act
93-
Action act = () => kernel.Should().ResolveInterfaces(interfaces).WithAtLeastOneInstance();
93+
Action act = () => kernel.Should().Resolve(interfaces).WithAtLeastOneInstance();
9494

9595
// Assert
9696
act.ShouldThrow<AssertionException>();
@@ -104,7 +104,7 @@ public void Should_succeed_when_asserting_interfaces_can_be_resolved_when_implem
104104
var interfaces = new [] { typeof (IFooService) };
105105

106106
// Act
107-
Action act = () => kernel.Should().ResolveInterfaces(interfaces).WithSingleInstance();
107+
Action act = () => kernel.Should().Resolve(interfaces).WithSingleInstance();
108108

109109
// Assert
110110
act.ShouldNotThrow<AssertionException>();
@@ -120,7 +120,7 @@ public void Should_fail_when_asserting_interfaces_can_be_resolved_when_implement
120120
kernel.Unbind<ISampleRepository>();
121121

122122
// Act
123-
Action act = () => kernel.Should().ResolveInterfaces(interfaces).WithSingleInstance();
123+
Action act = () => kernel.Should().Resolve(interfaces).WithSingleInstance();
124124

125125
// Assert
126126
act.ShouldThrow<AssertionException>();

src/FluentAssertions.Ioc.Ninject/KernelAssertions.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,40 @@ protected internal KernelAssertions(IKernel kernel)
2323
public IKernel Subject { get; private set; }
2424

2525
/// <summary>
26-
/// Gets the interfaces which trying to be resolved.
26+
/// Gets the types to be resolved.
2727
/// </summary>
28-
private IEnumerable<Type> Interfaces { get; set; }
28+
private IEnumerable<Type> Types { get; set; }
2929

3030
/// <summary>
31-
/// Specifies the interfaces to try resolving from the kernel.
31+
/// Specifies the types to try resolving from the kernel.
3232
/// </summary>
33-
/// <param name="interfaces">The interfaces to resolve.</param>
34-
public KernelAssertions ResolveInterfaces(IEnumerable<Type> interfaces)
33+
/// <param name="types">The types to resolve.</param>
34+
public KernelAssertions Resolve(IEnumerable<Type> types)
3535
{
36-
Interfaces = interfaces;
36+
Types = types;
3737
return this;
3838
}
3939

4040
/// <summary>
41-
/// Specifies the interface to try resolving from the kernel.
41+
/// Specifies the type to try resolving from the kernel.
4242
/// </summary>
43-
/// <typeparam name="TInterface">The interface to resolve.</typeparam>
43+
/// <typeparam name="T">The type to resolve.</typeparam>
4444
/// <returns></returns>
45-
public KernelAssertions ResolveInterface<TInterface>()
45+
public KernelAssertions Resolve<T>()
4646
{
47-
Interfaces = new List<Type>() { typeof(TInterface) };
47+
Types = new List<Type>() { typeof(T) };
4848
return this;
4949
}
5050

5151
/// <summary>
52-
/// Asserts that the selected interface(s) can be resolved with a single instance.
52+
/// Asserts that the selected type(s) can be resolved with a single instance.
5353
/// </summary>
5454
public void WithSingleInstance()
5555
{
5656
var failed = new List<ActivationError>();
5757

58-
// Try to activate each interface in the list
59-
foreach (var type in Interfaces)
58+
// Try to activate each type in the list
59+
foreach (var type in Types)
6060
{
6161
try
6262
{
@@ -82,7 +82,7 @@ public void WithAtLeastOneInstance()
8282
var failed = new List<ActivationError>();
8383

8484
// Try to activate each interface in the list
85-
foreach (var type in Interfaces)
85+
foreach (var type in Types)
8686
{
8787
try
8888
{
@@ -107,7 +107,7 @@ private string BuildFailureMessage(List<ActivationError> failed)
107107
{
108108
// Build the failure message
109109
var builder = new StringBuilder();
110-
builder.AppendLine("The following interfaces could not be resolved:").AppendLine();
110+
builder.AppendLine("The following types could not be resolved:").AppendLine();
111111

112112
foreach (var error in failed)
113113
builder.AppendFormat(" - {0}", error.Type.FullName).AppendLine();

0 commit comments

Comments
 (0)