|
| 1 | +VERSION 1.0 CLASS |
| 2 | +BEGIN |
| 3 | + MultiUse = -1 'True |
| 4 | +END |
| 5 | +Attribute VB_Name = "SQLlibDatabaseTests" |
| 6 | +Attribute VB_GlobalNameSpace = False |
| 7 | +Attribute VB_Creatable = False |
| 8 | +Attribute VB_PredeclaredId = False |
| 9 | +Attribute VB_Exposed = False |
| 10 | +Implements iTestCase |
| 11 | +Dim MyDatabase As SQLDatabase |
| 12 | +Dim MyRecordset As New SQLTestRecordset |
| 13 | +Dim MyConnection As New SQLTestConnection |
| 14 | +Dim SimpleInsert As SQLInsert |
| 15 | + |
| 16 | +Sub iTestCase_Setup() |
| 17 | + Set MyDatabase = Create_SQLDatabase() |
| 18 | + |
| 19 | + With MyDatabase |
| 20 | + .DSN = "mydsn" |
| 21 | + .Password = "Pa$$word" |
| 22 | + .Username = "myusername" |
| 23 | + Set .Recordset = MyRecordset |
| 24 | + Set .Connection = MyConnection |
| 25 | + End With |
| 26 | + |
| 27 | + |
| 28 | + Set SimpleInsert = Create_SQLInsert |
| 29 | + With SimpleInsert |
| 30 | + .Table = "users" |
| 31 | + .Fields = Array("id") |
| 32 | + .Values = Array(1) |
| 33 | + End With |
| 34 | +End Sub |
| 35 | + |
| 36 | +Function mssqlTest() |
| 37 | + MyDatabase.DBType = "mssql" |
| 38 | + |
| 39 | + Actual = MyDatabase.InsertGetNewId(SimpleInsert) |
| 40 | + Expected = "SET NOCOUNT ON;INSERT INTO users (id) VALUES (1);SELECT SCOPE_IDENTITY() as somethingunique" |
| 41 | + mssqlTest = AssertEquals(Actual, Expected) |
| 42 | +End Function |
| 43 | + |
| 44 | +Function psqlTest() |
| 45 | + MyDatabase.DBType = "psql" |
| 46 | + |
| 47 | + Actual = MyDatabase.InsertGetNewId(SimpleInsert, "id") |
| 48 | + Expected = "INSERT INTO users (id) VALUES (1) RETURNING id" |
| 49 | + psqlTest = AssertEquals(Actual, Expected) |
| 50 | + |
| 51 | +End Function |
| 52 | + |
| 53 | +Function iTestCase_GetAllTests() |
| 54 | + GetAllTests = Array("mssqlTest", "psqlTest") |
| 55 | +End Function |
0 commit comments