Skip to content

Commit

Permalink
Merge pull request #42 from jpimbert/Issue#39-thisWorkBookOnCreation
Browse files Browse the repository at this point in the history
Fix Issue #39
  • Loading branch information
jpimbert committed Mar 6, 2015
2 parents f159190 + 3a5963f commit b9b8020
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Source/ConfProd/vtkMainFunctions.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 29 additions & 0 deletions Source/ConfTest/vtkCreateProjectTester.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit b9b8020

Please sign in to comment.