|
2 | 2 | Option Explicit |
3 | 3 | Option Compare Text |
4 | 4 |
|
| 5 | +' Integrierte Erweiterungen |
| 6 | +Private Const EXTENSION_KEY_AccUnitConfiguration As String = "AccUnitConfiguration" |
| 7 | + |
| 8 | +Public Property Get CurrentAccUnitConfiguration() As AccUnitConfiguration |
| 9 | + Set CurrentAccUnitConfiguration = CurrentApplication.Extensions(EXTENSION_KEY_AccUnitConfiguration) |
| 10 | +End Property |
| 11 | + |
5 | 12 | Public Sub AddAccUnitTlbReference() |
6 | 13 | RemoveAccUnitTlbReference |
7 | 14 | CurrentVbProject.References.AddFromFile CurrentAccUnitConfiguration.AccUnitDllPath & "\AccessCodeLib.AccUnit.tlb" |
@@ -97,18 +104,141 @@ Public Sub ExportTestClasses() |
97 | 104 |
|
98 | 105 | End Sub |
99 | 106 |
|
100 | | -Public Sub RemoveTestEnvironment(ByVal RemoveTestModules As Boolean) |
| 107 | +Public Sub RemoveTestEnvironment(ByVal RemoveTestModules As Boolean, Optional ByVal SaveTestModules As Boolean = True) |
101 | 108 |
|
102 | 109 | Dim Configurator As AccUnit.Configurator |
103 | 110 |
|
104 | 111 | With New AccUnitLoaderFactory |
105 | 112 | Set Configurator = .Configurator |
106 | 113 | End With |
107 | 114 |
|
108 | | - Configurator.RemoveTestEnvironment RemoveTestModules, , CurrentVbProject |
| 115 | + Configurator.RemoveTestEnvironment RemoveTestModules, SaveTestModules, CurrentVbProject |
109 | 116 | Set Configurator = Nothing |
110 | 117 |
|
111 | 118 | On Error Resume Next |
112 | 119 | Application.RunCommand acCmdCompileAndSaveAllModules |
113 | 120 |
|
114 | 121 | End Sub |
| 122 | + |
| 123 | + |
| 124 | +Public Property Get AccUnitFileNames() As Variant() |
| 125 | + |
| 126 | + AccUnitFileNames = Array( _ |
| 127 | + ACCUNIT_TYPELIB_FILE, _ |
| 128 | + ACCUNIT_DLL_FILE, _ |
| 129 | + "AccessCodeLib.Common.Tools.dll", _ |
| 130 | + "AccessCodeLib.Common.VBIDETools.dll", _ |
| 131 | + "AccessCodeLib.Common.VBIDETools.XmlSerializers.dll", _ |
| 132 | + "Microsoft.Vbe.Interop.dll") |
| 133 | + ' "Interop.VBA.dll" |
| 134 | +End Property |
| 135 | + |
| 136 | +Public Sub ExportAccUnitFiles(Optional ByVal lBit As Long = 0) |
| 137 | + |
| 138 | + Dim accFileName As Variant |
| 139 | + Dim sBit As String |
| 140 | + Dim DllPath As String |
| 141 | + |
| 142 | +On Error GoTo HandleErr |
| 143 | + |
| 144 | + If lBit = 0 Then |
| 145 | + lBit = GetCurrentAccessBitSystem |
| 146 | + End If |
| 147 | + |
| 148 | + sBit = CStr(lBit) |
| 149 | + DllPath = CurrentAccUnitConfiguration.AccUnitDllPath |
| 150 | + |
| 151 | + With CurrentApplication.Extensions("AppFile") |
| 152 | + For Each accFileName In AccUnitFileNames |
| 153 | + .CreateAppFile accFileName, DllPath & accFileName, "BitInfo", sBit |
| 154 | + Next |
| 155 | + End With |
| 156 | + |
| 157 | +ExitHere: |
| 158 | + Exit Sub |
| 159 | + |
| 160 | +HandleErr: |
| 161 | + If accFileName = "AccessCodeLib.AccUnit.tlb" Then |
| 162 | + Resume Next |
| 163 | + End If |
| 164 | + Err.Raise Err.Number, Err.Source, Err.Description, Err.HelpFile, Err.HelpContext |
| 165 | + |
| 166 | +End Sub |
| 167 | + |
| 168 | +Public Sub ImportAccUnitFiles(Optional ByVal lBit As Long = 0) |
| 169 | + |
| 170 | + Dim accFileName As Variant |
| 171 | + Dim sBit As String |
| 172 | + Dim DllPath As String |
| 173 | + |
| 174 | + If lBit = 0 Then |
| 175 | + lBit = GetCurrentAccessBitSystem |
| 176 | + End If |
| 177 | + |
| 178 | + sBit = CStr(lBit) |
| 179 | + DllPath = CurrentAccUnitConfiguration.AccUnitDllPath |
| 180 | + |
| 181 | + If lBit = 32 Then |
| 182 | + DllPath = Replace(DllPath, "x64", "x86") |
| 183 | + ElseIf lBit = 64 Then |
| 184 | + DllPath = Replace(DllPath, "x86", "x64") |
| 185 | + End If |
| 186 | + |
| 187 | + With CurrentApplication.Extensions("AppFile") |
| 188 | + For Each accFileName In AccUnitFileNames |
| 189 | + .SaveAppFile accFileName, DllPath & accFileName, True, , , "BitInfo", sBit |
| 190 | + Next |
| 191 | + End With |
| 192 | + |
| 193 | +End Sub |
| 194 | + |
| 195 | +Public Function GetCurrentAccessBitSystem() As Long |
| 196 | + |
| 197 | +#If VBA7 Then |
| 198 | +#If Win64 Then |
| 199 | + GetCurrentAccessBitSystem = 64 |
| 200 | +#Else |
| 201 | + GetCurrentAccessBitSystem = 32 |
| 202 | +#End If |
| 203 | +#Else |
| 204 | + GetCurrentAccessBitSystem = 32 |
| 205 | +#End If |
| 206 | + |
| 207 | +End Function |
| 208 | + |
| 209 | +Public Function AutomatedTestRun() As Boolean |
| 210 | + |
| 211 | + Dim Success As Boolean |
| 212 | + Dim TestSummary As AccUnit.ITestSummary |
| 213 | + Dim FailedMessage As String |
| 214 | + |
| 215 | + AddAccUnitTlbReference |
| 216 | + InsertFactoryModule |
| 217 | + ImportTestClasses |
| 218 | + |
| 219 | + SetFocusToImmediateWindow |
| 220 | + |
| 221 | + Set TestSummary = GetAccUnitFactory.TestSuite(LogFile + DebugPrint).AddFromVBProject.Run.Summary |
| 222 | + Success = TestSummary.Success |
| 223 | + |
| 224 | + RemoveTestEnvironment True |
| 225 | + |
| 226 | + If Not Success Then |
| 227 | + FailedMessage = TestSummary.Failed & " of " & TestSummary.Total & " Tests failed" |
| 228 | + Err.Raise vbObjectError + 12, "AccUnitLoader.AutomatedTestRun", FailedMessage |
| 229 | + End If |
| 230 | + |
| 231 | +End Function |
| 232 | + |
| 233 | +Private Sub SetFocusToImmediateWindow() |
| 234 | + Dim VbeWin As VBIDE.Window |
| 235 | + For Each VbeWin In Application.VBE.Windows |
| 236 | + If VbeWin.Type = vbext_wt_Immediate Then |
| 237 | + If Not VbeWin.Visible Then |
| 238 | + VbeWin.Visible = True |
| 239 | + End If |
| 240 | + VbeWin.SetFocus |
| 241 | + Exit Sub |
| 242 | + End If |
| 243 | + Next |
| 244 | +End Sub |
0 commit comments