Skip to content

Commit f40b3c2

Browse files
committed
Merge pull request #4 from duncanworthy/master
NullReferenceException in SingleTypeKernelAssertions
2 parents 35f26a1 + 71cd6c8 commit f40b3c2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void Should_succeed_when_asserting_interfaces_can_be_resolved_with_a_sing
2323
Action act = () => kernel.Should().Resolve(interfaces).WithSingleInstance();
2424

2525
// Assert
26-
act.ShouldNotThrow<AssertionException>();
26+
act.ShouldNotThrow();
2727
}
2828

2929
[Test]
@@ -51,7 +51,7 @@ public void Should_succeed_when_asserting_an_interface_can_be_resolved_with_a_si
5151
Action act = () => kernel.Should().Resolve<ISampleService>().WithSingleInstance();
5252

5353
// Assert
54-
act.ShouldNotThrow<AssertionException>();
54+
act.ShouldNotThrow();
5555
}
5656

5757
[Test]
@@ -77,7 +77,7 @@ public void Should_succeed_when_asserting_interface_can_be_resolved_with_at_leas
7777
Action act = () => kernel.Should().Resolve<ISomeProvider>().WithAtLeastOneInstance();
7878

7979
// Assert
80-
act.ShouldNotThrow<AssertionException>();
80+
act.ShouldNotThrow();
8181
}
8282

8383
[Test]
@@ -105,7 +105,7 @@ public void Should_succeed_when_asserting_interfaces_can_be_resolved_with_at_lea
105105
Action act = () => kernel.Should().Resolve(interfaces).WithAtLeastOneInstance();
106106

107107
// Assert
108-
act.ShouldNotThrow<AssertionException>();
108+
act.ShouldNotThrow();
109109
}
110110

111111
[Test]
@@ -134,7 +134,7 @@ public void Should_succeed_when_asserting_interfaces_can_be_resolved_when_implem
134134
Action act = () => kernel.Should().Resolve(interfaces).WithSingleInstance();
135135

136136
// Assert
137-
act.ShouldNotThrow<AssertionException>();
137+
act.ShouldNotThrow();
138138
}
139139

140140
[Test]
@@ -163,7 +163,7 @@ public void Should_succeed_when_asserting_an_interface_resolves_to_concrete_impl
163163
Action act = () => kernel.Should().Resolve<IFooService>().To<FooService>();
164164

165165
// Assert
166-
act.ShouldNotThrow<Exception>();
166+
act.ShouldNotThrow();
167167
}
168168

169169
[Test]

src/FluentAssertions.Ioc.Ninject/SingleTypeKernelAssertions.cs

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public void To<T>()
5757

5858
private string BuildFailureMessage(ActivationError error)
5959
{
60+
if (error == null) return string.Empty;
61+
6062
var builder = new StringBuilder();
6163

6264
builder.AppendFormat("Unable to resolve type {0}.", error.Type.FullName);

0 commit comments

Comments
 (0)