source: trunk/ab5.0/ablib/TestCase/SimpleTestCase/SimpleTestCase.ab@ 632

Last change on this file since 632 was 632, checked in by イグトランス (egtra), 16 years ago

[627]への対応

File size: 2.0 KB
Line 
1' SimpleTestCase.ab
2
3#console
4
5Function GetTempDirectory() As String
6' Return System.IO.Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath ) + "\temp\"
7 Return System.IO.Path.GetTempPath()
8End Function
9
10Sub 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 )
24End Sub
25
26'Initialize()
27
28Dim prevBackColor = System.Console.BackgroundColor
29Dim prevForeColor = System.Console.ForegroundColor
30
31#include "SimpleTestCase.idx"
32
33Imports System
34
35Dim failureCount = 0 As DWord
36
37Sub SetFailureColor()
38 Console.BackgroundColor = ConsoleColor.Yellow
39 Console.ForegroundColor = ConsoleColor.Black
40End Sub
41
42Sub 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
60End Sub
61
62Sub 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
72End Sub
73
74Function 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
84End Function
85
86Print "失敗"; failureCount; "個"
87Print "Please Enter key"
88System.Console.ReadLine()
Note: See TracBrowser for help on using the repository browser.