File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
src/FluentAssertions.Ioc.Ninject Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 33using System . Linq ;
44using System . Text ;
55using FluentAssertions . Execution ;
6+ using FluentAssertions . Formatting ;
67using FluentAssertions . Ioc . Ninject . Internal ;
78using Ninject ;
89
@@ -66,14 +67,26 @@ public void WithAtLeastOneInstance()
6667 . FailWith ( BuildFailureMessage ( failed ) ) ;
6768 }
6869
69- private string BuildFailureMessage ( List < ActivationError > failed )
70+ private string BuildFailureMessage ( IEnumerable < ActivationError > failed )
7071 {
7172 // Build the failure message
7273 var builder = new StringBuilder ( ) ;
74+ var exceptionBuilder = new StringBuilder ( ) ;
7375 builder . AppendLine ( "The following types could not be resolved:" ) . AppendLine ( ) ;
74-
76+
7577 foreach ( var error in failed )
78+ {
7679 builder . AppendFormat ( " - {0}" , error . Type . FullName ) . AppendLine ( ) ;
80+
81+ if ( error . Exception != null )
82+ {
83+ exceptionBuilder . AppendLine ( Formatter . ToString ( error . Exception ) ) ;
84+ exceptionBuilder . AppendLine ( ) ;
85+ }
86+ }
87+
88+ builder . AppendLine ( ) ;
89+ builder . AppendLine ( exceptionBuilder . ToString ( ) ) ;
7790
7891 return builder . ToString ( ) ;
7992 }
Original file line number Diff line number Diff line change 11using System ;
2+ using System . Text ;
23using FluentAssertions . Execution ;
4+ using FluentAssertions . Formatting ;
35using FluentAssertions . Ioc . Ninject . Internal ;
46using Ninject ;
57
@@ -55,7 +57,18 @@ public void To<T>()
5557
5658 private string BuildFailureMessage ( ActivationError error )
5759 {
58- return String . Format ( "Unable to resolve type {0}" , error . Type . FullName ) ;
60+ var builder = new StringBuilder ( ) ;
61+
62+ builder . AppendFormat ( "Unable to resolve type {0}." , error . Type . FullName ) ;
63+
64+ if ( error . Exception != null )
65+ {
66+ builder . AppendLine ( ) ;
67+ builder . AppendLine ( ) ;
68+ builder . Append ( Formatter . ToString ( error . Exception ) ) ;
69+ }
70+
71+ return builder . ToString ( ) ;
5972 }
6073 }
6174}
You can’t perform that action at this time.
0 commit comments