| 1 | ' SimpleTestCase.ab
|
|---|
| 2 |
|
|---|
| 3 | #console
|
|---|
| 4 |
|
|---|
| 5 | Dim hStdOut = _System_hConsoleOut
|
|---|
| 6 |
|
|---|
| 7 | Function GetTempDirectory() As String
|
|---|
| 8 | Return System.IO.Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath ) + "\temp\"
|
|---|
| 9 | ' Return System.IO.Path.GetTempPath()
|
|---|
| 10 | End Function
|
|---|
| 11 |
|
|---|
| 12 | Sub Initialize()
|
|---|
| 13 | ' 初期化関数
|
|---|
| 14 |
|
|---|
| 15 | ' 一時ディレクトリを空にしておく
|
|---|
| 16 | Dim tempDir = GetTempDirectory()
|
|---|
| 17 | If System.IO.Directory.Exists( tempDir ) Then
|
|---|
| 18 | Try
|
|---|
| 19 | ' 存在するときは一旦消す
|
|---|
| 20 | System.IO.Directory.Delete( tempDir, True )
|
|---|
| 21 | Catch e As System.IO.IOException
|
|---|
| 22 | OutputDebugString(e.ToString)
|
|---|
| 23 | End Try
|
|---|
| 24 | End If
|
|---|
| 25 | System.IO.Directory.CreateDirectory( tempDir )
|
|---|
| 26 | End Sub
|
|---|
| 27 |
|
|---|
| 28 | Initialize()
|
|---|
| 29 |
|
|---|
| 30 | Dim csbi As CONSOLE_SCREEN_BUFFER_INFO
|
|---|
| 31 | GetConsoleScreenBufferInfo(hStdOut, csbi)
|
|---|
| 32 |
|
|---|
| 33 | #include "SimpleTestCase.idx"
|
|---|
| 34 |
|
|---|
| 35 | Dim failureCount = 0 As DWord
|
|---|
| 36 |
|
|---|
| 37 | Sub UnitTest( msg As String, isSuccessful As Boolean )
|
|---|
| 38 | Dim resultStr = Nothing As String
|
|---|
| 39 | If isSuccessful Then
|
|---|
| 40 | resultStr = Ex"OK "
|
|---|
| 41 | Else
|
|---|
| 42 | resultStr = Ex"FAILURE!"
|
|---|
| 43 | failureCount++
|
|---|
| 44 | End If
|
|---|
| 45 |
|
|---|
| 46 | If Not isSuccessful Then
|
|---|
| 47 | SetConsoleTextAttribute(hStdOut, BACKGROUND_RED Or BACKGROUND_GREEN Or BACKGROUND_INTENSITY)
|
|---|
| 48 | End If
|
|---|
| 49 |
|
|---|
| 50 | Print resultStr; msg
|
|---|
| 51 |
|
|---|
| 52 | If Not isSuccessful Then
|
|---|
| 53 | SetConsoleTextAttribute(hStdOut, csbi.wAttributes)
|
|---|
| 54 | End If
|
|---|
| 55 | End Sub
|
|---|
| 56 |
|
|---|
| 57 | Sub UnitTest( msg As String, test As String, expectation As String)
|
|---|
| 58 | If test = expectation Then
|
|---|
| 59 | Print Ex"OK "; msg
|
|---|
| 60 | Else
|
|---|
| 61 | SetConsoleTextAttribute(hStdOut, BACKGROUND_RED Or BACKGROUND_GREEN Or BACKGROUND_INTENSITY)
|
|---|
| 62 | Print Ex"FAILURE!"; msg
|
|---|
| 63 | Print " 期待 = '" + expectation + "'" + " 結果 = '" + test + "'"
|
|---|
| 64 | SetConsoleTextAttribute(hStdOut, csbi.wAttributes)
|
|---|
| 65 | failureCount++
|
|---|
| 66 | End If
|
|---|
| 67 | End Sub
|
|---|
| 68 |
|
|---|
| 69 | Function GetExclusiveTempDirPath( testCaseName As String ) As String
|
|---|
| 70 | Dim tempDir = GetTempDirectory()
|
|---|
| 71 | Dim exclusiveTempDirPath = tempDir + testCaseName
|
|---|
| 72 |
|
|---|
| 73 | If Not System.IO.Directory.Exists( exclusiveTempDirPath ) Then
|
|---|
| 74 | ' 無かったら作る
|
|---|
| 75 | System.IO.Directory.CreateDirectory( exclusiveTempDirPath )
|
|---|
| 76 | End If
|
|---|
| 77 |
|
|---|
| 78 | Return exclusiveTempDirPath
|
|---|
| 79 | End Function
|
|---|
| 80 |
|
|---|
| 81 | Print "失敗"; failureCount; "個"
|
|---|
| 82 | Print "Please Enter key"
|
|---|
| 83 | System.Console.ReadLine()
|
|---|