From 3a5963f33861fe6b0145be7007885a2296a9e454 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Imbert Date: Fri, 6 Mar 2015 06:48:15 +0100 Subject: [PATCH] Add a test for thisWorkbook export/import and fix the issue : - Add thisWorkbook exportation test in vtkCreateProjectTester - Add thisWorkbook importation test in vtkCreateProjectTester - Add thisWorkbook in the DEV configuration in new projects 493 Unit Tests OK in 198,55 seconds --- Source/ConfProd/vtkMainFunctions.bas | 8 ++++++ Source/ConfTest/vtkCreateProjectTester.cls | 29 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/Source/ConfProd/vtkMainFunctions.bas b/Source/ConfProd/vtkMainFunctions.bas index 262afc2..2b49cde 100644 --- a/Source/ConfProd/vtkMainFunctions.bas +++ b/Source/ConfProd/vtkMainFunctions.bas @@ -99,6 +99,14 @@ Public Function vtkCreateProject(path As String, name As String, Optional displa ' Insert the BeforeSave handler in the newly created project vtkAddBeforeSaveHandlerInDEVWorkbook Wb:=wb, projectName:=project.projectName, confName:=project.projectDEVName + ' Declare the BeforeSave handler in the new project configuration + Dim module As VBComponent, nm As Integer, nc As Integer, moduleName As String, cm As vtkConfigurationManager + Set cm = vtkConfigurationManagerForProject(project.projectName) + nc = cm.getConfigurationNumber(project.projectDEVName) + moduleName = "thisWorkbook" + Set module = Wb.VBProject.VBComponents(moduleName) + nm = cm.addModule(moduleName) + cm.setModulePathWithNumber path:="Source\ConfTest\" & module.name & ".cls", numModule:=nm, numConfiguration:=nc ' Save configured and updated project for test Wb.Save diff --git a/Source/ConfTest/vtkCreateProjectTester.cls b/Source/ConfTest/vtkCreateProjectTester.cls index 84b04b1..1c27fd4 100644 --- a/Source/ConfTest/vtkCreateProjectTester.cls +++ b/Source/ConfTest/vtkCreateProjectTester.cls @@ -237,6 +237,31 @@ Test_VBAUnitModulesImportation_Error: mAssert.Should False, "No error have to be raised during project creation (Err=" & Err.Number & ": " & Err.Description & ")" End Sub +Public Sub Test_ThisWorkbookExportation() + ' Verify that the ThisWorkbook Excel Object is exported from a new VBAToolkit project + Dim returnValue As Long, fso As New FileSystemObject + + returnValue = vtkCreateProject(path:=VBAToolKit.vtkTestPath, name:=vtkTestProjectName, displayError:=False) + + mAssert.Should fso.FileExists(VBAToolKit.vtkTestPath & "\" & vtkTestProjectName & "\" & "Source\ConfTest\" & "ThisWorkbook.cls"), "ThisWorkBook Excel Object have to be exported" +End Sub + +Public Sub Test_ThisWorkbookImportation() + ' Verify that the ThisWorkbook Excel Object is imported in the new VBAToolKit project + Dim returnValue As Long, fso As New FileSystemObject + + returnValue = vtkCreateProject(path:=VBAToolKit.vtkTestPath, name:=vtkTestProjectName, displayError:=False) + + + On Error GoTo Test_VBAUnitModulesImportation_Error + mAssert.Should Not Workbooks(vtkTestProjectName & "_DEV.xlsm").VBProject.VBComponents("ThisWorkbook") Is Nothing, "ThisWorkbook Excel Object have to be imported" + On Error GoTo 0 + Exit Sub + +Test_VBAUnitModulesImportation_Error: + mAssert.Should False, "No error have to be raised during project creation (Err=" & Err.Number & ": " & Err.Description & ")" +End Sub + Public Sub Test_vtkCreateProject_correctPathGitFolderIsCreated() Dim fso As New FileSystemObject @@ -337,6 +362,8 @@ Private Function ITest_Suite() As TestSuite ITest_Suite.AddTest ITest_Manager.ClassName, "TestReferencesOfDeliveryWorkbookWasActivated" ITest_Suite.AddTest ITest_Manager.ClassName, "Test_VBAUnitModulesExportation" ITest_Suite.AddTest ITest_Manager.ClassName, "Test_VBAUnitModulesImportation" + ITest_Suite.AddTest ITest_Manager.ClassName, "Test_ThisWorkbookExportation" + ITest_Suite.AddTest ITest_Manager.ClassName, "Test_ThisWorkbookImportation" ITest_Suite.AddTest ITest_Manager.ClassName, "Test_vtkCreateProject_correctPathGitFolderIsCreated" ITest_Suite.AddTest ITest_Manager.ClassName, "Test_vtkCreateProject_handlerAddedInDEVWorkbook_modulesAreExported" ITest_Suite.AddTest ITest_Manager.ClassName, "Test_vtkCreateProject_handlerAddedInDEVWorkbook_xmlIsCreated" @@ -358,6 +385,8 @@ Private Sub ITestCase_RunTest() Case "TestReferencesOfDeliveryWorkbookWasActivated": TestReferencesOfDeliveryWorkbookWasActivated Case "Test_VBAUnitModulesExportation": Test_VBAUnitModulesExportation Case "Test_VBAUnitModulesImportation": Test_VBAUnitModulesImportation + Case "Test_ThisWorkbookExportation": Test_ThisWorkbookExportation + Case "Test_ThisWorkbookImportation": Test_ThisWorkbookImportation Case "Test_vtkCreateProject_correctPathGitFolderIsCreated": Test_vtkCreateProject_correctPathGitFolderIsCreated Case "Test_vtkCreateProject_handlerAddedInDEVWorkbook_modulesAreExported": Test_vtkCreateProject_handlerAddedInDEVWorkbook_modulesAreExported Case "Test_vtkCreateProject_handlerAddedInDEVWorkbook_xmlIsCreated": Test_vtkCreateProject_handlerAddedInDEVWorkbook_xmlIsCreated