1
+ //
2
+ // Copyright (c) Microsoft. All rights reserved.
3
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4
+ //
5
+
6
+ using Microsoft . SqlServer . Management . Smo ;
7
+ using Microsoft . SqlTools . SqlCore . ObjectExplorer . SmoModel ;
8
+ using NUnit . Framework ;
9
+
10
+ namespace Microsoft . SqlTools . ServiceLayer . UnitTests . ObjectExplorer
11
+ {
12
+ public class SmoColumnCustomNodeHelperTests
13
+ {
14
+ [ Test ]
15
+ public void ShouldCalculateTypeLabels ( )
16
+ {
17
+ var cases = new [ ]
18
+ {
19
+ // Numbers
20
+ new { Type = DataType . Int , Label = "int" } ,
21
+ new { Type = DataType . BigInt , Label = "bigint" } ,
22
+ new { Type = DataType . SmallInt , Label = "smallint" } ,
23
+ new { Type = DataType . TinyInt , Label = "tinyint" } ,
24
+ new { Type = DataType . Bit , Label = "bit" } ,
25
+ new { Type = DataType . Decimal ( 10 , 2 ) , Label = "decimal(2,10)" } , // precision then scale is standard, opposite order from the constructor
26
+ new { Type = DataType . Float , Label = "float" } ,
27
+ new { Type = DataType . Real , Label = "real" } ,
28
+ new { Type = DataType . Money , Label = "money" } ,
29
+ new { Type = DataType . SmallMoney , Label = "smallmoney" } ,
30
+
31
+ // Binary types
32
+ new { Type = DataType . Binary ( 10 ) , Label = "binary(10)" } ,
33
+ new { Type = DataType . VarBinary ( 10 ) , Label = "varbinary(10)" } ,
34
+ new { Type = DataType . VarBinaryMax , Label = "varbinary(max)" } ,
35
+
36
+ // String types
37
+ new { Type = DataType . Char ( 10 ) , Label = "char(10)" } ,
38
+ new { Type = DataType . NChar ( 10 ) , Label = "nchar(10)" } ,
39
+ new { Type = DataType . NVarChar ( 10 ) , Label = "nvarchar(10)" } ,
40
+ new { Type = DataType . NVarCharMax , Label = "nvarchar(max)" } ,
41
+ new { Type = DataType . VarChar ( 20 ) , Label = "varchar(20)" } ,
42
+ new { Type = DataType . VarCharMax , Label = "varchar(max)" } ,
43
+
44
+ // Date Types
45
+ new { Type = DataType . DateTime , Label = "datetime" } ,
46
+ new { Type = DataType . Date , Label = "date" } ,
47
+ new { Type = DataType . DateTime2 ( 7 ) , Label = "datetime2(7)" } ,
48
+ new { Type = DataType . DateTimeOffset ( 5 ) , Label = "datetimeoffset(5)" } ,
49
+ new { Type = DataType . Time ( 3 ) , Label = "time(3)" } ,
50
+
51
+ // Specialty types
52
+ new { Type = DataType . Vector ( 17 ) , Label = "vector(17)" } ,
53
+ } ;
54
+
55
+ foreach ( var testCase in cases )
56
+ {
57
+ string label = SmoColumnCustomNodeHelper . GetTypeSpecifierLabel ( testCase . Type , uddts : null ) ;
58
+ Assert . That ( label , Is . EqualTo ( testCase . Label ) , $ "Expected label to be { testCase . Label } ") ;
59
+ }
60
+ }
61
+ }
62
+ }
0 commit comments