' SimpleTestCase.ab #console Function GetTempDirectory() As String ' Return System.IO.Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath ) + "\temp\" Return System.IO.Path.GetTempPath() End Function Sub Initialize() ' 初期化関数 ' 一時ディレクトリを空にしておく Dim tempDir = GetTempDirectory() If System.IO.Directory.Exists( tempDir ) Then Try ' 存在するときは一旦消す System.IO.Directory.Delete( tempDir, True ) Catch e As System.IO.IOException OutputDebugString(e.ToString) End Try End If System.IO.Directory.CreateDirectory( tempDir ) End Sub 'Initialize() #include "SimpleTestCase.idx" Imports System Dim failureCount = 0 As DWord Sub SetFailureColor() Console.BackgroundColor = ConsoleColor.Yellow Console.ForegroundColor = ConsoleColor.Black End Sub Sub UnitTest( msg As String, isSuccessful As Boolean ) Dim resultStr = Nothing As String If isSuccessful Then resultStr = Ex"OK " Else resultStr = Ex"FAILURE!" failureCount++ End If If Not isSuccessful Then SetFailureColor() End If Print resultStr; msg If Not isSuccessful Then Console.ResetColor() End If End Sub Sub UnitTest( msg As String, test As String, expectation As String) If test = expectation Then Print Ex"OK "; msg Else SetFailureColor() Print Ex"FAILURE!"; msg Print " 期待 = '" + expectation + "'" + " 結果 = '" + test + "'" Console.ResetColor() failureCount++ End If End Sub Function GetExclusiveTempDirPath( testCaseName As String ) As String Dim tempDir = GetTempDirectory() Dim exclusiveTempDirPath = tempDir + testCaseName If Not System.IO.Directory.Exists( exclusiveTempDirPath ) Then ' 無かったら作る System.IO.Directory.CreateDirectory( exclusiveTempDirPath ) End If Return exclusiveTempDirPath End Function Print "失敗"; failureCount; "個" Print "Please Enter key" System.Console.ReadLine()