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