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
Line 
1' SimpleTestCase.ab
2
3#console
4
5Dim hStdOut = _System_hConsoleOut
6
7Function GetTempDirectory() As String
8' Return System.IO.Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath ) + "\temp\"
9 Return System.IO.Path.GetTempPath()
10End Function
11
12Sub Initialize()
13 ' 初期化関数
14
15 ' 一時ディレクトリを空にしておく
16 Dim tempDir = GetTempDirectory()
17 If System.IO.Directory.Exists( tempDir ) Then
18 Try
19 ' 存在するときは一旦消す
20 System.IO.Directory.Delete( tempDir, True )
21 Catch e As System.IO.IOException
22 OutputDebugString(e.ToString)
23 End Try
24 End If
25 System.IO.Directory.CreateDirectory( tempDir )
26End Sub
27
28'Initialize()
29
30Dim csbi As CONSOLE_SCREEN_BUFFER_INFO
31GetConsoleScreenBufferInfo(hStdOut, csbi)
32
33#include "SimpleTestCase.idx"
34
35Dim failureCount = 0 As DWord
36
37Sub UnitTest( msg As String, isSuccessful As Boolean )
38 Dim resultStr = Nothing As String
39 If isSuccessful Then
40 resultStr = Ex"OK "
41 Else
42 resultStr = Ex"FAILURE!"
43 failureCount++
44 End If
45
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
55End Sub
56
57Sub UnitTest( msg As String, test As String, expectation As String)
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
63 Print " 期待 = '" + expectation + "'" + " 結果 = '" + test + "'"
64 SetConsoleTextAttribute(hStdOut, csbi.wAttributes)
65 failureCount++
66 End If
67End Sub
68
69Function GetExclusiveTempDirPath( testCaseName As String ) As String
70 Dim tempDir = GetTempDirectory()
71 Dim exclusiveTempDirPath = tempDir + testCaseName
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
81Print "失敗"; failureCount; "個"
82Print "Please Enter key"
83System.Console.ReadLine()
Note: See TracBrowser for help on using the repository browser.