Skip to content

Commit

Permalink
Merge pull request #57 from ByteBlast/master
Browse files Browse the repository at this point in the history
Brought in ExpressionToString
  • Loading branch information
Null authored and Null committed Apr 8, 2015
2 parents fde71ce + a13eadd commit 00ce004
Show file tree
Hide file tree
Showing 10 changed files with 323 additions and 203 deletions.
24 changes: 22 additions & 2 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You can read the original problem specification and discussion [here](https://g

If your project has been impacted by this particular breaking change, you might consider reevaluate the correctness of the affected tests.

## Error Messages
## Error Message Quotes

Some error messages surrounded actual values in double quotes. Others surrounded the values in single quotes. In version 3.0.0 *all* values are surrounded in single quotes.

Expand All @@ -33,7 +33,27 @@ Consistency.

### Fix

Amend all effected tests to expect single quotes instead of double quotes.
Amend any affected tests to expect single quotes instead of double quotes.

## Error Message Lambda Expression

In error messages, lambda expressions arguments are now surrounded in a pair of parentheses. For example:

... to pass the given condition (model => (model.Property1 != null))

will now look like this:

... to pass the given condition ((model) => (model.Property1 != null))

As you can see, the argument called `model` is now surrounded in parentheses.

###Reason

FluentMVCTesting now uses [ExpressionToString](https://github.com/JakeGinnivan/ExpressionToString) to humanize expression trees. ExpressionToString surrounds arguments in parentheses.

###Fix

Amend any affected tests to expect lambda expression arguments to be surrounded in parentheses.

# Version 2.0.0

Expand Down
174 changes: 0 additions & 174 deletions TestStack.FluentMVCTesting.Tests/Internal/ExpressionInspectorTests.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
<Compile Include="ControllerResultTestTests\ShouldReturnEmptyResultTests.cs" />
<Compile Include="ControllerResultTestTests\ShouldReturnJsonTests.cs" />
<Compile Include="ControllerResultTestTests\ShouldReturnContentTests.cs" />
<Compile Include="Internal\ExpressionInspectorTests.cs" />
<Compile Include="RouteValueDictionaryExtensionsTests.cs" />
<Compile Include="TempDataResultTest.cs" />
<Compile Include="TestControllers\AsyncController.cs" />
Expand Down
17 changes: 14 additions & 3 deletions TestStack.FluentMVCTesting.Tests/ViewResultTestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void Check_for_invalid_model_using_predicate()
var exception = Assert.Throws<ViewResultModelAssertionException>(() =>
_viewResultTest.WithModel<TestViewModel>(m => m.Property1 == null)
);
Assert.That(exception.Message, Is.EqualTo(string.Format("Expected view model {{\"Property1\":\"{0}\",\"Property2\":{1}}} to pass the given condition (m => (m.Property1 == null)), but it failed.", _model.Property1, _model.Property2)));
Assert.That(exception.Message, Is.EqualTo(string.Format("Expected view model {{\"Property1\":\"{0}\",\"Property2\":{1}}} to pass the given condition ((m) => (m.Property1 == null)), but it failed.", _model.Property1, _model.Property2)));
}

[Test]
Expand All @@ -81,7 +81,7 @@ public void Check_for_invalid_model_using_predicate_with_conditional_or()
var exception = Assert.Throws<ViewResultModelAssertionException>(() =>
_viewResultTest.WithModel<TestViewModel>(m => m.Property1 == null || m.Property2 == 1)
);
Assert.That(exception.Message, Is.EqualTo(string.Format("Expected view model {{\"Property1\":\"{0}\",\"Property2\":{1}}} to pass the given condition (m => ((m.Property1 == null) || (m.Property2 == 1))), but it failed.", _model.Property1, _model.Property2)));
Assert.That(exception.Message, Is.EqualTo(string.Format("Expected view model {{\"Property1\":\"{0}\",\"Property2\":{1}}} to pass the given condition ((m) => ((m.Property1 == null) || (m.Property2 == 1))), but it failed.", _model.Property1, _model.Property2)));
}

[Test]
Expand All @@ -91,7 +91,18 @@ public void Check_for_invalid_model_using_predicate_with_primitive_operand()
var exception = Assert.Throws<ViewResultModelAssertionException>(() =>
_viewResultTest.WithModel<string>(m => m == "ab")
);
Assert.That(exception.Message, Is.EqualTo(string.Format("Expected view model \"{0}\" to pass the given condition (m => (m == \"ab\")), but it failed.", _viewResult.ViewData.Model)));
Assert.That(exception.Message, Is.EqualTo(string.Format("Expected view model \"{0}\" to pass the given condition ((m) => (m == \"ab\")), but it failed.", _viewResult.ViewData.Model)));
}

[Test]
public void Check_for_invalid_model_using_predicate_with_captured_var_operand()
{
var capturedOuterVar = "ab";
_viewResult.ViewData.Model = "abc";
var exception = Assert.Throws<ViewResultModelAssertionException>(() =>
_viewResultTest.WithModel<string>(m => m == capturedOuterVar)
);
Assert.That(exception.Message, Is.EqualTo(string.Format("Expected view model \"{0}\" to pass the given condition ((m) => (m == capturedOuterVar)), but it failed.", _viewResult.ViewData.Model)));
}

[Test]
Expand Down
Loading

0 comments on commit 00ce004

Please sign in to comment.