Added VB runtime tests
[mono.git] / mcs / class / Microsoft.VisualBasic / Test / standalone / 6786.vb
1   '\r
2   ' Copyright (c) 2002-2003 Mainsoft Corporation.\r
3   '\r
4   ' Permission is hereby granted, free of charge, to any person obtaining a\r
5   ' copy of this software and associated documentation files (the "Software"),\r
6   ' to deal in the Software without restriction, including without limitation\r
7   ' the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
8   ' and/or sell copies of the Software, and to permit persons to whom the\r
9   ' Software is furnished to do so, subject to the following conditions:\r
10   ' \r
11   ' The above copyright notice and this permission notice shall be included in\r
12   ' all copies or substantial portions of the Software.\r
13   ' \r
14   ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
15   ' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
16   ' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
17   ' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
18   ' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r
19   ' FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\r
20   ' DEALINGS IN THE SOFTWARE.\r
21   '
22
23
24 Imports Microsoft.VisualBasic\r
25 \r
26 Public Class TestClass\r
27     Public Function Test() As String\r
28         'If the file specified by FileName doesn't exist, \r
29         'it is created when a file is opened for Append, Binary, Output, or Random modes.\r
30         Dim fn As Integer\r
31         Dim strFileName As String\r
32         Dim strPathName As String\r
33         \r
34         '// make sure all files are closed\r
35         Microsoft.VisualBasic.FileSystem.Reset()\r
36 \r
37 \r
38         strPathName = System.IO.Directory.GetCurrentDirectory() + "\data\"\r
39         strFileName = "6786.txt"\r
40 \r
41         'if this file exists - kill it\r
42         If (strFileName = Dir(strPathName & strFileName)) Then\r
43             Kill(strPathName & strFileName)\r
44         End If\r
45 \r
46         fn = FreeFile()\r
47         FileOpen(fn, strPathName & strFileName, OpenMode.Append)\r
48         FileClose(fn)\r
49         'if created file not exists - return fails\r
50         If (strFileName = Dir(strPathName & strFileName)) Then\r
51             Kill(strPathName & strFileName)\r
52         Else\r
53             Return "failed to create in OpenMode.Append"\r
54         End If\r
55 \r
56         fn = FreeFile()\r
57         FileOpen(fn, strPathName & strFileName, OpenMode.Binary)\r
58         FileClose(fn)\r
59         'if created file not exists - return fails\r
60         If (strFileName = Dir(strPathName & strFileName)) Then\r
61             Kill(strPathName & strFileName)\r
62         Else\r
63             Return "failed to create in OpenMode.Binary"\r
64         End If\r
65 \r
66         fn = FreeFile()\r
67         FileOpen(fn, strPathName & strFileName, OpenMode.Output)\r
68         FileClose(fn)\r
69         'if created file not exists - return fails\r
70         If (strFileName = Dir(strPathName & strFileName)) Then\r
71             Kill(strPathName & strFileName)\r
72         Else\r
73             Return "failed to create in OpenMode.Output"\r
74         End If\r
75 \r
76         fn = FreeFile()\r
77         FileOpen(fn, strPathName & strFileName, OpenMode.Random)\r
78         FileClose(fn)\r
79         'if created file not exists - return fails\r
80         If (strFileName = Dir(strPathName & strFileName)) Then\r
81             Kill(strPathName & strFileName)\r
82         Else\r
83             Return "failed to create in OpenMode.Random"\r
84         End If\r
85 \r
86         Return "success"\r
87 \r
88     End Function\r
89 End Class\r