@everyonesoftware/common 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/outputs/chunk-AY3YWKOM.js +7741 -0
  2. package/outputs/chunk-AY3YWKOM.js.map +1 -0
  3. package/outputs/sources.cjs +9007 -0
  4. package/outputs/sources.cjs.map +1 -0
  5. package/outputs/sources.d.cts +4082 -0
  6. package/outputs/sources.d.ts +4082 -0
  7. package/outputs/sources.js +1370 -0
  8. package/outputs/sources.js.map +1 -0
  9. package/outputs/tests.cjs +17208 -0
  10. package/outputs/tests.cjs.map +1 -0
  11. package/outputs/tests.d.cts +3 -0
  12. package/outputs/tests.d.ts +3 -0
  13. package/outputs/tests.js +9798 -0
  14. package/outputs/tests.js.map +1 -0
  15. package/package.json +6 -1
  16. package/.c8rc.json +0 -12
  17. package/.github/workflows/publish.yml +0 -54
  18. package/.mocharc.json +0 -9
  19. package/sources/assertMessageParameters.ts +0 -22
  20. package/sources/asyncIterator.ts +0 -437
  21. package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +0 -48
  22. package/sources/asyncResult.ts +0 -95
  23. package/sources/basicDisposable.ts +0 -57
  24. package/sources/byteList.ts +0 -202
  25. package/sources/byteListStream.ts +0 -121
  26. package/sources/byteReadStream.ts +0 -24
  27. package/sources/byteWriteStream.ts +0 -16
  28. package/sources/bytes.ts +0 -25
  29. package/sources/characterList.ts +0 -195
  30. package/sources/characterListStream.ts +0 -151
  31. package/sources/characterReadStream.ts +0 -81
  32. package/sources/characterReadStreamIterator.ts +0 -128
  33. package/sources/characterWriteStream.ts +0 -45
  34. package/sources/commandLineParameter.ts +0 -45
  35. package/sources/commandLineParameters.ts +0 -21
  36. package/sources/comparable.ts +0 -144
  37. package/sources/comparer.ts +0 -133
  38. package/sources/comparison.ts +0 -20
  39. package/sources/concatenateIterable.ts +0 -119
  40. package/sources/concatenateIterator.ts +0 -165
  41. package/sources/condition.ts +0 -329
  42. package/sources/currentProcess.ts +0 -158
  43. package/sources/dateTime.ts +0 -130
  44. package/sources/depthFirstSearch.ts +0 -230
  45. package/sources/disposable.ts +0 -31
  46. package/sources/emptyError.ts +0 -10
  47. package/sources/english.ts +0 -45
  48. package/sources/equalFunctions.ts +0 -123
  49. package/sources/fetchHttpClient.ts +0 -89
  50. package/sources/fetchHttpResponse.ts +0 -106
  51. package/sources/flatMapIterable.ts +0 -104
  52. package/sources/flatMapIterator.ts +0 -152
  53. package/sources/generator.ts +0 -251
  54. package/sources/httpClient.ts +0 -36
  55. package/sources/httpHeader.ts +0 -37
  56. package/sources/httpHeaders.ts +0 -216
  57. package/sources/httpIncomingRequest.ts +0 -30
  58. package/sources/httpIncomingResponse.ts +0 -19
  59. package/sources/httpMethod.ts +0 -164
  60. package/sources/httpOutgoingRequest.ts +0 -119
  61. package/sources/httpOutgoingResponse.ts +0 -113
  62. package/sources/httpServer.ts +0 -34
  63. package/sources/inMemoryCharacterWriteStream.ts +0 -78
  64. package/sources/index.ts +0 -101
  65. package/sources/iterable.ts +0 -345
  66. package/sources/iterator.ts +0 -481
  67. package/sources/iteratorToJavascriptIteratorAdapter.ts +0 -48
  68. package/sources/javascript.ts +0 -59
  69. package/sources/javascriptArrayList.ts +0 -175
  70. package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +0 -124
  71. package/sources/javascriptIteratorToIteratorAdapter.ts +0 -133
  72. package/sources/javascriptMapMap.ts +0 -143
  73. package/sources/javascriptSetSet.ts +0 -134
  74. package/sources/list.ts +0 -330
  75. package/sources/listQueue.ts +0 -62
  76. package/sources/listStack.ts +0 -62
  77. package/sources/luxonDateTime.ts +0 -109
  78. package/sources/map.ts +0 -302
  79. package/sources/mapAsyncIterator.ts +0 -141
  80. package/sources/mapIterable.ts +0 -105
  81. package/sources/mapIterator.ts +0 -145
  82. package/sources/mutableCondition.ts +0 -451
  83. package/sources/mutableHttpHeaders.ts +0 -204
  84. package/sources/mutableMap.ts +0 -292
  85. package/sources/network.ts +0 -18
  86. package/sources/node.ts +0 -37
  87. package/sources/nodeJSCharacterWriteStream.ts +0 -42
  88. package/sources/nodeJSHttpIncomingRequest.ts +0 -132
  89. package/sources/nodeJSHttpServer.ts +0 -134
  90. package/sources/notFoundError.ts +0 -12
  91. package/sources/postCondition.ts +0 -284
  92. package/sources/postConditionError.ts +0 -12
  93. package/sources/preCondition.ts +0 -284
  94. package/sources/preConditionError.ts +0 -12
  95. package/sources/promiseAsyncResult.ts +0 -174
  96. package/sources/property.ts +0 -63
  97. package/sources/queue.ts +0 -49
  98. package/sources/realNetwork.ts +0 -28
  99. package/sources/recreationDotGovClient.ts +0 -259
  100. package/sources/searchControl.ts +0 -42
  101. package/sources/set.ts +0 -244
  102. package/sources/skipAsyncIterator.ts +0 -145
  103. package/sources/skipIterator.ts +0 -155
  104. package/sources/stack.ts +0 -48
  105. package/sources/stringComparer.ts +0 -33
  106. package/sources/stringIterator.ts +0 -149
  107. package/sources/strings.ts +0 -322
  108. package/sources/syncResult.ts +0 -300
  109. package/sources/takeAsyncIterator.ts +0 -141
  110. package/sources/takeIterator.ts +0 -151
  111. package/sources/toStringFunctions.ts +0 -185
  112. package/sources/types.ts +0 -371
  113. package/sources/whereAsyncIterator.ts +0 -143
  114. package/sources/whereIterable.ts +0 -108
  115. package/sources/whereIterator.ts +0 -157
  116. package/sources/wonderlandTrailClient.ts +0 -1503
  117. package/tests/assertTest.ts +0 -113
  118. package/tests/assertTestTests.ts +0 -75
  119. package/tests/basicTestSkip.ts +0 -51
  120. package/tests/byteListStreamTests.ts +0 -390
  121. package/tests/byteListTests.ts +0 -27
  122. package/tests/bytesTests.ts +0 -43
  123. package/tests/characterListStreamTests.ts +0 -391
  124. package/tests/characterListTests.ts +0 -250
  125. package/tests/characterWriteStreamTests.ts +0 -12
  126. package/tests/comparerTests.ts +0 -92
  127. package/tests/conditionTests.ts +0 -877
  128. package/tests/consoleTestRunner.ts +0 -404
  129. package/tests/consoleTestRunnerTests.ts +0 -651
  130. package/tests/dateTimeTests.ts +0 -30
  131. package/tests/depthFirstSearchTests.ts +0 -106
  132. package/tests/disposableTests.ts +0 -121
  133. package/tests/englishTests.ts +0 -103
  134. package/tests/equalFunctionsTests.ts +0 -223
  135. package/tests/failedTest.ts +0 -43
  136. package/tests/fetchHttpClientTests.ts +0 -33
  137. package/tests/generatorTests.ts +0 -86
  138. package/tests/httpClientTests.ts +0 -18
  139. package/tests/inMemoryCharacterWriteStreamTests.ts +0 -117
  140. package/tests/iterableTests.ts +0 -141
  141. package/tests/iteratorTests.ts +0 -1086
  142. package/tests/javascriptMapMapTests.ts +0 -21
  143. package/tests/listTests.ts +0 -338
  144. package/tests/mapIteratorTests.ts +0 -55
  145. package/tests/mapTests.ts +0 -104
  146. package/tests/mutableConditionTests.ts +0 -273
  147. package/tests/mutableMapTests.ts +0 -154
  148. package/tests/nodeJSHttpServerTests.ts +0 -75
  149. package/tests/notFoundErrorTests.ts +0 -24
  150. package/tests/postConditionErrorTests.ts +0 -24
  151. package/tests/preConditionErrorTests.ts +0 -24
  152. package/tests/promiseAsyncResultTests.ts +0 -688
  153. package/tests/propertyTests.ts +0 -63
  154. package/tests/queueTests.ts +0 -29
  155. package/tests/recreationDotGovClientTests.ts +0 -191
  156. package/tests/setTests.ts +0 -140
  157. package/tests/skippedTest.ts +0 -39
  158. package/tests/stackTests.ts +0 -66
  159. package/tests/stringComparerTests.ts +0 -60
  160. package/tests/stringIteratorTests.ts +0 -156
  161. package/tests/stringsTests.ts +0 -516
  162. package/tests/syncResultTests.ts +0 -1251
  163. package/tests/test.ts +0 -228
  164. package/tests/testAction.ts +0 -75
  165. package/tests/testActionTests.ts +0 -93
  166. package/tests/testFailureTests.ts +0 -12
  167. package/tests/testRunner.ts +0 -267
  168. package/tests/testRunnerTests.ts +0 -895
  169. package/tests/testSkip.ts +0 -34
  170. package/tests/tests.ts +0 -103
  171. package/tests/toStringFunctionsTests.ts +0 -55
  172. package/tests/typesTests.ts +0 -257
  173. package/tests/whereIteratorTests.ts +0 -77
  174. package/tests/wonderlandTrailClientTests.ts +0 -452
  175. package/tsconfig.json +0 -20
  176. package/tsup.config.ts +0 -13
