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