@@ -35,99 +35,133 @@ namespace BridgeVs.Build.UnitTest
35
35
[ TestClass ]
36
36
public class MapperBuildTest
37
37
{
38
- private static Assembly _assemblyModel ;
38
+ private const string VsVersion11 = "11.0" ;
39
+ private const string VsVersion12 = "12.0" ;
40
+ private const string VsVersion14 = "14.0" ;
41
+ private const string VsVersion15 = "15.0" ;
42
+
43
+ private static string AssemblyModelLocation => typeof ( CustomType1 ) . Assembly . Location ;
44
+
45
+ private static string TargetAssemblyName ( string vsVersion )
46
+ {
47
+ return VisualizerAssemblyNameFormat . GetTargetVisualizerAssemblyName ( vsVersion , AssemblyModelLocation ) ;
48
+ }
49
+
50
+ private static string TargetInstallationPath ( string vsVersion )
51
+ {
52
+ return VisualStudioOptions . GetVisualizerDestinationFolder ( vsVersion ) ;
53
+ }
54
+
55
+ private static string DotNetAssemblyName ( string vsVersion )
56
+ {
57
+ return VisualizerAssemblyNameFormat . GetDotNetVisualizerName ( vsVersion ) ;
58
+ }
39
59
40
60
[ ClassInitialize ]
41
61
public static void Init ( TestContext context )
42
62
{
43
- _assemblyModel = typeof ( CustomType1 ) . Assembly ;
63
+ if ( ! Directory . Exists ( TargetInstallationPath ( VsVersion11 ) ) )
64
+ {
65
+ Directory . CreateDirectory ( TargetInstallationPath ( VsVersion11 ) ) ;
66
+ }
67
+
68
+ if ( ! Directory . Exists ( TargetInstallationPath ( VsVersion12 ) ) )
69
+ {
70
+ Directory . CreateDirectory ( TargetInstallationPath ( VsVersion12 ) ) ;
71
+ }
44
72
73
+ if ( ! Directory . Exists ( TargetInstallationPath ( VsVersion14 ) ) )
74
+ {
75
+ Directory . CreateDirectory ( TargetInstallationPath ( VsVersion14 ) ) ;
76
+ }
77
+
78
+ if ( ! Directory . Exists ( TargetInstallationPath ( VsVersion15 ) ) )
79
+ {
80
+ Directory . CreateDirectory ( TargetInstallationPath ( VsVersion15 ) ) ;
81
+ }
82
+ }
83
+
84
+ [ ClassCleanup ]
85
+ public static void Cleanup ( )
86
+ {
87
+ //delete the visualizers
88
+ File . Delete ( Path . Combine ( TargetInstallationPath ( VsVersion11 ) , TargetAssemblyName ( VsVersion11 ) ) ) ;
89
+ File . Delete ( Path . Combine ( TargetInstallationPath ( VsVersion12 ) , TargetAssemblyName ( VsVersion12 ) ) ) ;
90
+ File . Delete ( Path . Combine ( TargetInstallationPath ( VsVersion14 ) , TargetAssemblyName ( VsVersion14 ) ) ) ;
91
+ File . Delete ( Path . Combine ( TargetInstallationPath ( VsVersion15 ) , TargetAssemblyName ( VsVersion15 ) ) ) ;
92
+
93
+ File . Delete ( Path . Combine ( TargetInstallationPath ( VsVersion11 ) , DotNetAssemblyName ( VsVersion11 ) ) ) ;
94
+ File . Delete ( Path . Combine ( TargetInstallationPath ( VsVersion12 ) , DotNetAssemblyName ( VsVersion12 ) ) ) ;
95
+ File . Delete ( Path . Combine ( TargetInstallationPath ( VsVersion14 ) , DotNetAssemblyName ( VsVersion14 ) ) ) ;
96
+ File . Delete ( Path . Combine ( TargetInstallationPath ( VsVersion15 ) , DotNetAssemblyName ( VsVersion15 ) ) ) ;
45
97
}
46
98
47
99
[ TestMethod ]
48
100
[ TestCategory ( "UnitTest" ) ]
49
101
public void Mapper_Build_Test_V11_Should_Succeed ( )
50
102
{
51
- const string vsVersion = "11.0" ;
52
- string targetAssemblyName = VisualizerAssemblyNameFormat . GetTargetVisualizerAssemblyName ( vsVersion , _assemblyModel . Location ) ;
53
- string targetInstallationPath = VisualStudioOptions . GetVisualizerDestinationFolder ( vsVersion ) ;
54
-
55
103
MapperBuildTask mapper = new MapperBuildTask
56
104
{
57
- Assembly = _assemblyModel . Location ,
58
- VisualStudioVer = vsVersion
105
+ Assembly = AssemblyModelLocation ,
106
+ VisualStudioVer = VsVersion11
59
107
} ;
60
108
61
109
bool result = mapper . Execute ( ) ;
62
110
63
111
Assert . IsTrue ( result , "Mapper Build Task Execute return false." ) ;
64
- Assert . IsTrue ( File . Exists ( Path . Combine ( targetInstallationPath , targetAssemblyName ) ) ) ;
65
-
66
- File . Delete ( Path . Combine ( targetInstallationPath , targetAssemblyName ) ) ;
112
+ Assert . IsTrue ( File . Exists ( Path . Combine ( TargetInstallationPath ( VsVersion11 ) , TargetAssemblyName ( VsVersion11 ) ) ) , $ "Custom Debugger Visualizer { TargetAssemblyName ( VsVersion11 ) } hasn't been created") ;
113
+ Assert . IsTrue ( File . Exists ( Path . Combine ( TargetInstallationPath ( VsVersion11 ) , DotNetAssemblyName ( VsVersion11 ) ) ) , $ "DotNet Debugger Visualizer { DotNetAssemblyName ( VsVersion11 ) } hasn't been created ") ;
67
114
}
68
115
69
116
[ TestMethod ]
70
117
[ TestCategory ( "UnitTest" ) ]
71
118
public void Mapper_Build_Test_V12_Should_Succeed ( )
72
119
{
73
- const string vsVersion = "12.0" ;
74
- string targetAssemblyName = VisualizerAssemblyNameFormat . GetTargetVisualizerAssemblyName ( vsVersion , _assemblyModel . Location ) ;
75
- string targetInstallationPath = VisualStudioOptions . GetVisualizerDestinationFolder ( vsVersion ) ;
76
-
77
120
MapperBuildTask mapper = new MapperBuildTask
78
121
{
79
- Assembly = _assemblyModel . Location ,
80
- VisualStudioVer = vsVersion
122
+ Assembly = AssemblyModelLocation ,
123
+ VisualStudioVer = VsVersion12
81
124
} ;
82
125
83
126
bool result = mapper . Execute ( ) ;
84
127
85
128
Assert . IsTrue ( result , "Mapper Build Task Execute return false." ) ;
86
- Assert . IsTrue ( File . Exists ( Path . Combine ( targetInstallationPath , targetAssemblyName ) ) ) ;
87
-
88
- File . Delete ( Path . Combine ( targetInstallationPath , targetAssemblyName ) ) ;
129
+ Assert . IsTrue ( File . Exists ( Path . Combine ( TargetInstallationPath ( VsVersion12 ) , TargetAssemblyName ( VsVersion12 ) ) ) , $ "Custom Debugger Visualizer { TargetAssemblyName ( VsVersion12 ) } hasn't been created") ;
130
+ Assert . IsTrue ( File . Exists ( Path . Combine ( TargetInstallationPath ( VsVersion12 ) , DotNetAssemblyName ( VsVersion12 ) ) ) , $ "DotNet Debugger Visualizer { DotNetAssemblyName ( VsVersion12 ) } hasn't been created ") ;
89
131
}
90
132
[ TestMethod ]
91
133
[ TestCategory ( "UnitTest" ) ]
92
134
public void Mapper_Build_Test_V14_Should_Succeed ( )
93
135
{
94
- const string vsVersion = "14.0" ;
95
- string targetAssemblyName = VisualizerAssemblyNameFormat . GetTargetVisualizerAssemblyName ( vsVersion , _assemblyModel . Location ) ;
96
- string targetInstallationPath = VisualStudioOptions . GetVisualizerDestinationFolder ( vsVersion ) ;
97
-
98
136
MapperBuildTask mapper = new MapperBuildTask
99
137
{
100
- Assembly = _assemblyModel . Location ,
101
- VisualStudioVer = vsVersion
138
+ Assembly = AssemblyModelLocation ,
139
+ VisualStudioVer = VsVersion14
102
140
} ;
103
141
104
142
bool result = mapper . Execute ( ) ;
105
143
106
144
Assert . IsTrue ( result , "Mapper Build Task Execute return false." ) ;
107
- Assert . IsTrue ( File . Exists ( Path . Combine ( targetInstallationPath , targetAssemblyName ) ) ) ;
108
145
109
- File . Delete ( Path . Combine ( targetInstallationPath , targetAssemblyName ) ) ;
146
+ Assert . IsTrue ( File . Exists ( Path . Combine ( TargetInstallationPath ( VsVersion14 ) , TargetAssemblyName ( VsVersion14 ) ) ) , $ "Custom Debugger Visualizer { TargetAssemblyName ( VsVersion14 ) } hasn't been created") ;
147
+ Assert . IsTrue ( File . Exists ( Path . Combine ( TargetInstallationPath ( VsVersion14 ) , DotNetAssemblyName ( VsVersion14 ) ) ) , $ "DotNet Debugger Visualizer { DotNetAssemblyName ( VsVersion14 ) } hasn't been created ") ;
110
148
}
111
149
[ TestMethod ]
112
150
[ TestCategory ( "UnitTest" ) ]
113
151
public void Mapper_Build_Test_V15_Should_Succeed ( )
114
152
{
115
- const string vsVersion = "15.0" ;
116
- string targetAssemblyName = VisualizerAssemblyNameFormat . GetTargetVisualizerAssemblyName ( vsVersion , _assemblyModel . Location ) ;
117
- string targetInstallationPath = VisualStudioOptions . GetVisualizerDestinationFolder ( vsVersion ) ;
118
-
119
153
MapperBuildTask mapper = new MapperBuildTask
120
154
{
121
- Assembly = _assemblyModel . Location ,
122
- VisualStudioVer = vsVersion
155
+ Assembly = AssemblyModelLocation ,
156
+ VisualStudioVer = VsVersion15
123
157
} ;
124
158
125
159
bool result = mapper . Execute ( ) ;
126
160
127
161
Assert . IsTrue ( result , "Mapper Build Task Execute return false." ) ;
128
- Assert . IsTrue ( File . Exists ( Path . Combine ( targetInstallationPath , targetAssemblyName ) ) ) ;
129
162
130
- File . Delete ( Path . Combine ( targetInstallationPath , targetAssemblyName ) ) ;
163
+ Assert . IsTrue ( File . Exists ( Path . Combine ( TargetInstallationPath ( VsVersion15 ) , TargetAssemblyName ( VsVersion15 ) ) ) , $ "Custom Debugger Visualizer { TargetAssemblyName ( VsVersion15 ) } hasn't been created") ;
164
+ Assert . IsTrue ( File . Exists ( Path . Combine ( TargetInstallationPath ( VsVersion15 ) , DotNetAssemblyName ( VsVersion15 ) ) ) , $ "DotNet Debugger Visualizer { DotNetAssemblyName ( VsVersion15 ) } hasn't been created ") ;
131
165
}
132
166
}
133
167
}
0 commit comments