Skip to content

Commit b50fab1

Browse files
committed
Some tests for structs
1 parent 085aa98 commit b50fab1

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

CodingSeb.ExpressionEvaluator.Tests/CodingSeb.ExpressionEvaluator.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<DesignTime>True</DesignTime>
1919
<DependentUpon>Resources.resx</DependentUpon>
2020
</Compile>
21+
<Compile Update="TestsUtils\StructForTest1.cs">
22+
<SubType>Code</SubType>
23+
</Compile>
2124
</ItemGroup>
2225
<ItemGroup>
2326
<ProjectReference Include="..\CodingSeb.ExpressionEvaluator\CodingSeb.ExpressionEvaluator.csproj" />

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorScriptEvaluateTests.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ public static IEnumerable<TestCaseData> TestCasesForScriptEvaluateTests
12931293
.Returns("[6,4,10,6,10,4]");
12941294

12951295
#endregion
1296-
1296+
12971297
#region For Bug correction (no regression)
12981298

12991299
yield return new TestCaseData(Resources.Script0049, null, null, null)
@@ -1310,6 +1310,26 @@ public static IEnumerable<TestCaseData> TestCasesForScriptEvaluateTests
13101310
.SetCategory("Bug")
13111311
.Returns("{\"Hello\":3,\"No\":\"Yes\"}");
13121312

1313+
StructForTest1 structForTest1 = new StructForTest1();
1314+
ExpressionEvaluator evaluatorForStructs = new ExpressionEvaluator(
1315+
new Dictionary<string, object>
1316+
{
1317+
{ "myStruct", structForTest1 }
1318+
});
1319+
1320+
yield return new TestCaseData("return myStruct.myIntvalue;", evaluatorForStructs, null, null)
1321+
.SetCategory("Script")
1322+
.SetCategory("struct value")
1323+
.SetCategory("Bug")
1324+
.Returns(0);
1325+
1326+
yield return new TestCaseData("myStruct.myIntvalue = 3;\r\nmyStruct.myStringValue = \"Test\";"
1327+
, new ExpressionEvaluator(new Dictionary<string, object> { { "myStruct", new StructForTest1() } }), null, null)
1328+
.SetCategory("Script")
1329+
.SetCategory("struct value assignation")
1330+
.SetCategory("Bug")
1331+
.Returns(0);
1332+
13131333
#endregion
13141334
}
13151335
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace CodingSeb.ExpressionEvaluator.Tests
2+
{
3+
public struct StructForTest1
4+
{
5+
public int myIntvalue;
6+
public string myStringValue;
7+
}
8+
}

0 commit comments

Comments
 (0)