@@ -75,7 +75,7 @@ Variables can be used inside expressions with `Interpreter.SetVariable` method:
7575``` csharp
7676var target = new Interpreter ().SetVariable (" myVar" , 23 );
7777
78- Assert .AreEqual ( 23 , target .Eval (" myVar" ));
78+ Assert .That ( target .Eval (" myVar" ), Is . EqualTo ( 23 ));
7979```
8080Variables can be primitive types or custom complex types (classes, structures, delegates, arrays, collections, ...).
8181
@@ -84,7 +84,7 @@ Custom functions can be passed with delegate variables using `Interpreter.SetFun
8484Func < double , double , double > pow = (x , y ) => Math .Pow (x , y );
8585var target = new Interpreter ().SetFunction (" pow" , pow );
8686
87- Assert .AreEqual ( 9 . 0 , target .Eval (" pow(3, 2)" ));
87+ Assert .That ( target .Eval (" pow(3, 2)" ), Is . EqualTo ( 9 . 0 ));
8888```
8989Custom [ Expression] ( http://msdn.microsoft.com/en-us/library/system.linq.expressions.expression.aspx ) can be passed by using ` Interpreter.SetExpression ` method.
9090
@@ -99,7 +99,7 @@ var parameters = new[] {
9999 new Parameter (" y" , 7 )
100100};
101101
102- Assert .AreEqual ( 30 , interpreter .Eval (" x + y" , parameters ));
102+ Assert .That ( interpreter .Eval (" x + y" , parameters ), Is . EqualTo ( 30 ));
103103```
104104Parameters can be primitive types or custom types. You can parse an expression once and invoke it multiple times with different parameter values:
105105``` csharp
@@ -112,8 +112,8 @@ var parameters = new[] {
112112
113113var myFunc = target .Parse (" x + y" , parameters );
114114
115- Assert .AreEqual ( 30 , myFunc .Invoke (23 , 7 ));
116- Assert .AreEqual ( 30 , myFunc .Invoke (32 , - 2 ));
115+ Assert .That ( myFunc .Invoke (23 , 7 ), Is . EqualTo ( 30 ));
116+ Assert .That ( myFunc .Invoke (32 , - 2 ), Is . EqualTo ( 30 ));
117117```
118118
119119### Special identifiers
@@ -129,10 +129,10 @@ var target = new Interpreter();
129129target .SetVariable (" this" , new Customer { Name = " John" });
130130
131131// explicit context reference via 'this' variable
132- Assert .AreEqual ( " John " , target .Eval (" this.Name" ));
132+ Assert .That ( target .Eval (" this.Name" ), Is . EqualTo ( " John " ));
133133
134134// 'this' variable is referenced implicitly
135- Assert .AreEqual ( " John " , target . Eval ( " Name " ));
135+ Assert .That ( target . Eval ( " Name " ), Is . EqualTo ( " John " ));
136136```
137137
138138### Built-in types and custom types
@@ -153,8 +153,8 @@ You can reference any other custom .NET type by using `Interpreter.Reference` me
153153``` csharp
154154var target = new Interpreter ().Reference (typeof (Uri ));
155155
156- Assert .AreEqual ( typeof (Uri ), target . Eval ( " typeof(Uri)" ));
157- Assert .AreEqual ( Uri .UriSchemeHttp , target . Eval ( " Uri.UriSchemeHttp" ));
156+ Assert .That ( target . Eval ( " typeof(Uri)" ), Is . EqualTo ( typeof (Uri )));
157+ Assert .That ( target . Eval ( " Uri.UriSchemeHttp" ), Is . EqualTo ( Uri .UriSchemeHttp ));
158158```
159159
160160### Generate dynamic delegates
@@ -184,7 +184,7 @@ public void Linq_Where()
184184 var interpreter = new Interpreter ();
185185 Func < Customer , bool > dynamicWhere = interpreter .ParseAsDelegate <Func <Customer , bool >>(whereExpression , " customer" );
186186
187- Assert .AreEqual ( 1 , customers .Where (dynamicWhere ).Count ());
187+ Assert .That ( customers .Where (dynamicWhere ).Count (), Is . EqualTo ( 1 ));
188188}
189189```
190190This is the preferred way to parse an expression that you known at compile time what parameters can accept and what value must return.
@@ -217,7 +217,7 @@ public void Linq_Queryable_Expression_Where()
217217 var interpreter = new Interpreter ();
218218 Expression < Func < Customer , bool >> expression = interpreter .ParseAsExpression <Func <Customer , bool >>(whereExpression , " customer" );
219219
220- Assert .AreEqual ( 1 , customers .Where (expression ).Count ());
220+ Assert .That ( customers .Where (expression ).Count (), Is . EqualTo ( 1 ));
221221}
222222```
223223
@@ -332,18 +332,18 @@ var target = new Interpreter()
332332 .SetVariable (" x" , service )
333333 .SetVariable (" this" , context );
334334
335- Assert .AreEqual ( service . HelloWorld (), target . Eval ( " x .HelloWorld()" ));
336- Assert .AreEqual ( service . AProperty , target .Eval (" x.AProperty" ));
337- Assert .AreEqual ( service . AField , target .Eval (" x.AField" ));
335+ Assert .That ( target . Eval ( " x. HelloWorld()" ), Is . EqualTo ( service .HelloWorld ()));
336+ Assert .That ( target .Eval (" x.AProperty" ), Is . EqualTo ( service . AProperty ));
337+ Assert .That ( target .Eval (" x.AField" ), Is . EqualTo ( service . AField ));
338338
339339// implicit context reference
340- Assert .AreEqual ( context . GetContextId (), target . Eval ( " GetContextId()" ));
341- Assert .AreEqual ( context . ContextName , target .Eval (" ContextName" ));
342- Assert .AreEqual ( context . ContextField , target .Eval (" ContextField" ));
340+ Assert .That ( target . Eval ( " GetContextId()" ), Is . EqualTo ( context . GetContextId ()));
341+ Assert .That ( target .Eval (" ContextName" ), Is . EqualTo ( context . ContextName ));
342+ Assert .That ( target .Eval (" ContextField" ), Is . EqualTo ( context . ContextField ));
343343```
344344``` csharp
345345var target = new Interpreter ();
346- Assert .AreEqual ( new DateTime (2015 , 1 , 24 ), target . Eval ( " new DateTime(2015, 1, 24) " ));
346+ Assert .That ( target . Eval ( " new DateTime(2015, 1, 24)" ), Is . EqualTo ( new DateTime (2015 , 1 , 24 ));
347347```
348348Dynamic Expresso also supports :
349349
@@ -353,7 +353,7 @@ var x = new int[] { 10, 30, 4 };
353353var target = new Interpreter ()
354354 .Reference (typeof (System .Linq .Enumerable ))
355355 .SetVariable (" x" , x );
356- Assert .AreEqual ( x .Count (), target . Eval ( " x.Count()" ));
356+ Assert .That ( target . Eval ( " x.Count()" ), Is . EqualTo ( x .Count ()));
357357```
358358- Indexer methods (like `array [0 ]`)
359359- Generics , only partially supported (only implicit , you cannot invoke an explicit generic method )
@@ -369,7 +369,7 @@ var target = new Interpreter(options)
369369 .SetVariable (" x" , x );
370370
371371var results = target .Eval <IEnumerable <string >>(" x.Where(str => str.Length > 5).Select(str => str.ToUpper())" );
372- Assert .AreEqual ( new [] { " AWESOME" }, results );
372+ Assert .That ( results , Is . EqualTo ( new [] { " AWESOME" }) );
373373```
374374
375375Note that parsing lambda expressions is disabled by default , because it has a slight performance cost .
@@ -383,7 +383,7 @@ var target = new Interpreter(options)
383383 .SetVariable (" increment" , 3 ); // access a variable from the lambda expression
384384
385385var myFunc = target .Eval <Func <int , string , string >>(" (i, str) => str.ToUpper() + (i + increment)" );
386- Assert .AreEqual ( " TEST8 " , lambda .Invoke (5 , " test" ));
386+ Assert .That ( lambda .Invoke (5 , " test" ), Is . EqualTo ( " TEST8 " ));
387387```
388388
389389### Case sensitive/insensitive
@@ -397,8 +397,8 @@ var parameters = new[] {
397397 new Parameter (" x" , x .GetType (), x )
398398};
399399
400- Assert .AreEqual ( x , target .Eval (" x" , parameters ));
401- Assert .AreEqual ( x , target .Eval (" X" , parameters ));
400+ Assert .That ( target .Eval (" x" , parameters ), Is . EqualTo ( x ));
401+ Assert .That ( target .Eval (" X" , parameters ), Is . EqualTo ( x ));
402402```
403403
404404
@@ -414,8 +414,8 @@ var target = new Interpreter();
414414
415415var detectedIdentifiers = target .DetectIdentifiers (" x + y" );
416416
417- CollectionAssert . AreEqual ( new [] { " x " , " y " } ,
418- detectedIdentifiers . UnknownIdentifiers . ToArray () );
417+ Assert . That ( detectedIdentifiers . UnknownIdentifiers ,
418+ Is . EqualTo ( new [] { " x " , " y " } );
419419```
420420
421421## Default number type
@@ -430,8 +430,8 @@ var target = new Interpreter();
430430
431431target .SetDefaultNumberType (DefaultNumberType .Decimal );
432432
433- Assert .IsInstanceOf ( typeof ( System . Decimal ), target .Eval (" 45" ));
434- Assert .AreEqual ( 10 M / 3 M , target .Eval (" 10/3" )); // 3.33333333333 instead of 3
433+ Assert .That ( target .Eval (" 45" ), Is . InstanceOf < System . Decimal >( ));
434+ Assert .That ( target .Eval (" 10/3" ), Is . EqualTo ( 10 M / 3 M )); // 3.33333333333 instead of 3
435435 ```
436436
437437## Limitations
0 commit comments