• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

luttje / Key2Joy / 6557152774

18 Oct 2023 06:36AM UTC coverage: 52.519% (+39.8%) from 12.718%
6557152774

push

github

web-flow
Adding more tests, fixing bugs in the process (#48)

* Add config manager tests

* legacy config and mapping profile tests (should fix #42)

* remove comment, problem was caused by transfer across appdomain (or to/fro scripting environment)

* Test core functionality #48 + includes minor refactoring to be able to test + added docs

* Add interop tests + implement and test async test utility (refactors away from singletons)

* fix not all tests running in workflow

* config and interop tests

* Refactor and allow mocking global input hook class

* add capture action test

* Make Execute override optional for script only methods

* add dependency injection + refactor and try test gamepad service

* Refactor config singleton to using dependency injection

* add tests for scripting

* add tests for plugin set + fix plugin showing as loaded even if checksum match failed

* fix tests failing because it relied on config exist (I guess the test order was accidentally correct earlier, this means we should really fix cleanup so we catch this sooner)

* refactor docs code + fix wrong enum summary

* refactor docs builder and start testing it a bit

* fix cmd project structure

* ignore designer files in tests

* cleanup and refactor UI code + show latest version in help

* truncate listview action column

* allow user config to minimize app when pressing X (defaults to shut down app) resolves #45

696 of 1757 branches covered (0.0%)

Branch coverage included in aggregate %.

4597 of 4597 new or added lines in 138 files covered. (100.0%)

3619 of 6459 relevant lines covered (56.03%)

17089.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.18
/Support/Key2Joy.Tests/BuildMarkdownDocs/Util/StringExtensionsTests.cs
1
using System;
2
using BuildMarkdownDocs.Util;
3
using Microsoft.VisualStudio.TestTools.UnitTesting;
4

5
namespace Key2Joy.Tests.BuildMarkdownDocs.Util;
6

7
[TestClass]
8
public class StringExtensionsTests
9
{
10
    [TestMethod]
11
    public void FirstCharToUpper_InputIsNull_ThrowsArgumentNullException()
12
    {
13
        string input = null;
1✔
14

15
        Assert.ThrowsException<ArgumentNullException>(input.FirstCharToUpper);
1✔
16
    }
1✔
17

18
    [TestMethod]
19
    public void FirstCharToUpper_InputIsEmpty_ThrowsArgumentException()
20
    {
21
        var input = "";
1✔
22

23
        Assert.ThrowsException<ArgumentException>(input.FirstCharToUpper);
1✔
24
    }
1✔
25

26
    [TestMethod]
27
    public void FirstCharToUpper_InputIsSingleCharacter_ReturnsUppercaseCharacter()
28
    {
29
        var input = "a";
1✔
30

31
        var result = input.FirstCharToUpper();
1✔
32

33
        Assert.AreEqual("A", result);
1✔
34
    }
1✔
35

36
    [TestMethod]
37
    public void FirstCharToUpper_InputIsMixedCase_ReturnsStringWithFirstCharUppercase()
38
    {
39
        var input = "helloWorld";
1✔
40

41
        var result = input.FirstCharToUpper();
1✔
42

43
        Assert.AreEqual("HelloWorld", result);
1✔
44
    }
1✔
45

46
    [TestMethod]
47
    public void FirstCharToUpper_InputIsAlreadyUppercase_ReturnsSameString()
48
    {
49
        var input = "HELLO";
1✔
50

51
        var result = input.FirstCharToUpper();
1✔
52

53
        Assert.AreEqual("HELLO", result);
1✔
54
    }
1✔
55

56
    [TestMethod]
57
    public void FirstCharToUpper_InputWithTrailingWhitespace_ReturnsStringWithFirstCharUppercase()
58
    {
59
        var input = "world   ";
1✔
60

61
        var result = input.FirstCharToUpper();
1✔
62

63
        Assert.AreEqual("World   ", result);
1✔
64
    }
1✔
65

66
    [TestMethod]
67
    public void FirstCharToUpper_InputWithSpecialCharacters_ReturnsStringWithFirstCharUppercase()
68
    {
69
        var input = "@hello#";
1✔
70

71
        var result = input.FirstCharToUpper();
1✔
72

73
        Assert.AreEqual("@hello#", result);
1✔
74
    }
1✔
75

76
    [TestMethod]
77
    public void FirstCharToUpper_InputWithNumbers_ReturnsStringWithFirstCharUppercase()
78
    {
79
        var input = "123abc";
1✔
80

81
        var result = input.FirstCharToUpper();
1✔
82

83
        Assert.AreEqual("123abc", result);
1✔
84
    }
1✔
85

86
    [TestMethod]
87
    public void FirstCharToUpper_ValidInput_CapitalizesFirstCharacter()
88
    {
89
        var input = "hello";
1✔
90
        var expected = "Hello";
1✔
91

92
        var result = input.FirstCharToUpper();
1✔
93

94
        Assert.AreEqual(expected, result);
1✔
95
    }
1✔
96

97
    [TestMethod]
98
    [ExpectedException(typeof(ArgumentNullException))]
99
    public void FirstCharToUpper_NullInput_ThrowsArgumentNullException()
100
    {
101
        string input = null;
1✔
102
        input.FirstCharToUpper();
1✔
103
    }
×
104

105
    [TestMethod]
106
    [ExpectedException(typeof(ArgumentException))]
107
    public void FirstCharToUpper_EmptyString_ThrowsArgumentException()
108
    {
109
        var input = "";
1✔
110
        input.FirstCharToUpper();
1✔
111
    }
×
112

113
    [TestMethod]
114
    public void TrimEachLine_InputIsEmpty_ReturnsEmptyString()
115
    {
116
        var input = "";
1✔
117

118
        var result = input.TrimEachLine();
1✔
119

120
        Assert.AreEqual("", result);
1✔
121
    }
1✔
122

123
    [TestMethod]
124
    public void TrimEachLine_InputHasNoLeadingWhitespace_ReturnsSameString()
125
    {
126
        var input = "Line 1\nLine 2\nLine 3";
1✔
127

128
        var result = input.TrimEachLine();
1✔
129

130
        Assert.AreEqual("Line 1\nLine 2\nLine 3", result);
1✔
131
    }
1✔
132

133
    [TestMethod]
134
    public void TrimEachLine_InputHasLeadingWhitespace_ReturnsStringWithLeadingWhitespaceRemoved()
135
    {
136
        var input = "   Line 1\n   Line 2\n   Line 3";
1✔
137

138
        var result = input.TrimEachLine();
1✔
139

140
        Assert.AreEqual("Line 1\nLine 2\nLine 3", result);
1✔
141
    }
1✔
142

143
    [TestMethod]
144
    public void TrimEachLine_InputHasInternalWhitespace_ReturnsStringWithInternalWhitespaceTrimmed()
145
    {
146
        var input = "   Line 1\n   Line 2\n   Line 3";
1✔
147

148
        var result = input.TrimEachLine();
1✔
149

150
        Assert.AreEqual("Line 1\nLine 2\nLine 3", result);
1✔
151
    }
1✔
152

153
    [TestMethod]
154
    public void TrimEachLine_InputHasSpecialCharacters_ReturnsStringWithSpecialCharacters()
155
    {
156
        var input = "@Line 1\n#Line 2\n$Line 3";
1✔
157

158
        var result = input.TrimEachLine();
1✔
159

160
        Assert.AreEqual("@Line 1\n#Line 2\n$Line 3", result);
1✔
161
    }
1✔
162

163
    [TestMethod]
164
    public void TrimEachLine_InputHasMixedWhitespaceCharacters_ReturnsStringWithWhitespaceTrimmed()
165
    {
166
        var input = "\t   Line 1\n  \t   Line 2\n      Line 3";
1✔
167

168
        var result = input.TrimEachLine();
1✔
169

170
        Assert.AreEqual("Line 1\nLine 2\nLine 3", result);
1✔
171
    }
1✔
172

173
    [TestMethod]
174
    public void TrimEachLine_ValidInput_TrimsStartOfEachLine()
175
    {
176
        var input = "  hello\n  world";
1✔
177
        var expected = "hello\nworld";
1✔
178

179
        var result = input.TrimEachLine();
1✔
180

181
        Assert.AreEqual(expected, result);
1✔
182
    }
1✔
183

184
    [TestMethod]
185
    public void TrimEachLine_NoExtraWhitespaceAtStart_ReturnsSameString()
186
    {
187
        var input = "hello\nworld";
1✔
188
        var expected = input;
1✔
189

190
        var result = input.TrimEachLine();
1✔
191

192
        Assert.AreEqual(expected, result);
1✔
193
    }
1✔
194

195
    [TestMethod]
196
    public void TrimEachLine_OnlyOneWhitespaceAtStart_ReturnsSameString()
197
    {
198
        var input = " hello\n world";
1✔
199
        var expected = input;
1✔
200

201
        var result = input.TrimEachLine();
1✔
202

203
        Assert.AreEqual(expected, result);
1✔
204
    }
1✔
205

206
    [TestMethod]
207
    public void TrimEndEachLine_ValidInput_TrimsEndOfEachLine()
208
    {
209
        var input = "hello  \nworld  ";
1✔
210
        var expected = "hello\nworld";
1✔
211

212
        var result = input.TrimEndEachLine();
1✔
213

214
        Assert.AreEqual(expected, result);
1✔
215
    }
1✔
216

217
    [TestMethod]
218
    public void TrimEndEachLine_NoExtraWhitespaceAtEnd_ReturnsSameString()
219
    {
220
        var input = "hello\nworld";
1✔
221
        var expected = input;
1✔
222

223
        var result = input.TrimEndEachLine();
1✔
224

225
        Assert.AreEqual(expected, result);
1✔
226
    }
1✔
227

228
    [TestMethod]
229
    public void TrimEndEachLine_OnlyNewLineAtEnd_ReturnsSameString()
230
    {
231
        var input = "hello\nworld\n";
1✔
232
        var expected = input;
1✔
233

234
        var result = input.TrimEndEachLine();
1✔
235

236
        Assert.AreEqual(expected, result);
1✔
237
    }
1✔
238

239
    [TestMethod]
240
    public void NormalizeNewlinesToLF_ValidInput_ReplacesWithLF()
241
    {
242
        var input = "hello\r\nworld\nhi\rthere";
1✔
243
        var expected = "hello\nworld\nhi\nthere";
1✔
244

245
        var result = input.NormalizeNewlinesToLF();
1✔
246

247
        Assert.AreEqual(expected, result);
1✔
248
    }
1✔
249

250
    [TestMethod]
251
    public void NormalizeNewlinesToLF_NoCarriageReturn_ReturnsSameString()
252
    {
253
        var input = "hello\nworld";
1✔
254
        var expected = input;
1✔
255

256
        var result = input.NormalizeNewlinesToLF();
1✔
257

258
        Assert.AreEqual(expected, result);
1✔
259
    }
1✔
260

261
    [TestMethod]
262
    public void NormalizeNewlinesToLF_OnlyCarriageReturn_ReplacesWithLF()
263
    {
264
        var input = "hello\rworld";
1✔
265
        var expected = "hello\nworld";
1✔
266

267
        var result = input.NormalizeNewlinesToLF();
1✔
268

269
        Assert.AreEqual(expected, result);
1✔
270
    }
1✔
271
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc