[236] | 1 | ' SimpleTestCase.ab
|
---|
| 2 |
|
---|
[221] | 3 | #console
|
---|
[355] | 4 |
|
---|
| 5 | Dim hStdOut = _System_hConsoleOut
|
---|
| 6 |
|
---|
[468] | 7 | Function GetTempDirectory() As String
|
---|
[545] | 8 | ' Return System.IO.Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath ) + "\temp\"
|
---|
| 9 | Return System.IO.Path.GetTempPath()
|
---|
[468] | 10 | End Function
|
---|
| 11 |
|
---|
[465] | 12 | Sub Initialize()
|
---|
| 13 | ' 初期化関数
|
---|
| 14 |
|
---|
| 15 | ' 一時ディレクトリを空にしておく
|
---|
[468] | 16 | Dim tempDir = GetTempDirectory()
|
---|
[465] | 17 | If System.IO.Directory.Exists( tempDir ) Then
|
---|
[468] | 18 | Try
|
---|
| 19 | ' 存在するときは一旦消す
|
---|
| 20 | System.IO.Directory.Delete( tempDir, True )
|
---|
| 21 | Catch e As System.IO.IOException
|
---|
| 22 | OutputDebugString(e.ToString)
|
---|
| 23 | End Try
|
---|
[465] | 24 | End If
|
---|
| 25 | System.IO.Directory.CreateDirectory( tempDir )
|
---|
| 26 | End Sub
|
---|
| 27 |
|
---|
[545] | 28 | 'Initialize()
|
---|
[465] | 29 |
|
---|
[355] | 30 | Dim csbi As CONSOLE_SCREEN_BUFFER_INFO
|
---|
| 31 | GetConsoleScreenBufferInfo(hStdOut, csbi)
|
---|
| 32 |
|
---|
[221] | 33 | #include "SimpleTestCase.idx"
|
---|
| 34 |
|
---|
[468] | 35 | Dim failureCount = 0 As DWord
|
---|
| 36 |
|
---|
[438] | 37 | Sub UnitTest( msg As String, isSuccessful As Boolean )
|
---|
[383] | 38 | Dim resultStr = Nothing As String
|
---|
[222] | 39 | If isSuccessful Then
|
---|
[355] | 40 | resultStr = Ex"OK "
|
---|
[222] | 41 | Else
|
---|
[236] | 42 | resultStr = Ex"FAILURE!"
|
---|
[468] | 43 | failureCount++
|
---|
[222] | 44 | End If
|
---|
[236] | 45 |
|
---|
[355] | 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
|
---|
[438] | 55 | End Sub
|
---|
[221] | 56 |
|
---|
[438] | 57 | Sub UnitTest( msg As String, test As String, expectation As String)
|
---|
[383] | 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
|
---|
[468] | 63 | Print " 期待 = '" + expectation + "'" + " 結果 = '" + test + "'"
|
---|
[383] | 64 | SetConsoleTextAttribute(hStdOut, csbi.wAttributes)
|
---|
[468] | 65 | failureCount++
|
---|
[383] | 66 | End If
|
---|
[438] | 67 | End Sub
|
---|
[383] | 68 |
|
---|
[465] | 69 | Function GetExclusiveTempDirPath( testCaseName As String ) As String
|
---|
[468] | 70 | Dim tempDir = GetTempDirectory()
|
---|
| 71 | Dim exclusiveTempDirPath = tempDir + testCaseName
|
---|
[465] | 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 |
|
---|
[468] | 81 | Print "失敗"; failureCount; "個"
|
---|
[457] | 82 | Print "Please Enter key"
|
---|
| 83 | System.Console.ReadLine()
|
---|