1 // FileSystemTest.cs - NUnit Test Cases for vb module FileSystem
2 // (class Microsoft.VisualBasic.FileSystem)
4 // Rafael Teixeira (rafaelteixeirabr@hotmail.com)
10 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using NUnit
.Framework
;
35 using Microsoft
.VisualBasic
;
37 namespace MonoTests
.Microsoft
.VisualBasic
41 public class FileSystemTest
: Assertion
{
45 public void GetReady()
47 oldDir
= Environment
.CurrentDirectory
;
54 Environment
.CurrentDirectory
= oldDir
;
60 [ExpectedException (typeof(ArgumentException
))]
61 public void ChDirArg1()
63 FileSystem
.ChDir ("");
67 [ExpectedException (typeof(FileNotFoundException
))]
68 public void ChDirArg2()
70 FileSystem
.ChDir ("z:\\home\rob");
74 public void TestChDir()
76 // change the current dir to parent dir
77 DirectoryInfo parent
= Directory
.GetParent (Environment
.CurrentDirectory
);
78 FileSystem
.ChDir (parent
.FullName
);
79 AssertEquals ("CHDIR#01", parent
.FullName
, Environment
.CurrentDirectory
);
83 [ExpectedException (typeof(FileNotFoundException
))]
84 public void ChDriveArgs1()
86 FileSystem
.ChDir ("z:\\home\rob");
90 public void TestChDrive()
92 string[] drives
= Directory
.GetLogicalDrives ();
94 foreach (string drive
in drives
) {
95 // skip diskdrive, if no disk is present it fails.
96 if (drive
.ToLower()[0] == 'a')
98 FileSystem
.ChDrive (drive
);
99 Assert ("ChDrive#01", Environment
.CurrentDirectory
.StartsWith (drive
));
104 public void TestCurDir()
106 string dir
= FileSystem
.CurDir ();
107 AssertEquals ("CurDir#01", Environment
.CurrentDirectory
, dir
);
111 [ExpectedException(typeof(ArgumentException))]
112 public void TestDir() {
114 Fail ("Calling as the first thing the parameterless overload of Dir didn't throw an exception");
118 public void TestDirWithSourceFile() {
119 AssertEquals("Didn't found the source file with pattern './Microsoft.VisualBasic/FileSystem.cs'",
121 FileSystem.Dir("./Microsoft.VisualBasic/FileSystem.cs", FileAttribute.Normal)) ;