Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create params to test methods (called by add-in) #59

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified access-add-in/AccUnitLoader.accda
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Public Property Get AccUnitFileNames() As Variant()
ACCUNIT_DLL_FILE, _
"AccessCodeLib.Common.Tools.dll", _
"AccessCodeLib.Common.VBIDETools.dll", _
"AccessCodeLib.AccUnit.VbeAddIn.dll", _
"AccUnit.VbeAddIn.dll", _
"AccessCodeLib.Common.VbeUserControlHost.dll")

End Property
Expand Down
2 changes: 1 addition & 1 deletion access-add-in/source/modules/_config_Application.bas
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Option Compare Text
Option Explicit

'Version number
Private Const APPLICATION_VERSION As String = "0.9.800.240509"
Private Const APPLICATION_VERSION As String = "0.9.800.240510"

Private Const APPLICATION_NAME As String = "ACLib AccUnit Loader"
Private Const APPLICATION_FULLNAME As String = "Access Code Library - AccUnit Loader"
Expand Down
2 changes: 1 addition & 1 deletion access-add-in/source/vcs-options.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Info": {
"AddinVersion": "4.0.35-jp01",
"AddinVersion": "4.0.36-jp",
"AccessVersion": "16.0 32-bit"
},
"Options": {
Expand Down
Binary file modified excel-add-in/AccUnitLoader.xlam
Binary file not shown.
2 changes: 1 addition & 1 deletion excel-add-in/source/AccUnitLoaderConfigProcedures.bas
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Option Compare Text

Public Sub AddAccUnitTlbReference()
RemoveAccUnitTlbReference
CurrentVbProject.References.AddFromFile CurrentAccUnitConfiguration.AccUnitDllPath & "\AccessCodeLib.AccUnit.tlb"
CurrentVbProject.References.AddFromFile CurrentAccUnitConfiguration.AccUnitDllPath & "\" & ACCUNIT_TYPELIB_FILE
End Sub

Public Sub RemoveAccUnitTlbReference()
Expand Down
4 changes: 2 additions & 2 deletions excel-add-in/source/AccUnitLoaderForm.frm
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Private Sub cmdSetAccUnitTlbReferenz_Click()
On Error GoTo HandleErr

AddAccUnitTlbReference
ShowSuccessInfo "AccUnit.tlb reference inserted"
ShowSuccessInfo ACCUNIT_TYPELIB_FILE & " reference inserted"

ExitHere:
Exit Sub
Expand All @@ -277,7 +277,7 @@ Private Sub cmdRemoveAccUnitTlbReferenz_Click()
On Error GoTo HandleErr

RemoveAccUnitTlbReference
ShowSuccessInfo "AccUnit.tlb reference removed"
ShowSuccessInfo ACCUNIT_TYPELIB_FILE & " reference removed"

ExitHere:
Exit Sub
Expand Down
Binary file modified excel-add-in/source/AccUnitLoaderForm.frx
Binary file not shown.
Binary file modified excel-add-in/source/AccUnitUserSettings.frx
Binary file not shown.
8 changes: 4 additions & 4 deletions excel-add-in/source/config_Application.bas
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ Option Explicit
Option Private Module

'Version number
Private Const APPLICATION_VERSION As String = "0.9.700.240403"
Private Const APPLICATION_VERSION As String = "0.9.900.2400512"

Private Const APPLICATION_NAME As String = "ACLib AccUnit Loader"
Private Const APPLICATION_FULLNAME As String = "Access Code Library - AccUnit Loader"
Private Const APPLICATION_TITLE As String = APPLICATION_FULLNAME
Private Const APPLICATION_ICONFILE As String = "ACLib.ico"
Public Const ACCUNIT_TYPELIB_FILE As String = "AccessCodeLib.AccUnit.tlb"
Public Const ACCUNIT_DLL_FILE As String = "AccessCodeLib.AccUnit.dll"
Public Const ACCUNIT_TYPELIB_FILE As String = "AccUnit.tlb"
Public Const ACCUNIT_DLL_FILE As String = "AccUnit.dll"

Private Const APPLICATION_STARTFORMNAME As String = "AccUnitLoaderForm"

Expand All @@ -39,7 +39,7 @@ Private m_Extensions As AppHandler_ExtensionCollection
' <summary>
' Konfigurationseinstellungen initialisieren
' </summary>
' <param name="oCurrentAppHandler">Möglichkeit einer Referenzübergabe, damit nicht CurrentApplication genutzt werden muss</param>
' <param name="oCurrentAppHandler">M�glichkeit einer Referenz�bergabe, damit nicht CurrentApplication genutzt werden muss</param>
' <returns></returns>
' <remarks>
' </remarks>
Expand Down
6 changes: 4 additions & 2 deletions excel-add-in/source/defGlobal_AccUnitLoader.bas
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ Public Property Get AccUnitFileNames() As Variant()
ACCUNIT_TYPELIB_FILE, _
ACCUNIT_DLL_FILE, _
"AccessCodeLib.Common.Tools.dll", _
"AccessCodeLib.Common.VBIDETools.dll")
"AccessCodeLib.Common.VBIDETools.dll", _
"AccUnit.VbeAddIn.dll", _
"AccessCodeLib.Common.VbeUserControlHost.dll")

End Property

Expand All @@ -101,7 +103,7 @@ ExitHere:
Exit Sub

