test_methods.bas 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Option Compare Database
  2. Public Const ADDIN_NAME = "OpenAccess.accda"
  3. Private Sub setUp_tests()
  4. Dim tmp_path, oa_path As String
  5. tmp_path = CurrentProject.path
  6. oa_path = tmp_path & "\" & ADDIN_NAME
  7. Do Until Dir(oa_path) <> ""
  8. If Len(tmp_path) = 0 Then
  9. Debug.Print "setUp_tests - Unable to find " & ADDIN_NAME & " in the parents directory"
  10. Exit Sub
  11. End If
  12. tmp_path = parDir(tmp_path)
  13. oa_path = tmp_path & "\" & ADDIN_NAME
  14. Loop
  15. On Error Resume Next
  16. Access.References.AddFromFile (oa_path)
  17. DoEvents
  18. If Err.Number = 32813 Then
  19. 'already added
  20. Else
  21. Debug.Print "setUp_tests - Error while loading " & ADDIN_NAME & " as a reference"
  22. End If
  23. End Sub
  24. Public Function test_export()
  25. 'run an OpenAccess export on itself
  26. setUp_tests
  27. Dim result As Integer
  28. result = Application.Run("silent_export")
  29. Err.Number = result
  30. Application.Quit
  31. End Function
  32. Public Function test_import()
  33. 'run an OpenAccess import on itself
  34. setUp_tests
  35. Dim result As Integer
  36. result = Application.Run("silent_import")
  37. Err.Number = result
  38. Application.Quit
  39. End Function
  40. Private Function parDir(ByVal path As String) As String
  41. parDir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(path)
  42. End Function