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

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

[627]への対応

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