forked from codingseb/ExpressionEvaluator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOthersTests.cs
99 lines (82 loc) · 3.35 KB
/
OthersTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using NUnit.Framework;
using Shouldly;
namespace CodingSeb.ExpressionEvaluator.Tests
{
[TestFixture]
public class OthersTests
{
[Test]
public void RealNestedStructAssignationToSeeHowItWorksScript0055()
{
// The real version of Script0055
StructForTest2 otherStruct;
otherStruct.AnOtherIntValue = 5;
otherStruct.nestedStruct = new StructForTest1()
{
myIntvalue = 8,
myStringValue = "Hey"
};
otherStruct.nestedStruct.myIntvalue = 9;
$"Result {otherStruct.nestedStruct.myStringValue} {otherStruct.nestedStruct.myIntvalue}, {otherStruct.AnOtherIntValue}".ShouldBe("Result Hey 9, 5");
}
[Test]
public void RealNestedStructByPropertyAssignationToSeeHowItWorks()
{
// Same as Script0055 with properties
StructForTest4 otherStruct = new StructForTest4();
otherStruct.AnOtherIntValue = 5;
otherStruct.NestedStruct = new StructForTest3()
{
MyIntvalue = 8,
MyStringValue = "Hey"
};
// Do not compile
//otherStruct.NestedStruct.MyIntvalue = 9;
$"Result {otherStruct.NestedStruct.MyStringValue} {otherStruct.NestedStruct.MyIntvalue}, {otherStruct.AnOtherIntValue}".ShouldBe("Result Hey 8, 5");
}
[Test]
public void RealNestedStructInClassAssignationToSeeHowItWorksScript0056()
{
// The real version of Script0056
ClassStructContainer classStructContainer = new ClassStructContainer()
{
nestedStructField = new StructForTest1()
{
myIntvalue = 8,
myStringValue = "Hey"
}
};
classStructContainer.nestedStructField.myIntvalue = 9;
$"Result {classStructContainer.nestedStructField.myStringValue} {classStructContainer.nestedStructField.myIntvalue}".ShouldBe("Result Hey 9");
}
[Test]
public void RealNestedStructInClassPropertyAssignationToSeeHowItWorks()
{
ClassStructContainer classStructContainer = new ClassStructContainer()
{
NestedStructProperty = new StructForTest1()
{
myIntvalue = 8,
myStringValue = "Hey"
}
};
// Do not compile
//classStructContainer.NestedStructProperty.myIntvalue = 9;
$"Result {classStructContainer.NestedStructProperty.myStringValue} {classStructContainer.NestedStructProperty.myIntvalue}".ShouldBe("Result Hey 8");
}
[Test]
public void RealNestedStructPropertyInClassAttributeAssignationToSeeHowItWorksScript0057()
{
ClassStructContainer classStructContainer = new ClassStructContainer()
{
nestedStructField2 = new StructForTest3()
{
MyIntvalue = 8,
MyStringValue = "Hey"
}
};
classStructContainer.nestedStructField2.MyIntvalue = 9;
$"Result {classStructContainer.nestedStructField2.MyStringValue} {classStructContainer.nestedStructField2.MyIntvalue}".ShouldBe("Result Hey 9");
}
}
}