-
Notifications
You must be signed in to change notification settings - Fork 137
/
Copy pathvalidateCSharpNamespace.test.ts
39 lines (33 loc) · 1.86 KB
/
validateCSharpNamespace.test.ts
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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { validateCSharpNamespace } from '../extension.bundle';
suite('validateCSharpNamespace', () => {
test('Valid values', async () => {
assert.equal(validateCSharpNamespace('Company.Function'), undefined);
assert.equal(validateCSharpNamespace('Company_A.Function'), undefined);
assert.equal(validateCSharpNamespace('a.b.c.d.e.f'), undefined);
assert.equal(validateCSharpNamespace('a'), undefined);
assert.equal(validateCSharpNamespace('_a'), undefined);
assert.equal(validateCSharpNamespace('a9'), undefined);
});
test('Invalid - Extra period', () => {
assert.notEqual(validateCSharpNamespace('a.'), undefined);
assert.notEqual(validateCSharpNamespace('.a'), undefined);
assert.notEqual(validateCSharpNamespace('.'), undefined);
});
test('Invalid - Keyword', () => {
assert.notEqual(validateCSharpNamespace('abstract'), undefined);
assert.notEqual(validateCSharpNamespace('a.namespace'), undefined);
});
test('Invalid - Disallowed characters', () => {
// start character must be letter or '_'
assert.notEqual(validateCSharpNamespace('9a'), undefined);
assert.notEqual(validateCSharpNamespace('-a'), undefined);
assert.notEqual(validateCSharpNamespace('Company.Funct*ion'), undefined);
assert.notEqual(validateCSharpNamespace('Company.Funct)ion'), undefined);
assert.notEqual(validateCSharpNamespace('Company.Funct😀ion'), undefined);
});
});