Skip to content

Commit c6e1653

Browse files
authored
Config settings by add in (#30)
Config AccUnit settings with AccUnit-Loader add-in
1 parent 2dcb7f8 commit c6e1653

40 files changed

+2716
-2340
lines changed

access-add-in/AccUnitLoader.accda

44 KB
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Public Sub {MethodUnderTest}_{StateUnderTest}_{ExpectedBehaviour}({Params})
2+
' Arrange
3+
Err.Raise vbObjectError, "{MethodUnderTest}_{StateUnderTest}_{ExpectedBehaviour}", "Test not implemented"
4+
Const Expected As Variant = "expected value"
5+
Dim Actual As Variant
6+
' Act
7+
Actual = "actual value"
8+
' Assert
9+
Assert.That Actual, Iz.EqualTo(Expected)
10+
End Sub

access-add-in/source/AccUnitConfiguration.cls

Lines changed: 14 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,9 @@ Private Const EXTENSION_KEY As String = "AccUnitConfiguration"
4040
#Const ADODB_EARLYBINDING = 0
4141
'ADODB wird hier über Late binding eingesetzt, da es nur zum Erstellen der Tabelle genutzt wird
4242

43+
Private m_ACLibConfig As ACLibConfiguration
4344

44-
' Grundeinstellungen
45-
Private Const ACLIB_CONFIG_ROOTFOLDERNAME As String = "AccessCodeLibrary"
46-
Private Const ACLIB_CONFIG_DATABASENAME As String = "ACLib_Config"
47-
Private Const ACLIB_CONFIG_TABLEDEFNAME As String = "ACLib_ConfigTable"
48-
49-
Private Const SQL_CONFIG_TABLE_FIELD_PROPNAME As String = "PropName"
50-
Private Const SQL_CONFIG_TABLE_FIELD_PROPVALUE As String = "PropValue"
51-
Private Const SQL_SELECT_PROPERTYVALUE As String = _
52-
"select " & SQL_CONFIG_TABLE_FIELD_PROPNAME & ", " & SQL_CONFIG_TABLE_FIELD_PROPVALUE & _
53-
" From " & ACLIB_CONFIG_TABLEDEFNAME & " where " & SQL_CONFIG_TABLE_FIELD_PROPNAME & " = [?]"
54-
55-
Private Const SQL_CREATETABLE_CONFIGTABLE As String = _
56-
"CREATE TABLE " & ACLIB_CONFIG_TABLEDEFNAME & _
57-
"([PropName] varchar(255) WITH COMPRESSION NOT NULL," & _
58-
" [PropValue] varchar(255) WITH COMPRESSION," & _
59-
" [PropRemarks] text WITH COMPRESSION," & _
60-
" CONSTRAINT PK_" & ACLIB_CONFIG_TABLEDEFNAME & " PRIMARY KEY ([PropName]))"
61-
45+
' Base config
6246
Private Const PROPNAME_ACCUNITDLLPATH As String = "AccUnitDllPath"
6347

6448
' Hilfsvariablen
@@ -115,9 +99,17 @@ End Sub
11599

116100

117101
'---------------------------------------------------------------------------------------
118-
' Ergänzungen für Ereiterung: AccUnitConfiguration
102+
' Ergänzungen für Erweiterung: AccUnitConfiguration
119103
'---------------------------------------------------------------------------------------
120104

105+
106+
Public Property Get ACLibConfig() As ACLibConfiguration
107+
If m_ACLibConfig Is Nothing Then
108+
Set m_ACLibConfig = New ACLibConfiguration
109+
End If
110+
Set ACLibConfig = m_ACLibConfig
111+
End Property
112+
121113
Private Sub GetExtensionPropertyLookup(ByVal PropertyName As String, ByRef ResumeMode As ApplicationHandlerResumeModes, ByRef ResumeMessage As Variant)
122114

123115
ResumeMode = AppResumeMode_Completed
@@ -140,15 +132,15 @@ End Property
140132
Public Property Get AccUnitDllPath() As String
141133

142134
If Len(m_AccUnitDllPath) = 0 Then
143-
m_AccUnitDllPath = GetACLibGlobalProperty(PROPNAME_ACCUNITDLLPATH)
135+
m_AccUnitDllPath = ACLibConfig.GetACLibGlobalProperty(PROPNAME_ACCUNITDLLPATH)
144136
If Len(m_AccUnitDllPath) > 0 Then
145137
If Not DirExists(m_AccUnitDllPath) Then
146138
Err.Raise vbObjectError, "AccUnitConfiguration.AccUnitDllPath", "Das Verzeichnis '" & m_AccUnitDllPath & "' ist nicht vorhanden!"
147139
m_AccUnitDllPath = vbNullString
148140
End If
149141
If VBA.Right$(m_AccUnitDllPath, 1) <> "\" Then
150142
m_AccUnitDllPath = m_AccUnitDllPath & "\"
151-
SetACLibGlobalProperty PROPNAME_ACCUNITDLLPATH, m_AccUnitDllPath
143+
ACLibConfig.SetACLibGlobalProperty PROPNAME_ACCUNITDLLPATH, m_AccUnitDllPath
152144
End If
153145
End If
154146
End If
@@ -169,180 +161,10 @@ Public Property Let AccUnitDllPath(ByVal NewPath As String)
169161
End If
170162
End If
171163
m_AccUnitDllPath = NewPath
172-
SetACLibGlobalProperty PROPNAME_ACCUNITDLLPATH, m_AccUnitDllPath
164+
ACLibConfig.SetACLibGlobalProperty PROPNAME_ACCUNITDLLPATH, m_AccUnitDllPath
173165

174166
End Property
175167

176168
Private Property Get DefaultAccUnitDllPath() As String
177169
DefaultAccUnitDllPath = DefaultAccUnitLibFolder & "\"
178170
End Property
179-
180-
Private Function GetACLibGlobalProperty(ByRef PropertyName As String) As String
181-
182-
Dim rst As DAO.Recordset
183-
Dim SelectSql As String
184-
185-
SelectSql = Replace(SQL_SELECT_PROPERTYVALUE, "[?]", DaoSqlTool.TextToSqlText(PropertyName))
186-
Set rst = ACLibPropertyDb.OpenRecordset(SelectSql)
187-
If Not rst.EOF Then
188-
GetACLibGlobalProperty = Nz(rst.Fields(SQL_CONFIG_TABLE_FIELD_PROPVALUE), vbNullString)
189-
Else
190-
GetACLibGlobalProperty = vbNullString
191-
End If
192-
rst.Close
193-
194-
End Function
195-
196-
Private Function SetACLibGlobalProperty(ByRef PropertyName As String, ByRef NewValue As String) As String
197-
198-
Dim rst As DAO.Recordset
199-
Dim SelectSql As String
200-
201-
SelectSql = Replace(SQL_SELECT_PROPERTYVALUE, "[?]", DaoSqlTool.TextToSqlText(PropertyName))
202-
Set rst = ACLibPropertyDb.OpenRecordset(SelectSql)
203-
If rst.EOF Then
204-
rst.AddNew
205-
rst.Fields(SQL_CONFIG_TABLE_FIELD_PROPNAME).Value = PropertyName
206-
Else
207-
rst.Edit
208-
End If
209-
rst.Fields(SQL_CONFIG_TABLE_FIELD_PROPVALUE).Value = NewValue
210-
rst.Update
211-
rst.Close
212-
213-
End Function
214-
215-
Private Property Get ACLibPropertyDb() As DAO.Database
216-
217-
If m_ACLibPropertyDb Is Nothing Then
218-
If CheckConfigTableDef Then
219-
Set m_ACLibPropertyDb = CodeDb
220-
End If
221-
End If
222-
Set ACLibPropertyDb = m_ACLibPropertyDb
223-
224-
End Property
225-
226-
#If ADODB_EARLYBINDING Then
227-
Private Function CreateConfigTable(ByRef TargetConnection As ADODB.Connection) As Boolean
228-
#Else
229-
Private Function CreateConfigTable(ByRef TargetConnection As Object) As Boolean
230-
#End If
231-
232-
TargetConnection.Execute SQL_CREATETABLE_CONFIGTABLE
233-
CreateConfigTable = True
234-
235-
End Function
236-
237-
238-
Private Function CheckConfigTableDef() As Boolean
239-
240-
Dim db As DAO.Database
241-
Dim tdf As DAO.TableDef
242-
243-
Set db = CodeDb
244-
245-
If Not TableDefExists(ACLIB_CONFIG_TABLEDEFNAME, db) Then
246-
247-
Set tdf = db.CreateTableDef(ACLIB_CONFIG_TABLEDEFNAME)
248-
tdf.Connect = ";Database=" & ACLibConfigDatabaseFile
249-
tdf.SourceTableName = ACLIB_CONFIG_TABLEDEFNAME
250-
db.TableDefs.Append tdf
251-
252-
ElseIf Len(VBA.Dir$(VBA.Mid$(db.TableDefs(ACLIB_CONFIG_TABLEDEFNAME).Connect, VBA.Len(";Database=") + 1))) = 0 Then
253-
254-
With db.TableDefs(ACLIB_CONFIG_TABLEDEFNAME)
255-
.Connect = ";Database=" & ACLibConfigDatabaseFile
256-
.RefreshLink
257-
End With
258-
259-
End If
260-
261-
Set db = Nothing
262-
263-
CheckConfigTableDef = True
264-
265-
End Function
266-
267-
Public Property Get ACLibConfigDirectory() As String
268-
269-
Dim strPath As String
270-
271-
strPath = VBA.Environ("Appdata") & "\" & ACLIB_CONFIG_ROOTFOLDERNAME & "\"
272-
If Len(VBA.Dir$(strPath, vbDirectory)) = 0 Then
273-
VBA.MkDir strPath
274-
End If
275-
276-
ACLibConfigDirectory = strPath
277-
278-
End Property
279-
280-
Private Property Get ACLibConfigDatabaseFile() As String
281-
282-
Dim db As DAO.Database
283-
Dim strDbFile As String
284-
Dim bolCreateConfigTable As Boolean
285-
286-
#If ADODB_EARLYBINDING = 1 Then
287-
Dim cnn As ADODB.Connection
288-
#Else
289-
Dim cnn As Object
290-
#End If
291-
292-
strDbFile = CodeDb.Name
293-
strDbFile = VBA.Mid$(strDbFile, VBA.InStrRev(strDbFile, "."))
294-
If VBA.Left$(strDbFile, 5) = ".accd" Then
295-
strDbFile = ".accdu"
296-
Else
297-
strDbFile = ".mdt"
298-
End If
299-
strDbFile = ACLibConfigDirectory & ACLIB_CONFIG_DATABASENAME & strDbFile
300-
301-
If Len(VBA.Dir$(strDbFile)) = 0 Then
302-
303-
'Datenbank anlegen
304-
If CodeDb.Version = "4.0" Then
305-
Set db = DBEngine.CreateDatabase(strDbFile, dbLangGeneral, dbVersion40)
306-
Else
307-
Set db = DBEngine.CreateDatabase(strDbFile, dbLangGeneral)
308-
End If
309-
db.Close
310-
311-
bolCreateConfigTable = True
312-
313-
Else 'Prüfen ob Config-Tabelle vorhanden ist
314-
315-
Set db = DBEngine.OpenDatabase(strDbFile)
316-
bolCreateConfigTable = Not TableDefExists(ACLIB_CONFIG_TABLEDEFNAME, db)
317-
db.Close
318-
319-
End If
320-
321-
If bolCreateConfigTable Then
322-
'Tabelle erstellen
323-
#If ADODB_EARLYBINDING = 1 Then
324-
Set cnn = New ADODB.Connection
325-
#Else
326-
Set cnn = CreateObject("ADODB.Connection")
327-
#End If
328-
cnn.ConnectionString = VBA.Replace(CodeProject.Connection.ConnectionString, CodeDb.Name, strDbFile)
329-
cnn.Open
330-
CreateConfigTable cnn
331-
cnn.Close
332-
Set cnn = Nothing
333-
End If
334-
335-
ACLibConfigDatabaseFile = strDbFile
336-
337-
End Property
338-
339-
Private Property Get DaoSqlTool()
340-
If m_DaoSqlTools Is Nothing Then
341-
Set m_DaoSqlTools = SqlTools.Clone("\#yyyy-mm-dd\#", "True", "*")
342-
End If
343-
Set DaoSqlTool = m_DaoSqlTools
344-
End Property
345-
346-
Private Sub Class_Terminate()
347-
Set m_DaoSqlTools = Nothing
348-
End Sub
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Attribute VB_Name = "AccUnitLoaderFactoryCall"
2+
'---------------------------------------------------------------------------------------
3+
' Modul: AccUnitLoaderFactoryCall
4+
'---------------------------------------------------------------------------------------
5+
'<codelib>
6+
' <file>%AppFolder%/source/GetAccUnitFactory.bas</file>
7+
' <license>_codelib/license.bas</license>
8+
' <use>%AppFolder%/source/AccUnitLoaderFactory.cls</use>
9+
'</codelib>
10+
'---
11+
Option Compare Database
12+
Option Explicit
13+
14+
Public Function GetAccUnitFactory() As AccUnitLoaderFactory
15+
CheckAccUnitTypeLibFile
16+
Set GetAccUnitFactory = New AccUnitLoaderFactory
17+
End Function
16.7 KB
Binary file not shown.
86.9 KB
Binary file not shown.

access-add-in/source/DebugPrintTestSuite.cls

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ Private Function IAccessTestSuite_Add(ByVal testToAdd As Object) As AccUnit.IAcc
104104
Set IAccessTestSuite_Add = Add(testToAdd)
105105
End Function
106106

107-
Public Function AddByClassName(ByVal className As String) As DebugPrintTestSuite
108-
m_TestSuite.AddByClassName className
107+
Public Function AddByClassName(ByVal ClassName As String) As DebugPrintTestSuite
108+
m_TestSuite.AddByClassName ClassName
109109
Set AddByClassName = Me
110110
End Function
111111

112-
Private Function IAccessTestSuite_AddByClassName(ByVal className As String) As AccUnit.IAccessTestSuite
113-
Set IAccessTestSuite_AddByClassName = AddByClassName(className)
112+
Private Function IAccessTestSuite_AddByClassName(ByVal ClassName As String) As AccUnit.IAccessTestSuite
113+
Set IAccessTestSuite_AddByClassName = AddByClassName(ClassName)
114114
End Function
115115

116116
Public Function AddFromVBProject() As DebugPrintTestSuite

access-add-in/source/_config_Application.bas

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Attribute VB_Name = "_config_Application"
44
'---------------------------------------------------------------------------------------
55
'---------------------------------------------------------------------------------------
66
'<codelib>
7-
' <file>%AppFolder%/source/_config_Application.bas</file>
8-
' <replace>base/_config_Application.bas</replace>
97
' <license>_codelib/license.bas</license>
108
' <use>%AppFolder%/source/defGlobal_AccUnitLoader.bas</use>
119
' <use>base/modApplication.bas</use>
@@ -20,7 +18,7 @@ Option Compare Database
2018
Option Explicit
2119

2220
'Version nummer
23-
Private Const APPLICATION_VERSION As String = "0.9.17.230817"
21+
Private Const APPLICATION_VERSION As String = "0.9.18.231106"
2422

2523
Private Const APPLICATION_NAME As String = "ACLib AccUnit Loader"
2624
Private Const APPLICATION_FULLNAME As String = "Access Code Library - AccUnit Loader"

0 commit comments

Comments
 (0)