@@ -10,45 +10,42 @@ namespace PrimeLib.Tests
10
10
[ TestClass ]
11
11
public class RefactoringTests
12
12
{
13
- /*[TestMethod]
14
- public void FormatLinesTest()
15
- {
16
- Assert.Fail();
17
- }*/
18
-
19
13
private readonly string [ ] _codeBlocks =
20
14
{
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}"
23
19
} ;
24
20
25
21
private const string CRLF = "\n \r " , LineWithComments = "// Line with comments" + CRLF , IndentationString = "\t " ;
26
22
27
23
[ TestMethod ]
28
24
public void FormatLines_Simple_Test ( )
29
25
{
30
- TestBlocksThatShouldNotChange ( new object [ ] { String . Empty , ' ' , String . Empty , String . Empty , ';' } ) ;
26
+ TestBlocksThatShouldNotChange ( new object [ ] { String . Empty , ' ' , String . Empty , String . Empty , ';' } ) ;
31
27
}
32
28
33
29
[ TestMethod ]
34
30
public void FormatLines_Simple_Multiline_Test ( )
35
31
{
36
- TestBlocksThatShouldNotChange ( new object [ ] { String . Empty , String . Empty , String . Empty , CRLF , ';' } ) ;
32
+ TestBlocksThatShouldNotChange ( new object [ ] { String . Empty , String . Empty , String . Empty , CRLF , ';' } ) ;
37
33
}
38
34
39
35
[ TestMethod ]
40
36
public void FormatLines_Simple_Multiline_With_Outer_Comments_Test ( )
41
37
{
42
- TestBlocksThatShouldNotChange ( new object [ ] { LineWithComments , String . Empty , String . Empty , CRLF , ';' + LineWithComments } ) ;
38
+ TestBlocksThatShouldNotChange ( new object [ ]
39
+ { LineWithComments , String . Empty , String . Empty , CRLF , ';' + LineWithComments } ) ;
43
40
}
44
41
45
42
private void TestBlocksThatShouldNotChange ( object [ ] args )
46
43
{
47
44
foreach ( var l in _codeBlocks )
48
45
{
49
46
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 ) ) ;
52
49
53
50
Refactoring . FormatLines ( ref test , IndentationString ) ;
54
51
CollectionAssert . AreEqual ( original , test ) ;
@@ -59,12 +56,16 @@ private void TestBlocksThatShouldNotChange(object[] args)
59
56
public void FormatLines_IF_Sentence_Test ( )
60
57
{
61
58
// 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 ( ) ) ;
64
61
65
62
// 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 ( ) ) ;
68
69
69
70
// Test when is badly indented
70
71
FormatAndCheck ( new [ ] { "IF TRUE THEN" , IndentationString + IndentationString + "// NOP" , "END;" } . ToList ( ) ,
@@ -75,16 +76,20 @@ public void FormatLines_IF_Sentence_Test()
75
76
public void FormatLines_IFERR_Sentence_Test ( )
76
77
{
77
78
// 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 ( ) ) ;
80
81
81
82
// 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 ( ) ) ;
84
89
85
90
// 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 ( ) ) ;
88
93
}
89
94
90
95
[ TestMethod ]
@@ -97,16 +102,19 @@ public void FormatLines_FOR_Sentence_Test()
97
102
public void FormatLines_BEGIN_Sentence_Test ( )
98
103
{
99
104
// 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 ( ) ) ;
102
107
103
108
// 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 ( ) ) ;
106
114
107
115
// 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 ( ) ) ;
110
118
}
111
119
112
120
[ TestMethod ]
0 commit comments