HandleErr:
If AccUnitFileName = "AccessCodeLib.AccUnit.tlb" Then
If AccUnitFileName = ACCUNIT_TYPELIB_FILE Then
Resume Next
End If
Err.Raise Err.Number, Err.Source, Err.Description, Err.HelpFile, Err.HelpContext
Expand Down
4 changes: 2 additions & 2 deletions source/AccUnit/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.8.0")]
[assembly: AssemblyFileVersion("0.9.8.0")]
[assembly: AssemblyVersion("0.9.9.0")]
[assembly: AssemblyFileVersion("0.9.9.0")]
19 changes: 18 additions & 1 deletion source/AccUnit/Tools/TestClassGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using AccessCodeLib.Common.VBIDETools;
using Microsoft.Vbe.Interop;
using System.Collections.Generic;
using System.Linq;

namespace AccessCodeLib.AccUnit.Tools
{
Expand Down Expand Up @@ -28,7 +29,9 @@ public CodeModule NewTestClass(string CodeModuleToTest = null,
return InsertTestMethods(testClassName, methods);
}

private IEnumerable<CodeModuleMember> GetTestCodeModuleMemberFromCodeModule(string codeModuleToTest, string stateUnderTest = null, string expectedBehaviour = null)
private IEnumerable<CodeModuleMember> GetTestCodeModuleMemberFromCodeModule(
string codeModuleToTest, string stateUnderTest = null, string expectedBehaviour = null,
IEnumerable<string> methodsUnderTestFilter = null)
{
var codeModule = new CodeModuleContainer(_vbProject).TryGetCodeModule(codeModuleToTest);
if (codeModule is null)
Expand All @@ -40,6 +43,11 @@ private IEnumerable<CodeModuleMember> GetTestCodeModuleMemberFromCodeModule(stri
var members = codeModulueReader.Members;
var publicMembers = members.FindAll(true);

if (methodsUnderTestFilter != null)
{
publicMembers = publicMembers.Where(m => methodsUnderTestFilter.Contains(m.Name)).ToList();
}

var testCodeModuleMembers = new List<CodeModuleMember>();
foreach (var member in publicMembers)
{
Expand Down Expand Up @@ -94,6 +102,15 @@ public CodeModule InsertTestMethods(string testClass, IEnumerable<CodeModuleMemb
return modules.Generator.Add(vbext_ComponentType.vbext_ct_ClassModule, testClass, sourcecode, true);
}

public CodeModule InsertTestMethods(string codeModuleToTest, string testClass, IEnumerable<string> methodsUnderTest, string stateUnderTest, string expectedBehaviour)
{
if (codeModuleToTest == null )
return InsertTestMethods(testClass, methodsUnderTest, stateUnderTest, expectedBehaviour);

var methods = GetTestCodeModuleMemberFromCodeModule(codeModuleToTest, stateUnderTest, expectedBehaviour, methodsUnderTest);
return InsertTestMethods(testClass, methods);
}

public CodeModule InsertTestMethods(string testClass, IEnumerable<string> methodsUnderTest, string stateUnderTest, string expectedBehaviour)
{
var testCodeGenerator = new TestCodeGenerator();
Expand Down
4 changes: 3 additions & 1 deletion vbe-add-In/AccUnit.VbeAddIn/CommitMethodNameEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ public CommitInsertTestMethodEventArgs(string methodUnderTest, string stateUnder

public class CommitInsertTestMethodsEventArgs : EventArgs
{
public CommitInsertTestMethodsEventArgs(string testClass, IEnumerable<string> methodsUnderTest, string stateUnderTest, string expectedBehaviour)
public CommitInsertTestMethodsEventArgs(string codeModuleToTest, string testClass, IEnumerable<string> methodsUnderTest, string stateUnderTest, string expectedBehaviour)
{
CodeModuleToTest = codeModuleToTest;
TestClass = testClass;
MethodsUnderTest = methodsUnderTest;
StateUnderTest = stateUnderTest;
ExpectedBehaviour = expectedBehaviour;
Cancel = false;
}

public string CodeModuleToTest { get; private set; }
public string TestClass { get; private set; }
public IEnumerable<string> MethodsUnderTest { get; private set; }
public string StateUnderTest { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public IStringValueLabelControlSource MethodNameSyntax
protected virtual void Commit()
{
InsertTestMethods?.Invoke(this,
new CommitInsertTestMethodsEventArgs(TestClassName.Value, MethodNamesToTest, StateTestNamePart.Value, ExpectedTestNamePart.Value));
new CommitInsertTestMethodsEventArgs(CurrentCodeModule.Name, TestClassName.Value, MethodNamesToTest, StateTestNamePart.Value, ExpectedTestNamePart.Value));
}
}
}
4 changes: 2 additions & 2 deletions vbe-add-In/AccUnit.VbeAddIn/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.0.0")]
[assembly: AssemblyFileVersion("0.9.0.0")]
[assembly: AssemblyVersion("0.9.1.0")]
[assembly: AssemblyFileVersion("0.9.1.0")]
2 changes: 1 addition & 1 deletion vbe-add-In/AccUnit.VbeAddIn/VbeIntegrationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ private CodeModule InsertTestMethodsDialogCommitMethodName(object sender, Commit
{
using (new BlockLogger($"{e.TestClass}.{e.MethodsUnderTest}_{e.StateUnderTest}_{e.ExpectedBehaviour}"))
{
return testClassGenerator.InsertTestMethods(e.TestClass, e.MethodsUnderTest, e.StateUnderTest, e.ExpectedBehaviour);
return testClassGenerator.InsertTestMethods(e.CodeModuleToTest, e.TestClass, e.MethodsUnderTest, e.StateUnderTest, e.ExpectedBehaviour);
}
}
catch (Exception ex)
Expand Down