Skip to content

Commit

Permalink
Merge pull request #36 from softreigns/master
Browse files Browse the repository at this point in the history
Verifiable / verify to show which verifiable statement failed. #31
  • Loading branch information
vanderkleij committed Oct 10, 2017
2 parents 45a6729 + 57f499c commit 58ee0f4
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion Source/Smocks/Exceptions/VerificationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Runtime.Serialization;
using Smocks.Setups;
using Smocks.Utility;
using System.Text;

namespace Smocks.Exceptions
{
Expand Down Expand Up @@ -60,7 +61,30 @@ private static string GetMessage(IEnumerable<IInternalSetupBase> notMatchedSetup
{
ArgumentChecker.NotNull(notMatchedSetups, () => notMatchedSetups);

return "Verification failed";
StringBuilder message = new StringBuilder();

foreach (IInternalSetupBase setup in notMatchedSetups)
{
if (!string.IsNullOrEmpty(message.ToString()))
{
message.Append(",");
}

message.Append(Environment.NewLine);
message.Append(setup.MethodCall.Method.ReflectedType);
message.Append(".");
message.Append(setup.MethodCall.Method.Name);
message.Append("(");

if (setup.MethodCall.Arguments.Count > 0)
{
message.Append(string.Join(",", setup.MethodCall.Arguments));
}

message.Append(")");
}

return "Verification failed for method setups : " + message.ToString();
}
}
}

0 comments on commit 58ee0f4

Please sign in to comment.