source: trunk/TestCase/SimpleTestCase/SimpleTestCase.ab@ 465

Last change on this file since 465 was 465, checked in by dai, 16 years ago

ActiveBasic.Xml.Parserを仮実装。
・SerializeTestのテストケースを追加。
・SimpleTestCaseにおいて、一時ディレクトリを扱えるようにした。
・XmlTestのテストケースを更新。

File size: 1.8 KB
RevLine 
[236]1' SimpleTestCase.ab
2
[221]3#console
[355]4
5Dim hStdOut = _System_hConsoleOut
6
[465]7Sub Initialize()
8 ' 初期化関数
9
10 ' 一時ディレクトリを空にしておく
11 Dim tempDir = System.IO.Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath ) + "\temp"
12 If System.IO.Directory.Exists( tempDir ) Then
13 ' 存在するときは一旦消す
14 System.IO.Directory.Delete( tempDir, True )
15 End If
16 System.IO.Directory.CreateDirectory( tempDir )
17End Sub
18
19Initialize()
20
[355]21Dim csbi As CONSOLE_SCREEN_BUFFER_INFO
22GetConsoleScreenBufferInfo(hStdOut, csbi)
23
[221]24#include "SimpleTestCase.idx"
25
[438]26Sub UnitTest( msg As String, isSuccessful As Boolean )
[383]27 Dim resultStr = Nothing As String
[222]28 If isSuccessful Then
[355]29 resultStr = Ex"OK "
[222]30 Else
[236]31 resultStr = Ex"FAILURE!"
[222]32 End If
[236]33
[355]34 If Not isSuccessful Then
35 SetConsoleTextAttribute(hStdOut, BACKGROUND_RED Or BACKGROUND_GREEN Or BACKGROUND_INTENSITY)
36 End If
37
38 Print resultStr; msg
39
40 If Not isSuccessful Then
41 SetConsoleTextAttribute(hStdOut, csbi.wAttributes)
42 End If
[438]43End Sub
[221]44
[438]45Sub UnitTest( msg As String, test As String, expectation As String)
[383]46 If test = expectation Then
47 Print Ex"OK "; msg
48 Else
49 SetConsoleTextAttribute(hStdOut, BACKGROUND_RED Or BACKGROUND_GREEN Or BACKGROUND_INTENSITY)
50 Print Ex"FAILURE!"; msg
51 Print " test string = '" + test + "'"
52 SetConsoleTextAttribute(hStdOut, csbi.wAttributes)
53 End If
[438]54End Sub
[383]55
[465]56Function GetExclusiveTempDirPath( testCaseName As String ) As String
57 Dim tempDir = System.IO.Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath ) + "\temp"
58 Dim exclusiveTempDirPath = tempDir + "\" + testCaseName
59
60 If Not System.IO.Directory.Exists( exclusiveTempDirPath ) Then
61 ' 無かったら作る
62 System.IO.Directory.CreateDirectory( exclusiveTempDirPath )
63 End If
64
65 Return exclusiveTempDirPath
66End Function
67
[457]68Print "Please Enter key"
69System.Console.ReadLine()
Note: See TracBrowser for help on using the repository browser.