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

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

文字列比較のテストを3引数版UnitTestの呼出に変更

File size: 1.9 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
28#include "SimpleTestCase.idx"
29
30Imports System
31
32Dim failureCount = 0 As DWord
33
34Sub SetFailureColor()
35 Console.BackgroundColor = ConsoleColor.Yellow
36 Console.ForegroundColor = ConsoleColor.Black
37End Sub
38
39Sub UnitTest( msg As String, isSuccessful As Boolean )
40 Dim resultStr = Nothing As String
41 If isSuccessful Then
42 resultStr = Ex"OK "
43 Else
44 resultStr = Ex"FAILURE!"
45 failureCount++
46 End If
47
48 If Not isSuccessful Then
49 SetFailureColor()
50 End If
51
52 Print resultStr; msg
53
54 If Not isSuccessful Then
55 Console.ResetColor()
56 End If
57End Sub
58
59Sub UnitTest( msg As String, test As String, expectation As String)
60 If test = expectation Then
61 Print Ex"OK "; msg
62 Else
63 SetFailureColor()
64 Print Ex"FAILURE!"; msg
65 Print " 期待 = '" + expectation + "'" + " 結果 = '" + test + "'"
66 Console.ResetColor()
67 failureCount++
68 End If
69End Sub
70
71Function GetExclusiveTempDirPath( testCaseName As String ) As String
72 Dim tempDir = GetTempDirectory()
73 Dim exclusiveTempDirPath = tempDir + testCaseName
74
75 If Not System.IO.Directory.Exists( exclusiveTempDirPath ) Then
76 ' 無かったら作る
77 System.IO.Directory.CreateDirectory( exclusiveTempDirPath )
78 End If
79
80 Return exclusiveTempDirPath
81End Function
82
83Print "失敗"; failureCount; "個"
84Print "Please Enter key"
85System.Console.ReadLine()
Note: See TracBrowser for help on using the repository browser.