Skip to content

Commit 242e082

Browse files
committed
Support for parsing equality operator with primitive operands.
1 parent e4d34a4 commit 242e082

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
using NUnit.Framework;
2+
using System;
3+
using System.Linq.Expressions;
4+
using TestStack.FluentMVCTesting.Internal;
25

36
namespace TestStack.FluentMVCTesting.Tests.Internal
47
{
58
[TestFixture]
6-
public class ExpressionInspectorTests
9+
public class ExpressionInspectorShould
710
{
8-
11+
[Test]
12+
public void Correctly_parse_equality_comparison_with_string_operands()
13+
{
14+
Expression<Func<string, bool>> func = text => text == "any";
15+
ExpressionInspector sut = new ExpressionInspector();
16+
var actual = sut.Inspect(func);
17+
Assert.AreEqual("text => text == \"any\"", actual);
18+
}
19+
20+
[Test]
21+
public void Correctly_parse_equality_comparison_with_int_operands()
22+
{
23+
Expression<Func<int, bool>> func = number => number == 5;
24+
ExpressionInspector sut = new ExpressionInspector();
25+
var actual = sut.Inspect(func);
26+
Assert.AreEqual("number => number == 5", actual);
27+
}
928
}
1029
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
using System;
2-
using System.Linq.Expressions;
1+
using System.Linq.Expressions;
2+
using System.Text.RegularExpressions;
33

44
namespace TestStack.FluentMVCTesting.Internal
55
{
66
internal class ExpressionInspector
77
{
8-
internal void Inspect(LambdaExpression expression)
8+
internal string Inspect(LambdaExpression expression)
99
{
10-
throw new NotImplementedException();
10+
return Regex.Replace(expression.ToString(), "[()]", "");
1111
}
1212
}
1313
}

0 commit comments

Comments
 (0)