Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 958a226

Browse files
committed
Small changes in the unit tests
1 parent 61cfd0d commit 958a226

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

PrimeCommTest/PrimeCommTest.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
</Otherwise>
5454
</Choose>
5555
<ItemGroup>
56-
<Compile Include="PrimeLibRefactoringTests.cs" />
5756
<Compile Include="Properties\AssemblyInfo.cs" />
57+
<Compile Include="RefactoringTests.cs" />
5858
</ItemGroup>
5959
<ItemGroup>
6060
<ProjectReference Include="..\PrimeLib\PrimeLib.csproj">

PrimeCommTest/RefactoringTests.cs

+37-29
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,42 @@ namespace PrimeLib.Tests
1010
[TestClass]
1111
public class RefactoringTests
1212
{
13-
/*[TestMethod]
14-
public void FormatLinesTest()
15-
{
16-
Assert.Fail();
17-
}*/
18-
1913
private readonly string[] _codeBlocks =
2014
{
21-
"{0}BEGIN{1}{2}{3}END{4}", "{0}IFERR{1}{2}{3}END{4}", "{0}IF{1}{2}{3}END{4}", "{0}IF{1}{2}ELSE{3}END{4}", "{0}IFERR{1}{2}ELSE{3}END{4}",
22-
"{0}FOR X FROM 1 TO 10 DO{1}{2}{3}END{4}", "{0}FOR X FROM 1 TO 10 STEP 1 DO{1}{2}{3}END{4}", "{0}REPEAT{1}{2}{3}UNTIL 1{4}"
15+
"{0}BEGIN{1}{2}{3}END{4}", "{0}IFERR{1}{2}{3}END{4}", "{0}IF{1}{2}{3}END{4}", "{0}IF{1}{2}ELSE{3}END{4}",
16+
"{0}IFERR{1}{2}ELSE{3}END{4}",
17+
"{0}FOR X FROM 1 TO 10 DO{1}{2}{3}END{4}", "{0}FOR X FROM 1 TO 10 STEP 1 DO{1}{2}{3}END{4}",
18+
"{0}REPEAT{1}{2}{3}UNTIL 1{4}"
2319
};
2420

2521
private const string CRLF = "\n\r", LineWithComments = "// Line with comments" + CRLF, IndentationString = "\t";
2622

2723
[TestMethod]
2824
public void FormatLines_Simple_Test()
2925
{
30-
TestBlocksThatShouldNotChange(new object[] { String.Empty, ' ', String.Empty, String.Empty, ';' });
26+
TestBlocksThatShouldNotChange(new object[] {String.Empty, ' ', String.Empty, String.Empty, ';'});
3127
}
3228

3329
[TestMethod]
3430
public void FormatLines_Simple_Multiline_Test()
3531
{
36-
TestBlocksThatShouldNotChange(new object[] { String.Empty, String.Empty, String.Empty, CRLF, ';' });
32+
TestBlocksThatShouldNotChange(new object[] {String.Empty, String.Empty, String.Empty, CRLF, ';'});
3733
}
3834

3935
[TestMethod]
4036
public void FormatLines_Simple_Multiline_With_Outer_Comments_Test()
4137
{
42-
TestBlocksThatShouldNotChange(new object[] { LineWithComments, String.Empty, String.Empty, CRLF, ';' + LineWithComments });
38+
TestBlocksThatShouldNotChange(new object[]
39+
{LineWithComments, String.Empty, String.Empty, CRLF, ';' + LineWithComments});
4340
}
4441

4542
private void TestBlocksThatShouldNotChange(object[] args)
4643
{
4744
foreach (var l in _codeBlocks)
4845
{
4946
var tmp = String.Format(l, args);
50-
var original = new List<string>(tmp.Split(new[] { CRLF }, StringSplitOptions.None));
51-
var test = new List<string>(tmp.Split(new[] { CRLF }, StringSplitOptions.None));
47+
var original = new List<string>(tmp.Split(new[] {CRLF}, StringSplitOptions.None));
48+
var test = new List<string>(tmp.Split(new[] {CRLF}, StringSplitOptions.None));
5249

5350
Refactoring.FormatLines(ref test, IndentationString);
5451
CollectionAssert.AreEqual(original, test);
@@ -59,12 +56,16 @@ private void TestBlocksThatShouldNotChange(object[] args)
5956
public void FormatLines_IF_Sentence_Test()
6057
{
6158
// Test when is not indented
62-
FormatAndCheck(new[] { "IF TRUE THEN", "// NOP", "END;" }.ToList(),
63-
new[] { "IF TRUE THEN", IndentationString+ "// NOP", "END;" }.ToList());
59+
FormatAndCheck(new[] {"IF TRUE THEN", "// NOP", "END;"}.ToList(),
60+
new[] {"IF TRUE THEN", IndentationString + "// NOP", "END;"}.ToList());
6461

6562
// TODO: Should ELSE be considered as inside the IF?
66-
FormatAndCheck(new[] { "IF TRUE THEN", "// NOP","ELSE", "// NOP", "END;" }.ToList(),
67-
new[] { "IF TRUE THEN", IndentationString + "// NOP", IndentationString + "ELSE", IndentationString + "// NOP", "END;" }.ToList());
63+
FormatAndCheck(new[] {"IF TRUE THEN", "// NOP", "ELSE", "// NOP", "END;"}.ToList(),
64+
new[]
65+
{
66+
"IF TRUE THEN", IndentationString + "// NOP", IndentationString + "ELSE", IndentationString + "// NOP",
67+
"END;"
68+
}.ToList());
6869

6970
// Test when is badly indented
7071
FormatAndCheck(new[] {"IF TRUE THEN", IndentationString + IndentationString + "// NOP", "END;"}.ToList(),
@@ -75,16 +76,20 @@ public void FormatLines_IF_Sentence_Test()
7576
public void FormatLines_IFERR_Sentence_Test()
7677
{
7778
// Test when is not indented
78-
FormatAndCheck(new[] { "IFERR TRUE THEN", "// NOP", "END;" }.ToList(),
79-
new[] { "IFERR TRUE THEN", IndentationString + "// NOP", "END;" }.ToList());
79+
FormatAndCheck(new[] {"IFERR TRUE THEN", "// NOP", "END;"}.ToList(),
80+
new[] {"IFERR TRUE THEN", IndentationString + "// NOP", "END;"}.ToList());
8081

8182
// TODO: Should ELSE be considered as inside the IF?
82-
FormatAndCheck(new[] { "IFERR TRUE THEN", "// NOP", "ELSE", "// NOP", "END;" }.ToList(),
83-
new[] { "IFERR TRUE THEN", IndentationString + "// NOP", IndentationString + "ELSE", IndentationString + "// NOP", "END;" }.ToList());
83+
FormatAndCheck(new[] {"IFERR TRUE THEN", "// NOP", "ELSE", "// NOP", "END;"}.ToList(),
84+
new[]
85+
{
86+
"IFERR TRUE THEN", IndentationString + "// NOP", IndentationString + "ELSE",
87+
IndentationString + "// NOP", "END;"
88+
}.ToList());
8489

8590
// Test when is badly indented
86-
FormatAndCheck(new[] { "IFERR TRUE THEN", IndentationString + IndentationString + "// NOP", "END;" }.ToList(),
87-
new[] { "IFERR TRUE THEN", IndentationString + "// NOP", "END;" }.ToList());
91+
FormatAndCheck(new[] {"IFERR TRUE THEN", IndentationString + IndentationString + "// NOP", "END;"}.ToList(),
92+
new[] {"IFERR TRUE THEN", IndentationString + "// NOP", "END;"}.ToList());
8893
}
8994

9095
[TestMethod]
@@ -97,16 +102,19 @@ public void FormatLines_FOR_Sentence_Test()
97102
public void FormatLines_BEGIN_Sentence_Test()
98103
{
99104
// Test when is not indented
100-
FormatAndCheck(new[] { "BEGIN", "// NOP", "END;" }.ToList(),
101-
new[] { "BEGIN", IndentationString + "// NOP", "END;" }.ToList());
105+
FormatAndCheck(new[] {"BEGIN", "// NOP", "END;"}.ToList(),
106+
new[] {"BEGIN", IndentationString + "// NOP", "END;"}.ToList());
102107

103108
// TODO: Should ELSE be considered as inside the IF?
104-
FormatAndCheck(new[] { "BEGIN", "// NOP", "ELSE", "// NOP", "END;" }.ToList(),
105-
new[] { "BEGIN", IndentationString + "// NOP", IndentationString + "ELSE", IndentationString + "// NOP", "END;" }.ToList());
109+
FormatAndCheck(new[] {"BEGIN", "// NOP", "ELSE", "// NOP", "END;"}.ToList(),
110+
new[]
111+
{
112+
"BEGIN", IndentationString + "// NOP", IndentationString + "ELSE", IndentationString + "// NOP", "END;"
113+
}.ToList());
106114

107115
// Test when is badly indented
108-
FormatAndCheck(new[] { "BEGIN", IndentationString + IndentationString + "// NOP", "END;" }.ToList(),
109-
new[] { "BEGIN", IndentationString + "// NOP", "END;" }.ToList());
116+
FormatAndCheck(new[] {"BEGIN", IndentationString + IndentationString + "// NOP", "END;"}.ToList(),
117+
new[] {"BEGIN", IndentationString + "// NOP", "END;"}.ToList());
110118
}
111119

112120
[TestMethod]

0 commit comments

Comments
 (0)