-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUnitTest.cs
121 lines (110 loc) · 3.77 KB
/
UnitTest.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
using StringExtension;
namespace UnitTests;
/// <summary>
/// Contains unit tests for the StringExtension methods.
/// </summary>
public class Tests {
[SetUp]
public void Setup() {
}
public class UnitTest {
/// <summary>
/// Tests the RemoveCharacters method.
/// </summary>
[Test]
public void TestRemoveCharacters() {
string input = "hello world!";
char[] charactersToRemove = {'l', 'o'};
string expected = "he wrd!";
string result = input.RemoveCharacters(charactersToRemove);
Assert.That(result, Is.EqualTo(expected));
// Test code and assertions explained in code.
}
/// <summary>
/// Tests the IsValidEmail method.
/// </summary>
[Test]
public void TestIsValidEmail() {
string email = "[email protected]";
bool result = email.IsValidEmail();
Assert.IsTrue(result);
// Test code and assertions explained in code.
}
/// <summary>
/// Tests the IsValidPhoneNumber method.
/// </summary>
[Test]
public void TestIsValidPhoneNumber() {
string phoneNumber = "555-555-5555";
bool result = phoneNumber.IsValidPhoneNumber();
Assert.IsTrue(result);
// Test code and assertions explained in code.
}
/// <summary>
/// Tests the CountSubstring method.
/// </summary>
[Test]
public void TestCountSubstring() {
string input = "hello world!";
string substring = "l";
int expected = 3;
int result = input.CountSubstring(substring);
Assert.That(result, Is.EqualTo(expected));
// Test code and assertions explained in code.
}
/// <summary>
/// Tests the ReverseWords method.
/// </summary>
[Test]
public void TestReverseWords() {
string input = "hello world!";
string expected = "world! hello";
string result = input.ReverseWords();
Assert.That(result, Is.EqualTo(expected));
// Test code and assertions explained in code.
}
/// <summary>
/// Tests the IsPalindrome method.
/// </summary>
[Test]
public void TestIsPalindrome() {
string input = "racecar";
bool result = input.IsPalindrome();
Assert.IsTrue(result);
// Test code and assertions explained in code.
}
/// <summary>
/// Tests the CountLetters method.
/// </summary>
[Test]
public void TestCountLetters() {
string input = "hello world!";
int expected = 10;
int result = input.CountLetters();
Assert.That(result, Is.EqualTo(expected));
// Test code and assertions explained in code.
}
/// <summary>
/// Tests the RemoveDuplicateCharacters method.
/// </summary>
[Test]
public void TestRemoveDuplicateCharacters() {
string input = "hello world!";
string expected = "helo wrd!";
string result = input.RemoveDuplicateCharacters();
Assert.That(result, Is.EqualTo(expected));
// Test code and assertions explained in code.
}
/// <summary>
/// Tests the ToCamelCase method.
/// </summary>
[Test]
public void TestConvertToCamelCase() {
string input = "hello_world";
string expected = "helloWorld";
string result = input.ToCamelCase();
Assert.That(result, Is.EqualTo(expected));
// Test code and assertions explained in code.
}
}
}