@@ -1,273 +0,0 @@
1
-
2
-
3
- import { EqualFunctions } from "../sources/equalFunctions";
4
- import { MutableCondition } from "../sources/mutableCondition";
5
- import { PreConditionError } from "../sources/preConditionError";
6
- import { join } from "../sources/strings";
7
- import { ToStringFunctions } from "../sources/toStringFunctions";
8
- import { isNumber, isString } from "../sources/types";
9
- import { Test } from "./test";
10
- import { TestRunner } from "./testRunner";
11
-
12
- export function test(runner: TestRunner): void
13
- {
14
- runner.testFile("mutableCondition.ts", () =>
15
- {
16
- runner.testType("MutableCondition", () =>
17
- {
18
- runner.testFunction("create()", (test: Test) =>
19
- {
20
- const mc: MutableCondition = MutableCondition.create();
21
- test.assertNotUndefinedAndNotNull(mc);
22
- });
23
-
24
- runner.testFunction("setToStringFunctions()", () =>
25
- {
26
- function setToStringFunctionsErrorTest(testName: string, toStringFunctions: ToStringFunctions, expected: Error): void
27
- {
28
- runner.test(testName, (test: Test) =>
29
- {
30
- const mc: MutableCondition = MutableCondition.create();
31
- test.assertThrows(() => mc.setToStringFunctions(toStringFunctions), expected);
32
- });
33
- }
34
-
35
- setToStringFunctionsErrorTest("with undefined", undefined!, new PreConditionError(
36
- "Expression: toStringFunctions",
37
- "Expected: not undefined and not null",
38
- "Actual: undefined",
39
- ));
40
- setToStringFunctionsErrorTest("with null", null!, new PreConditionError(
41
- "Expression: toStringFunctions",
42
- "Expected: not undefined and not null",
43
- "Actual: null",
44
- ));
45
-
46
- runner.test("with valid value", (test: Test) =>
47
- {
48
- const mc: MutableCondition = MutableCondition.create();
49
- test.assertEqual(`"hello"`, mc.toValueString("hello"));
50
-
51
- mc.setToStringFunctions(
52
- ToStringFunctions.create()
53
- .add(isString, (value: string) => `---${value}---`),
54
- );
55
- test.assertEqual(`---hello---`, mc.toValueString("hello"));
56
- });
57
- });
58
-
59
- runner.testFunction("setEqualFunctions()", () =>
60
- {
61
- function setEqualFunctionsErrorTest(testName: string, equalFunctions: EqualFunctions, expected: Error): void
62
- {
63
- runner.test(testName, (test: Test) =>
64
- {
65
- const mc: MutableCondition = MutableCondition.create();
66
- test.assertThrows(() => mc.setEqualFunctions(equalFunctions), expected);
67
- });
68
- }
69
-
70
- setEqualFunctionsErrorTest("with undefined", undefined!, new PreConditionError(
71
- "Expression: equalFunctions",
72
- "Expected: not undefined and not null",
73
- "Actual: undefined",
74
- ));
75
- setEqualFunctionsErrorTest("with null", null!, new PreConditionError(
76
- "Expression: equalFunctions",
77
- "Expected: not undefined and not null",
78
- "Actual: null",
79
- ));
80
-
81
- runner.test("with valid value", (test: Test) =>
82
- {
83
- const mc: MutableCondition = MutableCondition.create();
84
- test.assertFalse(mc.areEqual(3, 5));
85
- test.assertFalse(mc.areEqual(3, 4));
86
- test.assertTrue(mc.areEqual(4, 4));
87
-
88
- mc.setEqualFunctions(
89
- EqualFunctions.create()
90
- .add((left: unknown, right: unknown) =>
91
- {
92
- return isNumber(left) && isNumber(right)
93
- ? left % 2 === right % 2
94
- : undefined;
95
- })
96
- )
97
-
98
- test.assertTrue(mc.areEqual(3, 5));
99
- test.assertFalse(mc.areEqual(3, 4));
100
- test.assertTrue(mc.areEqual(4, 4));
101
- });
102
- });
103
-
104
- runner.testFunction("setCreateErrorFunction()", () =>
105
- {
106
- function setCreateErrorFunctionErrorTest(testName: string, createErrorFunction: ((message: string) => Error), expected: Error): void
107
- {
108
- runner.test(testName, (test: Test) =>
109
- {
110
- const mc: MutableCondition = MutableCondition.create();
111
- test.assertThrows(() => mc.setCreateErrorFunction(createErrorFunction), expected);
112
- });
113
- }
114
-
115
- setCreateErrorFunctionErrorTest("with undefined", undefined!, new PreConditionError(
116
- "Expression: createErrorFunction",
117
- "Expected: not undefined and not null",
118
- "Actual: undefined",
119
- ));
120
- setCreateErrorFunctionErrorTest("with null", null!, new PreConditionError(
121
- "Expression: createErrorFunction",
122
- "Expected: not undefined and not null",
123
- "Actual: null",
124
- ));
125
-
126
- runner.test("with valid function", (test: Test) =>
127
- {
128
- const mc: MutableCondition = MutableCondition.create();
129
- test.assertThrows(() => mc.assertEqual(1, 2));
130
-
131
- mc.setCreateErrorFunction((message: string) =>
132
- {
133
- return Error(`fake '${message}' fake`);
134
- });
135
-
136
- mc.setEqualFunctions(
137
- EqualFunctions.create()
138
- .add((left: unknown, right: unknown) =>
139
- {
140
- return isNumber(left) && isNumber(right)
141
- ? left % 2 === right % 2
142
- : undefined;
143
- })
144
- )
145
-
146
- test.assertTrue(mc.areEqual(3, 5));
147
- test.assertFalse(mc.areEqual(3, 4));
148
- test.assertTrue(mc.areEqual(4, 4));
149
- });
150
- });
151
-
152
- runner.testFunction("assertUndefined()", () =>
153
- {
154
- runner.test("with undefined", (test: Test) =>
155
- {
156
- const mc: MutableCondition = MutableCondition.create();
157
- mc.assertUndefined(undefined);
158
- });
159
-
160
- function assertUndefinedErrorTest(value: unknown, expected: Error): void
161
- {
162
- runner.test(`with ${runner.toString(value)}`, (test: Test) =>
163
- {
164
- const mc: MutableCondition = MutableCondition.create();
165
- test.assertThrows(() => mc.assertUndefined(value), expected);
166
- });
167
- }
168
-
169
- assertUndefinedErrorTest(null, new Error(join("\n", [
170
- "Expected: undefined",
171
- "Actual: null",
172
- ])));
173
- assertUndefinedErrorTest(false, new Error(join("\n", [
174
- "Expected: undefined",
175
- "Actual: false",
176
- ])));
177
- assertUndefinedErrorTest("abc", new Error(join("\n", [
178
- "Expected: undefined",
179
- "Actual: \"abc\"",
180
- ])));
181
- });
182
-
183
- runner.testFunction("assertNotUndefined()", () =>
184
- {
185
- runner.test("with undefined", (test: Test) =>
186
- {
187
- const mc: MutableCondition = MutableCondition.create();
188
- test.assertThrows(
189
- () => mc.assertNotUndefined(undefined),
190
- new Error(join("\n", [
191
- "Expected: not undefined",
192
- "Actual: undefined",
193
- ])),
194
- );
195
- });
196
-
197
- function assertNotUndefinedTest(value: unknown): void
198
- {
199
- runner.test(`with ${runner.toString(value)}`, (test: Test) =>
200
- {
201
- const mc: MutableCondition = MutableCondition.create();
202
- mc.assertNotUndefined(value);
203
- });
204
- }
205
-
206
- assertNotUndefinedTest(null);
207
- assertNotUndefinedTest("");
208
- assertNotUndefinedTest(false);
209
- });
210
-
211
- runner.testFunction("areEqual()", () =>
212
- {
213
- function areEqualTest(left: unknown, right: unknown, expected: boolean): void
214
- {
215
- runner.test(`with ${runner.andList([left, right])}`, (test: Test) =>
216
- {
217
- const mc: MutableCondition = MutableCondition.create();
218
- test.assertEqual(mc.areEqual(left, right), expected);
219
- });
220
- }
221
-
222
- areEqualTest(undefined, undefined, true);
223
- areEqualTest(5, 5, true);
224
- areEqualTest(true, true, true);
225
- areEqualTest({}, {}, true);
226
-
227
- areEqualTest(undefined, "", false);
228
- areEqualTest(1, 2, false);
229
- areEqualTest(false, true, false);
230
- areEqualTest({a:1}, {a:2}, false);
231
- });
232
-
233
- runner.testFunction("toValueString()", () =>
234
- {
235
- function toValueStringTest(value: unknown, expected: string): void
236
- {
237
- runner.test(`with ${runner.toString(value)}`, (test: Test) =>
238
- {
239
- const mc: MutableCondition = MutableCondition.create();
240
- test.assertEqual(expected, mc.toValueString(value));
241
- });
242
- }
243
-
244
- toValueStringTest(undefined, "undefined");
245
- toValueStringTest(null, "null");
246
- toValueStringTest(0, "0");
247
- toValueStringTest("abc", `"abc"`);
248
- toValueStringTest({}, "{}");
249
- toValueStringTest({a:"a"}, `{"a":"a"}`);
250
- });
251
-
252
- runner.testFunction("createError()", () =>
253
- {
254
- runner.test("with all properties", (test: Test) =>
255
- {
256
- const mc: MutableCondition = MutableCondition.create();
257
- const error: Error = mc.createError({
258
- actual: "fake-actual",
259
- expected: "fake-expected",
260
- expression: "fake-expression",
261
- message: "fake-message",
262
- });
263
- test.assertEqual(error, new Error(join("\n", [
264
- "Message: fake-message",
265
- "Expression: fake-expression",
266
- "Expected: fake-expected",
267
- "Actual: fake-actual",
268
- ])));
269
- });
270
- });
271
- });
272
- });
273
- }
@@ -1,154 +0,0 @@
1
- import { Iterator } from "../sources/iterator";
2
- import { JavascriptIterable } from "../sources/javascript";
3
- import { isMap } from "../sources/map";
4
- import { MutableMap } from "../sources/mutableMap";
5
- import { NotFoundError } from "../sources/notFoundError";
6
- import { mapTests } from "./mapTests";
7
- import { Test } from "./test";
8
- import { TestRunner } from "./testRunner";
9
-
10
- export function test(runner: TestRunner): void
11
- {
12
- runner.testFile("mutableMap.ts", () =>
13
- {
14
- runner.testType("MutableMap<TKey,TValue>", () =>
15
- {
16
- runner.testFunction("create()", (test: Test) =>
17
- {
18
- const map: MutableMap<number,string> = MutableMap.create();
19
- test.assertSame(map.getCount().await(), 0);
20
- });
21
-
22
- mutableMapTests(runner, MutableMap.create);
23
- });
24
- });
25
- }
26
-
27
- export function mutableMapTests(runner: TestRunner, creator: () => MutableMap<number,string>): void
28
- {
29
- runner.testType("MutableMap<TKey,TValue>", () =>
30
- {
31
- mapTests(runner, creator);
32
-
33
- runner.testFunction("creator()", (test: Test) =>
34
- {
35
- test.assertNotUndefinedAndNotNull(creator);
36
-
37
- const map: MutableMap<number,string> = creator();
38
- test.assertNotUndefinedAndNotNull(map);
39
- test.assertEqual(map.getCount().await(), 0);
40
- test.assertTrue(isMap(map));
41
- });
42
-
43
- runner.testFunction("containsKey(TKey)", () =>
44
- {
45
- runner.test("when it doesn't contain the key", (test: Test) =>
46
- {
47
- const map: MutableMap<number,string> = creator();
48
-
49
- test.assertFalse(map.containsKey(50).await());
50
- });
51
-
52
- runner.test("when it contains the key", (test: Test) =>
53
- {
54
- const map: MutableMap<number,string> = creator().set(50, "fifty");
55
-
56
- test.assertTrue(map.containsKey(50).await());
57
- });
58
- });
59
-
60
- runner.testFunction("get(TKey)", () =>
61
- {
62
- runner.test("when it contains the key", (test: Test) =>
63
- {
64
- const map: MutableMap<number,string> = creator().set(1, "one");
65
- test.assertEqual(map.getCount().await(), 1);
66
- test.assertEqual(map.get(1).await(), "one");
67
- test.assertEqual(map.getCount().await(), 1);
68
- });
69
-
70
- runner.test("when it doesn't contain the key", (test: Test) =>
71
- {
72
- const map: MutableMap<number,string> = creator();
73
-
74
- test.assertThrows(() => map.get(1).await(),
75
- new NotFoundError(
76
- "The key 1 was not found in the map."));
77
- test.assertEqual(map.getCount().await(), 0);
78
- });
79
- });
80
-
81
- runner.testFunction("set(TKey,TValue)", () =>
82
- {
83
- function setTest(map: MutableMap<number,string>, key: number, value: string): void
84
- {
85
- runner.test(`with ${runner.andList([map, key, value])}`, (test: Test) =>
86
- {
87
- const setResult: MutableMap<number,string> = map.set(key, value);
88
- test.assertSame(setResult, map);
89
- test.assertSame(map.get(key).await(), value);
90
- });
91
- }
92
-
93
- setTest(creator(), 0, "zero");
94
- setTest(creator(), 1, "1");
95
- setTest(creator(), -1, "negative one");
96
-
97
- setTest(creator(), undefined!, "hello");
98
- setTest(creator(), null!, "oops");
99
- setTest(creator(), 10, undefined!);
100
- setTest(creator(), 11, null!);
101
-
102
- setTest(creator().set(1, "1"), 1, "one");
103
- });
104
-
105
- runner.testFunction("toString()", () =>
106
- {
107
- function toStringTest(map: MutableMap<number,string>, expected: string): void
108
- {
109
- runner.test(`with ${runner.toString(map)}`, (test: Test) =>
110
- {
111
- test.assertEqual(map.toString(), expected);
112
- });
113
- }
114
-
115
- toStringTest(creator(), "{}");
116
- toStringTest(creator().set(1, "one"), `{1:"one"}`);
117
- toStringTest(creator().set(2, "2").set(1, "one"), `{2:"2",1:"one"}`);
118
- });
119
-
120
- runner.testFunction("iterateKeys()", () =>
121
- {
122
- function iterateKeysTests(map: MutableMap<number,string>, expected: JavascriptIterable<number>): void
123
- {
124
- runner.test(`with ${runner.toString(map)}`, async (test: Test) =>
125
- {
126
- const keyIterator: Iterator<number> = map.iterateKeys();
127
- test.assertEqual(await keyIterator.toArray(), [...expected]);
128
- });
129
- }
130
-
131
- iterateKeysTests(creator(), []);
132
- iterateKeysTests(creator().set(5, "five"), [5]);
133
- iterateKeysTests(creator().set(5, "five").set(6, "six"), [5, 6]);
134
- iterateKeysTests(creator().set(5, "5").set(6, "6").set(7, "7"), [5, 6, 7]);
135
- });
136
-
137
- runner.testFunction("iterateValues()", () =>
138
- {
139
- function iterateValuesTests(map: MutableMap<number,string>, expected: JavascriptIterable<string>): void
140
- {
141
- runner.test(`with ${runner.toString(map)}`, async (test: Test) =>
142
- {
143
- const valueIterator: Iterator<string> = map.iterateValues();
144
- test.assertEqual(await valueIterator.toArray(), [...expected]);
145
- });
146
- }
147
-
148
- iterateValuesTests(creator(), []);
149
- iterateValuesTests(creator().set(5, "five"), ["five"]);
150
- iterateValuesTests(creator().set(5, "five").set(6, "six"), ["five", "six"]);
151
- iterateValuesTests(creator().set(5, "5").set(6, "6").set(7, "7"), ["5", "6", "7"]);
152
- });
153
- });
154
- }
@@ -1,75 +0,0 @@
1
- import { FetchHttpClient } from "../sources/fetchHttpClient";
2
- import { FetchHttpIncomingResponse } from "../sources/fetchHttpResponse";
3
- import { NodeJSHttpServer as NodeJSHttpServer } from "../sources/nodeJSHttpServer";
4
- import { PreConditionError } from "../sources/preConditionError";
5
- import { Test } from "./test";
6
- import { TestRunner } from "./testRunner";
7
-
8
- export function test(runner: TestRunner): void
9
- {
10
- runner.testFile("nodeJSHttpServer.ts", () =>
11
- {
12
- runner.testType("NodeJSHttpServer", () =>
13
- {
14
- runner.testFunction("create()", (test: Test) =>
15
- {
16
- const httpServer: NodeJSHttpServer = NodeJSHttpServer.create();
17
- test.assertNotUndefinedAndNotNull(httpServer);
18
- test.assertFalse(httpServer.isDisposed());
19
- test.assertFalse(httpServer.isStarted());
20
- });
21
-
22
- runner.testFunction("dispose()", async (test: Test) =>
23
- {
24
- const httpServer: NodeJSHttpServer = NodeJSHttpServer.create();
25
-
26
- test.assertTrue(await httpServer.dispose());
27
- test.assertTrue(httpServer.isDisposed());
28
- test.assertFalse(httpServer.isStarted());
29
-
30
- for (let i = 0; i < 3; i++)
31
- {
32
- test.assertFalse(await httpServer.dispose());
33
- test.assertTrue(httpServer.isDisposed());
34
- test.assertFalse(httpServer.isStarted());
35
- }
36
- });
37
-
38
- runner.testFunction("start()", () =>
39
- {
40
- runner.test("when disposed", async (test: Test) =>
41
- {
42
- const httpServer: NodeJSHttpServer = NodeJSHttpServer.create();
43
- test.assertTrue(await httpServer.dispose());
44
-
45
- test.assertThrows(() => httpServer.start(3000), new PreConditionError(
46
- "Expression: this.isDisposed()",
47
- "Expected: false",
48
- "Actual: true",
49
- ));
50
- test.assertTrue(httpServer.isDisposed());
51
- test.assertFalse(httpServer.isStarted());
52
- });
53
-
54
- runner.test("simple scenario", async (test: Test) =>
55
- {
56
- const httpServer: NodeJSHttpServer = NodeJSHttpServer.create();
57
-
58
- httpServer.start(3000);
59
- try
60
- {
61
- const httpClient: FetchHttpClient = FetchHttpClient.create();
62
- const response: FetchHttpIncomingResponse = await httpClient.sendGetRequest("http://localhost:3000");
63
-
64
- test.assertNotUndefinedAndNotNull(response);
65
- test.assertEqual(200, response.getStatusCode());
66
- }
67
- finally
68
- {
69
- await httpServer.dispose();
70
- }
71
- });
72
- });
73
- });
74
- });
75
- }
@@ -1,24 +0,0 @@
1
- import { NotFoundError } from "../sources/notFoundError";
2
- import { Test } from "./test";
3
- import { TestRunner } from "./testRunner";
4
-
5
- export function test(runner: TestRunner): void
6
- {
7
- runner.testFile("notFoundError.ts", () =>
8
- {
9
- runner.testType("NotFoundError", () =>
10
- {
11
- runner.testFunction("constructor(...string[])", () =>
12
- {
13
- runner.test("with no arguments", (test: Test) =>
14
- {
15
- const error: NotFoundError = new NotFoundError();
16
- test.assertNotUndefinedAndNotNull(error);
17
- test.assertEqual(error.name, "Error");
18
- test.assertEqual(error.message, "");
19
- test.assertNotUndefinedAndNotNull(error.stack);
20
- });
21
- });
22
- });
23
- });
24
- }
@@ -1,24 +0,0 @@
1
- import { PostConditionError } from "../sources/postConditionError";
2
- import { Test } from "./test";
3
- import { TestRunner } from "./testRunner";
4
-
5
- export function test(runner: TestRunner): void
6
- {
7
- runner.testFile("postConditionError.ts", () =>
8
- {
9
- runner.testType(PostConditionError.name, () =>
10
- {
11
- runner.testFunction("constructor(string|undefined)", () =>
12
- {
13
- runner.test("with no arguments", (test: Test) =>
14
- {
15
- const error: PostConditionError = new PostConditionError();
16
- test.assertNotUndefinedAndNotNull(error);
17
- test.assertEqual(error.name, "Error");
18
- test.assertEqual(error.message, "");
19
- test.assertNotUndefinedAndNotNull(error.stack);
20
- });
21
- });
22
- });
23
- });
24
- }
@@ -1,24 +0,0 @@
1
- import { PreConditionError } from "../sources/preConditionError";
2
- import { Test } from "./test";
3
- import { TestRunner } from "./testRunner";
4
-
5
- export function test(runner: TestRunner): void
6
- {
7
- runner.testFile("preConditionError.ts", () =>
8
- {
9
- runner.testType("PreConditionError", () =>
10
- {
11
- runner.testFunction("constructor(string|undefined)", () =>
12
- {
13
- runner.test("with no arguments", (test: Test) =>
14
- {
15
- const error: PreConditionError = new PreConditionError();
16
- test.assertNotUndefinedAndNotNull(error);
17
- test.assertEqual(error.name, "Error");
18
- test.assertEqual(error.message, "");
19
- test.assertNotUndefinedAndNotNull(error.stack);
20
- });
21
- });
22
- });
23
- });
24
- }