Skip to content

Commit

Permalink
changed compose-log-expected to be multi-line aware.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpinkzh committed Mar 26, 2016
1 parent 2e9cbe7 commit 5541d82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
10 changes: 1 addition & 9 deletions src/ExAs/Assertions/MemberAssertions/Strings/EqualAssertion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using ExAs.Results;
using ExAs.Utils;
using ExAs.Utils.StringExtensions;
using static ExAs.Utils.StringExtensions.StringFormattingFunctions;

namespace ExAs.Assertions.MemberAssertions.Strings
{
Expand All @@ -18,21 +17,14 @@ public EqualAssertion(string expected)
public ValueAssertionResult AssertValue(string actual)
{
var actualValueString = actual.ToValueString();
var expectationString = Expected(expected);
var expectationString = ComposeLog.Expected(expected.ToValueString());
Tuple<string, string> harmonizedOutput = HarmonizeLineCountWith(actualValueString, expectationString);
return new ValueAssertionResult(
string.Equals(actual, expected),
harmonizedOutput.Item1,
harmonizedOutput.Item2);
}

private string Expected(string input)
{
string apostrophedInput = input.ToValueString();
string inputWithExpectedPrefix = HangingIndent("(expected: ", apostrophedInput);
return string.Format("{0})", inputWithExpectedPrefix);
}

private Tuple<string, string> HarmonizeLineCountWith(string firstString, string otherString)
{
int firstStringLineCount = firstString.SplitLines().Length;
Expand Down
5 changes: 3 additions & 2 deletions src/ExAs/Utils/ComposeLog.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using ExAs.Utils.StringExtensions;
using static ExAs.Utils.StringExtensions.StringFormattingFunctions;

namespace ExAs.Utils
{
public static class ComposeLog
{
public static string Expected(string expectedValue)
public static string Expected(string expectationString)
{
return "(expected: ".Add(expectedValue).Add(")");
return $"{HangingIndent("(expected: ", expectationString)})";
}
}
}

0 comments on commit 5541d82

Please sign in to comment.