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

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

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

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