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 | Dim prevBackColor = System.Console.BackgroundColor
|
---|
29 | Dim prevForeColor = System.Console.ForegroundColor
|
---|
30 |
|
---|
31 | #include "SimpleTestCase.idx"
|
---|
32 |
|
---|
33 | Imports System
|
---|
34 |
|
---|
35 | Dim failureCount = 0 As DWord
|
---|
36 |
|
---|
37 | Sub SetFailureColor()
|
---|
38 | Console.BackgroundColor = ConsoleColor.Yellow
|
---|
39 | Console.ForegroundColor = ConsoleColor.Black
|
---|
40 | End Sub
|
---|
41 |
|
---|
42 | Sub UnitTest( msg As String, isSuccessful As Boolean )
|
---|
43 | Dim resultStr = Nothing As String
|
---|
44 | If isSuccessful Then
|
---|
45 | resultStr = Ex"OK "
|
---|
46 | Else
|
---|
47 | resultStr = Ex"FAILURE!"
|
---|
48 | failureCount++
|
---|
49 | End If
|
---|
50 |
|
---|
51 | If Not isSuccessful Then
|
---|
52 | SetFailureColor()
|
---|
53 | End If
|
---|
54 |
|
---|
55 | Print resultStr; msg
|
---|
56 |
|
---|
57 | If Not isSuccessful Then
|
---|
58 | Console.ResetColor()
|
---|
59 | End If
|
---|
60 | End Sub
|
---|
61 |
|
---|
62 | Sub UnitTest( msg As String, test As String, expectation As String)
|
---|
63 | If test = expectation Then
|
---|
64 | Print Ex"OK "; msg
|
---|
65 | Else
|
---|
66 | SetFailureColor()
|
---|
67 | Print Ex"FAILURE!"; msg
|
---|
68 | Print " 期待 = '" + expectation + "'" + " 結果 = '" + test + "'"
|
---|
69 | Console.ResetColor()
|
---|
70 | failureCount++
|
---|
71 | End If
|
---|
72 | End Sub
|
---|
73 |
|
---|
74 | Function GetExclusiveTempDirPath( testCaseName As String ) As String
|
---|
75 | Dim tempDir = GetTempDirectory()
|
---|
76 | Dim exclusiveTempDirPath = tempDir + testCaseName
|
---|
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 |
|
---|
86 | Print "失敗"; failureCount; "個"
|
---|
87 | Print "Please Enter key"
|
---|
88 | System.Console.ReadLine()
|
---|