Skip to content

Commit

Permalink
Adding VisitTypeBinary override for ExpressionStringBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
ssiko committed Jul 29, 2016
1 parent 9205f1e commit 84c9050
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/Shouldly.Tests/ShouldAllBe/TypeBinaryExpressionScenario.cs
@@ -0,0 +1,46 @@
using Shouldly.Tests.Strings;
using System.Collections.Generic;
using Xunit;

namespace Shouldly.Tests.ShouldAllBe
{
public class TypeBinaryExpressionScenario
{
[Fact]
public void TypeBinaryExpressionScenarioShouldFail()
{
List<object> objects = new List<object> { "1", 1 };

Verify.ShouldFail(() =>
objects.ShouldAllBe(x => x is string, "Some additional context"),

errorWithSource:
@"objects
should satisfy the condition
(x Is String)
but
[1]
do not
Additional Info:
Some additional context",

errorWithoutSource:
@"[""1"", 1]
should satisfy the condition
(x Is String)
but
[1]
do not
Additional Info:
Some additional context");
}

[Fact]
public void ShouldPass()
{
new[] { "1", "2", "3" }.ShouldAllBe(x => x is string);
}
}
}
Expand Up @@ -67,6 +67,12 @@ protected override Expression VisitBinary(BinaryExpression node)
return node;
}

protected override Expression VisitTypeBinary(TypeBinaryExpression node)
{
Out(node.ToString());
return node;
}

protected override Expression VisitParameter(ParameterExpression node)
{
Out(node.Name);
Expand Down

0 comments on commit 84c9050

Please sign in to comment.