Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 6a2e730

Browse files
committed
Fix build error and reformat
1 parent df2c94c commit 6a2e730

File tree

1 file changed

+123
-123
lines changed

1 file changed

+123
-123
lines changed

tests/ServiceStack.Text.Tests/StringExtensionsTests.cs

Lines changed: 123 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -5,82 +5,82 @@
55

66
namespace ServiceStack.Text.Tests
77
{
8-
[TestFixture]
9-
public class StringExtensionsTests
10-
{
11-
[Test]
12-
public void Can_SplitOnFirst_char_needle()
13-
{
14-
var parts = "user:pass@w:rd".SplitOnFirst(':');
15-
Assert.That(parts[0], Is.EqualTo("user"));
16-
Assert.That(parts[1], Is.EqualTo("pass@w:rd"));
17-
}
18-
19-
[Test]
20-
public void Can_SplitOnFirst_string_needle()
21-
{
22-
var parts = "user:pass@w:rd".SplitOnFirst(":");
23-
Assert.That(parts[0], Is.EqualTo("user"));
24-
Assert.That(parts[1], Is.EqualTo("pass@w:rd"));
25-
}
26-
27-
[Test]
28-
public void Can_SplitOnLast_char_needle()
29-
{
30-
var parts = "user:name:pass@word".SplitOnLast(':');
31-
Assert.That(parts[0], Is.EqualTo("user:name"));
32-
Assert.That(parts[1], Is.EqualTo("pass@word"));
33-
}
34-
35-
[Test]
36-
public void Can_SplitOnLast_string_needle()
37-
{
38-
var parts = "user:name:pass@word".SplitOnLast(":");
39-
Assert.That(parts[0], Is.EqualTo("user:name"));
40-
Assert.That(parts[1], Is.EqualTo("pass@word"));
41-
}
42-
43-
private static readonly char DirSep = Path.DirectorySeparatorChar;
44-
private static readonly char AltDirSep = Path.DirectorySeparatorChar == '/' ? '\\' : '/';
45-
46-
[Test]
47-
public void Does_get_ParentDirectory()
48-
{
49-
var dirSep = DirSep;
50-
var filePath = "path{0}to{0}file".FormatWith(dirSep);
51-
Assert.That(filePath.ParentDirectory(), Is.EqualTo("path{0}to".FormatWith(dirSep)));
52-
Assert.That(filePath.ParentDirectory().ParentDirectory(), Is.EqualTo("path".FormatWith(dirSep)));
53-
Assert.That(filePath.ParentDirectory().ParentDirectory().ParentDirectory(), Is.Null);
54-
55-
var filePathWithExt = "path{0}to{0}file/".FormatWith(dirSep);
56-
Assert.That(filePathWithExt.ParentDirectory(), Is.EqualTo("path{0}to".FormatWith(dirSep)));
57-
Assert.That(filePathWithExt.ParentDirectory().ParentDirectory(), Is.EqualTo("path".FormatWith(dirSep)));
58-
Assert.That(filePathWithExt.ParentDirectory().ParentDirectory().ParentDirectory(), Is.Null);
59-
}
60-
61-
[Test]
62-
public void Does_get_ParentDirectory_of_AltDirectorySeperator()
63-
{
64-
var dirSep = AltDirSep;
65-
var filePath = "path{0}to{0}file".FormatWith(dirSep);
66-
Assert.That(filePath.ParentDirectory(), Is.EqualTo("path{0}to".FormatWith(dirSep)));
67-
Assert.That(filePath.ParentDirectory().ParentDirectory(), Is.EqualTo("path".FormatWith(dirSep)));
68-
Assert.That(filePath.ParentDirectory().ParentDirectory().ParentDirectory(), Is.Null);
69-
70-
var filePathWithExt = "path{0}to{0}file{0}".FormatWith(dirSep);
71-
Assert.That(filePathWithExt.ParentDirectory(), Is.EqualTo("path{0}to".FormatWith(dirSep)));
72-
Assert.That(filePathWithExt.ParentDirectory().ParentDirectory(), Is.EqualTo("path".FormatWith(dirSep)));
73-
Assert.That(filePathWithExt.ParentDirectory().ParentDirectory().ParentDirectory(), Is.Null);
74-
}
75-
76-
[Test]
77-
public void Does_not_alter_filepath_without_extension()
78-
{
79-
var path = "path/dir.with.dot/to/file";
80-
Assert.That(path.WithoutExtension(), Is.EqualTo(path));
81-
82-
Assert.That("path/to/file.ext".WithoutExtension(), Is.EqualTo("path/to/file"));
83-
}
8+
[TestFixture]
9+
public class StringExtensionsTests
10+
{
11+
[Test]
12+
public void Can_SplitOnFirst_char_needle()
13+
{
14+
var parts = "user:pass@w:rd".SplitOnFirst(':');
15+
Assert.That(parts[0], Is.EqualTo("user"));
16+
Assert.That(parts[1], Is.EqualTo("pass@w:rd"));
17+
}
18+
19+
[Test]
20+
public void Can_SplitOnFirst_string_needle()
21+
{
22+
var parts = "user:pass@w:rd".SplitOnFirst(":");
23+
Assert.That(parts[0], Is.EqualTo("user"));
24+
Assert.That(parts[1], Is.EqualTo("pass@w:rd"));
25+
}
26+
27+
[Test]
28+
public void Can_SplitOnLast_char_needle()
29+
{
30+
var parts = "user:name:pass@word".SplitOnLast(':');
31+
Assert.That(parts[0], Is.EqualTo("user:name"));
32+
Assert.That(parts[1], Is.EqualTo("pass@word"));
33+
}
34+
35+
[Test]
36+
public void Can_SplitOnLast_string_needle()
37+
{
38+
var parts = "user:name:pass@word".SplitOnLast(":");
39+
Assert.That(parts[0], Is.EqualTo("user:name"));
40+
Assert.That(parts[1], Is.EqualTo("pass@word"));
41+
}
42+
43+
private static readonly char DirSep = Path.DirectorySeparatorChar;
44+
private static readonly char AltDirSep = Path.DirectorySeparatorChar == '/' ? '\\' : '/';
45+
46+
[Test]
47+
public void Does_get_ParentDirectory()
48+
{
49+
var dirSep = DirSep;
50+
var filePath = "path{0}to{0}file".FormatWith(dirSep);
51+
Assert.That(filePath.ParentDirectory(), Is.EqualTo("path{0}to".FormatWith(dirSep)));
52+
Assert.That(filePath.ParentDirectory().ParentDirectory(), Is.EqualTo("path".FormatWith(dirSep)));
53+
Assert.That(filePath.ParentDirectory().ParentDirectory().ParentDirectory(), Is.Null);
54+
55+
var filePathWithExt = "path{0}to{0}file/".FormatWith(dirSep);
56+
Assert.That(filePathWithExt.ParentDirectory(), Is.EqualTo("path{0}to".FormatWith(dirSep)));
57+
Assert.That(filePathWithExt.ParentDirectory().ParentDirectory(), Is.EqualTo("path".FormatWith(dirSep)));
58+
Assert.That(filePathWithExt.ParentDirectory().ParentDirectory().ParentDirectory(), Is.Null);
59+
}
60+
61+
[Test]
62+
public void Does_get_ParentDirectory_of_AltDirectorySeperator()
63+
{
64+
var dirSep = AltDirSep;
65+
var filePath = "path{0}to{0}file".FormatWith(dirSep);
66+
Assert.That(filePath.ParentDirectory(), Is.EqualTo("path{0}to".FormatWith(dirSep)));
67+
Assert.That(filePath.ParentDirectory().ParentDirectory(), Is.EqualTo("path".FormatWith(dirSep)));
68+
Assert.That(filePath.ParentDirectory().ParentDirectory().ParentDirectory(), Is.Null);
69+
70+
var filePathWithExt = "path{0}to{0}file{0}".FormatWith(dirSep);
71+
Assert.That(filePathWithExt.ParentDirectory(), Is.EqualTo("path{0}to".FormatWith(dirSep)));
72+
Assert.That(filePathWithExt.ParentDirectory().ParentDirectory(), Is.EqualTo("path".FormatWith(dirSep)));
73+
Assert.That(filePathWithExt.ParentDirectory().ParentDirectory().ParentDirectory(), Is.Null);
74+
}
75+
76+
[Test]
77+
public void Does_not_alter_filepath_without_extension()
78+
{
79+
var path = "path/dir.with.dot/to/file";
80+
Assert.That(path.WithoutExtension(), Is.EqualTo(path));
81+
82+
Assert.That("path/to/file.ext".WithoutExtension(), Is.EqualTo("path/to/file"));
83+
}
8484

8585
// 0 1
8686
// 01234567890123456789
@@ -89,28 +89,28 @@ public void Does_not_alter_filepath_without_extension()
8989
[TestCase("text with /* and <!--", "<!--", "/*x", 17)]
9090
[TestCase("text with /* and <!--", "<!--x", "/*x", -1)]
9191
public void Does_find_IndexOfAny_strings(string text, string needle1, string needle2, int expectedPos)
92-
{
93-
var pos = text.IndexOfAny(needle1, needle2);
94-
Assert.That(pos, Is.EqualTo(expectedPos));
95-
}
92+
{
93+
var pos = text.IndexOfAny(needle1, needle2);
94+
Assert.That(pos, Is.EqualTo(expectedPos));
95+
}
9696

9797
[Test]
98-
public void Does_ExtractContent_first_pattern_from_Document_without_marker()
99-
{
100-
var text = "text with random <!--comment--> and Contents: <!--Contents--> are here";
101-
var extract = text.ExtractContents("<!--", "-->");
98+
public void Does_ExtractContent_first_pattern_from_Document_without_marker()
99+
{
100+
var text = "text with random <!--comment--> and Contents: <!--Contents--> are here";
101+
var extract = text.ExtractContents("<!--", "-->");
102102

103-
Assert.That(extract, Is.EqualTo("comment"));
104-
}
103+
Assert.That(extract, Is.EqualTo("comment"));
104+
}
105105

106-
[Test]
107-
public void Does_ExtractContents_from_Document()
108-
{
109-
var text = "text with random <!--comment--> and Contents: <!--Contents--> are here";
110-
var extract = text.ExtractContents("Contents:", "<!--", "-->");
106+
[Test]
107+
public void Does_ExtractContents_from_Document()
108+
{
109+
var text = "text with random <!--comment--> and Contents: <!--Contents--> are here";
110+
var extract = text.ExtractContents("Contents:", "<!--", "-->");
111111

112-
Assert.That(extract, Is.EqualTo("Contents"));
113-
}
112+
Assert.That(extract, Is.EqualTo("Contents"));
113+
}
114114

115115
[Test]
116116
public void Can_Url_Encode_String()
@@ -119,7 +119,7 @@ public void Can_Url_Encode_String()
119119

120120
var encoded = text.UrlEncode();
121121

122-
Assert.That(encoded,
122+
Assert.That(encoded,
123123
Is.EqualTo("This+string+%26+has+%25+unsafe+%3f+characters+for+%29%5f%28%2a%26%5e%25%24%24%5e%24%40%23+a+query+string"));
124124

125125
var decoded = encoded.UrlDecode();
@@ -176,7 +176,7 @@ public void Can_ToTitleCase_Empty_String()
176176
Assert.That(ttc, Is.EqualTo(""));
177177
}
178178

179-
[Test]
179+
[Test]
180180
public void Can_Url_Encode_Unicode_String()
181181
{
182182
var text = "This string & has % 权뜑簒㮐ᾟ䗚璥趮⚦䭌䳅浝䕌ਥ⤧笫 characters";
@@ -191,9 +191,9 @@ public void Can_Url_Encode_Unicode_String()
191191
Assert.That(decoded, Is.EqualTo(text));
192192
}
193193

194-
[Test]
195-
public void Can_trim_prefixes()
196-
{
194+
[Test]
195+
public void Can_trim_prefixes()
196+
{
197197
Assert.That("/www_deploy/path/info".TrimPrefixes("/www_deploy", "~/www_deploy"),
198198
Is.EqualTo("/path/info"));
199199
Assert.That("~/www_deploy/path/info".TrimPrefixes("/www_deploy", "~/www_deploy"),
@@ -202,19 +202,19 @@ public void Can_trim_prefixes()
202202
Is.EqualTo("/path/info"));
203203
}
204204

205-
[Test]
206-
public void Can_read_lines()
207-
{
205+
[Test]
206+
public void Can_read_lines()
207+
{
208208
Assert.That((null as string).ReadLines().Count(), Is.EqualTo(0));
209209
Assert.That("".ReadLines().Count(), Is.EqualTo(0));
210210
Assert.That("a".ReadLines().Count(), Is.EqualTo(1));
211211
Assert.That("a\nb".ReadLines().Count(), Is.EqualTo(2));
212212
Assert.That("a\r\nb".ReadLines().Count(), Is.EqualTo(2));
213-
}
213+
}
214214

215-
[Test]
216-
public void Can_ParseKeyValueText()
217-
{
215+
[Test]
216+
public void Can_ParseKeyValueText()
217+
{
218218
Assert.That("".ParseKeyValueText().Count, Is.EqualTo(0));
219219
Assert.That("a".ParseKeyValueText().Count, Is.EqualTo(1));
220220
Assert.That("a".ParseKeyValueText()["a"], Is.Null);
@@ -226,26 +226,26 @@ public void Can_ParseKeyValueText()
226226
Assert.That("a:b\nc:d".ParseKeyValueText()["c"], Is.EqualTo("d"));
227227
Assert.That("a:b\r\nc:d".ParseKeyValueText()["c"], Is.EqualTo("d"));
228228
}
229-
229+
230230
[Test]
231-
public void Can_SafeSubstring_with_no_length {
232-
233-
var input = "TestString";
234-
Assert.That(input.SafeSubstring(0), Is.EqualTo("TestString"));
235-
Assert.That(input.SafeSubstring(2), Is.EqualTo("stString"));
236-
Assert.That(input.SafeSubstring(20), Is.EqualTo(""));
231+
public void Can_SafeSubstring_with_no_length()
232+
{
233+
234+
var input = "TestString";
235+
Assert.That(input.SafeSubstring(0), Is.EqualTo("TestString"));
236+
Assert.That(input.SafeSubstring(2), Is.EqualTo("stString"));
237+
Assert.That(input.SafeSubstring(20), Is.EqualTo(""));
237238
}
238-
239+
239240
[Test]
240-
public void Can_SafeSubstring_with_length {
241-
var input = "TestString";
242-
Assert.That(input.SafeSubstring(0,4), Is.EqualTo("Test"));
243-
Assert.That(input.SafeSubstring(2,4), Is.EqualTo("stSt"));
244-
Assert.That(input.SafeSubstring(20,4), Is.EqualTo(""));
245-
Assert.That(input.SafeSubstring(0,20), Is.EqualTo("TestString"));
246-
247-
}
248-
}
241+
public void Can_SafeSubstring_with_length()
242+
{
243+
var input = "TestString";
244+
Assert.That(input.SafeSubstring(0, 4), Is.EqualTo("Test"));
245+
Assert.That(input.SafeSubstring(2, 4), Is.EqualTo("stSt"));
246+
Assert.That(input.SafeSubstring(20, 4), Is.EqualTo(""));
247+
Assert.That(input.SafeSubstring(0, 20), Is.EqualTo("TestString"));
248+
249249
}
250-
}
250+
}
251251
}

0 commit comments

Comments
 (0)