Skip to content

Commit a8ba519

Browse files
committed
Migrate and add unit tests
- Migrate units test API. - Add new unit tests.
1 parent 6b9b253 commit a8ba519

File tree

2 files changed

+180
-57
lines changed

2 files changed

+180
-57
lines changed

Tests/NFUnitTestStringBuilder/EncodingTests.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,46 @@
1111
namespace NFUnitTestStringBuilder
1212
{
1313
[TestClass]
14-
class EncodingTests
14+
public class EncodingTests
1515
{
1616
[TestMethod]
1717
public void Utf8EncodingTests_Test1()
1818
{
1919
string str = "this is a normal string that will be used to convert to bytes then back to a string";
20-
20+
2121
byte[] data = new byte[128];
2222
int len = str.Length;
2323
int idx = 0;
2424

2525
Random rand = new Random();
26-
26+
2727
int cBytes = 0;
2828

2929
while (len > 0)
3030
{
3131
int size = (len <= 2) ? len : rand.Next(len / 2) + 1;
3232
len -= size;
3333

34-
int cnt = UTF8Encoding.UTF8.GetBytes(str, idx, size, data, cBytes);
34+
int cnt = Encoding.UTF8.GetBytes(str, idx, size, data, cBytes);
3535

36-
Assert.Equal(str.Substring(idx, size), new string(UTF8Encoding.UTF8.GetChars(data, cBytes, cnt)));
36+
Assert.AreEqual(str.Substring(idx, size), new string(Encoding.UTF8.GetChars(data, cBytes, cnt)));
3737

3838
cBytes += cnt;
3939
idx += size;
4040
}
41-
Assert.Equal(cBytes, str.Length);
42-
string strAfter = new string(UTF8Encoding.UTF8.GetChars(data, 0, cBytes));
43-
Assert.Equal(str, strAfter);
41+
Assert.AreEqual(cBytes, str.Length);
42+
string strAfter = new string(Encoding.UTF8.GetChars(data, 0, cBytes));
43+
Assert.AreEqual(str, strAfter);
4444
}
4545

4646
[TestMethod]
4747
public void Utf8EncodingTests_Test2()
4848
{
4949
string str = "this is a normal string that will be used to convert to bytes then back to a string";
50-
byte[] data = UTF8Encoding.UTF8.GetBytes(str);
51-
Assert.Equal(data.Length, str.Length);
52-
string strAfter = new string(UTF8Encoding.UTF8.GetChars(data));
53-
Assert.Equal(str, strAfter);
50+
byte[] data = Encoding.UTF8.GetBytes(str);
51+
Assert.AreEqual(data.Length, str.Length);
52+
string strAfter = new string(Encoding.UTF8.GetChars(data));
53+
Assert.AreEqual(str, strAfter);
5454
}
5555

5656
[TestMethod]
@@ -59,9 +59,9 @@ public void Utf8EncodingTests_Test3()
5959
// This tests involves a string with a special character
6060
string str = "AB\u010DAB";
6161
byte[] data = new byte[4];
62-
int count = UTF8Encoding.UTF8.GetBytes(str, 1, 3, data, 0);
63-
Assert.Equal(count, 4);
64-
Assert.Equal(new string(UTF8Encoding.UTF8.GetChars(data)), "B\u010DA");
62+
int count = Encoding.UTF8.GetBytes(str, 1, 3, data, 0);
63+
Assert.AreEqual(4, count);
64+
Assert.AreEqual("B\u010DA", new string(Encoding.UTF8.GetChars(data)));
6565
}
6666
}
67-
}
67+
}

0 commit comments

Comments
 (0)