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

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

ActiveBasic.Windows.UI.FormsをUIへ移動。UI以下にForms以外置くものが思い浮かばないので。

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