Skip to content

Commit d111dce

Browse files
author
Sébastien Geiser
committed
More tests for Typed variables
1 parent 3c24679 commit d111dce

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorScriptEvaluateTests.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,14 @@ public static IEnumerable<TestCaseData> TestCasesForScriptEvaluateTests
13011301
.SetCategory("=")
13021302
.Returns("[1,2,3,4]");
13031303

1304+
yield return new TestCaseData("int? x = null; return x;", null, null, null, null)
1305+
.SetCategory("Script")
1306+
.SetCategory("primaryTyped variable")
1307+
.SetCategory("null")
1308+
.SetCategory("nullable")
1309+
.SetCategory("=")
1310+
.Returns(null);
1311+
13041312
#endregion
13051313

13061314
#region More complex script
@@ -1541,6 +1549,31 @@ public static IEnumerable<TestCaseData> TestCasesForExceptionThrowingScriptEvalu
15411549
.SetCategory("Exception");
15421550

15431551
#endregion
1552+
1553+
#region set bad content to TypedVariable
1554+
1555+
yield return new TestCaseData(new ExpressionEvaluator(), "int x = \"Test\";", typeof(InvalidCastException), null, null)
1556+
.SetCategory("Script")
1557+
.SetCategory("int")
1558+
.SetCategory("primaryTyped variable")
1559+
.SetCategory("Exception");
1560+
1561+
yield return new TestCaseData(new ExpressionEvaluator(), "List<int> x = 3;", typeof(InvalidCastException), null, null)
1562+
.SetCategory("Script")
1563+
.SetCategory("int")
1564+
.SetCategory("List")
1565+
.SetCategory("primaryTyped variable")
1566+
.SetCategory("Exception");
1567+
1568+
yield return new TestCaseData(new ExpressionEvaluator(), "int x = null;", typeof(ExpressionEvaluatorSyntaxErrorException), "Can not cast null to System.Int32 because it's not a nullable valueType", null)
1569+
.SetCategory("Script")
1570+
.SetCategory("int")
1571+
.SetCategory("null")
1572+
.SetCategory("primaryTyped variable")
1573+
.SetCategory("Exception");
1574+
1575+
#endregion
1576+
15441577
}
15451578
}
15461579

0 commit comments

Comments
 (0)