[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 |
|
---|
[221] | 28 | #include "SimpleTestCase.idx"
|
---|
| 29 |
|
---|
[632] | 30 | Imports System
|
---|
| 31 |
|
---|
[468] | 32 | Dim failureCount = 0 As DWord
|
---|
| 33 |
|
---|
[632] | 34 | Sub SetFailureColor()
|
---|
| 35 | Console.BackgroundColor = ConsoleColor.Yellow
|
---|
| 36 | Console.ForegroundColor = ConsoleColor.Black
|
---|
| 37 | End Sub
|
---|
| 38 |
|
---|
[438] | 39 | Sub UnitTest( msg As String, isSuccessful As Boolean )
|
---|
[383] | 40 | Dim resultStr = Nothing As String
|
---|
[222] | 41 | If isSuccessful Then
|
---|
[355] | 42 | resultStr = Ex"OK "
|
---|
[222] | 43 | Else
|
---|
[236] | 44 | resultStr = Ex"FAILURE!"
|
---|
[468] | 45 | failureCount++
|
---|
[222] | 46 | End If
|
---|
[236] | 47 |
|
---|
[355] | 48 | If Not isSuccessful Then
|
---|
[632] | 49 | SetFailureColor()
|
---|
[355] | 50 | End If
|
---|
| 51 |
|
---|
| 52 | Print resultStr; msg
|
---|
| 53 |
|
---|
| 54 | If Not isSuccessful Then
|
---|
[632] | 55 | Console.ResetColor()
|
---|
[355] | 56 | End If
|
---|
[438] | 57 | End Sub
|
---|
[221] | 58 |
|
---|
[438] | 59 | Sub UnitTest( msg As String, test As String, expectation As String)
|
---|
[383] | 60 | If test = expectation Then
|
---|
| 61 | Print Ex"OK "; msg
|
---|
| 62 | Else
|
---|
[632] | 63 | SetFailureColor()
|
---|
[383] | 64 | Print Ex"FAILURE!"; msg
|
---|
[468] | 65 | Print " 期待 = '" + expectation + "'" + " 結果 = '" + test + "'"
|
---|
[632] | 66 | Console.ResetColor()
|
---|
[468] | 67 | failureCount++
|
---|
[383] | 68 | End If
|
---|
[438] | 69 | End Sub
|
---|
[383] | 70 |
|
---|
[465] | 71 | Function GetExclusiveTempDirPath( testCaseName As String ) As String
|
---|
[468] | 72 | Dim tempDir = GetTempDirectory()
|
---|
| 73 | Dim exclusiveTempDirPath = tempDir + testCaseName
|
---|
[465] | 74 |
|
---|
| 75 | If Not System.IO.Directory.Exists( exclusiveTempDirPath ) Then
|
---|
| 76 | ' 無かったら作る
|
---|
| 77 | System.IO.Directory.CreateDirectory( exclusiveTempDirPath )
|
---|
| 78 | End If
|
---|
| 79 |
|
---|
| 80 | Return exclusiveTempDirPath
|
---|
| 81 | End Function
|
---|
| 82 |
|
---|
[468] | 83 | Print "失敗"; failureCount; "個"
|
---|
[457] | 84 | Print "Please Enter key"
|
---|
| 85 | System.Console.ReadLine()
|
---|