(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / Microsoft.VisualBasic / Test / Microsoft.VisualBasic / FileSystemTest.cs
blob19d7a1c308d40dd4652074091290d5533ef4701a
1 // FileSystemTest.cs - NUnit Test Cases for vb module FileSystem
2 // (class Microsoft.VisualBasic.FileSystem)
3 //
4 // Rafael Teixeira (rafaelteixeirabr@hotmail.com)
5 //
6 // (C) Rafael Teixeira
7 //
9 //
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:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
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;
33 using System;
34 using System.IO;
35 using Microsoft.VisualBasic;
37 namespace MonoTests.Microsoft.VisualBasic
40 [TestFixture]
41 public class FileSystemTest : Assertion {
42 string oldDir = "";
44 [SetUp]
45 public void GetReady()
47 oldDir = Environment.CurrentDirectory;
50 [TearDown]
51 public void Clean()
53 // reset dir
54 Environment.CurrentDirectory = oldDir;
57 // ChDir
59 [Test]
60 [ExpectedException (typeof(ArgumentException))]
61 public void ChDirArg1()
63 FileSystem.ChDir ("");
66 [Test]
67 [ExpectedException (typeof(FileNotFoundException))]
68 public void ChDirArg2()
70 FileSystem.ChDir ("z:\\home\rob");
73 [Test]
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);
82 [Test]
83 [ExpectedException (typeof(FileNotFoundException))]
84 public void ChDriveArgs1()
86 FileSystem.ChDir ("z:\\home\rob");
89 [Test]
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')
97 continue;
98 FileSystem.ChDrive (drive);
99 Assert ("ChDrive#01", Environment.CurrentDirectory.StartsWith (drive));
103 [Test]
104 public void TestCurDir()
106 string dir = FileSystem.CurDir ();
107 AssertEquals ("CurDir#01", Environment.CurrentDirectory, dir);
110 [Test]
111 [ExpectedException(typeof(ArgumentException))]
112 public void TestDir() {
113 FileSystem.Dir();
114 Fail ("Calling as the first thing the parameterless overload of Dir didn't throw an exception");
117 [Test]
118 public void TestDirWithSourceFile() {
119 AssertEquals("Didn't found the source file with pattern './Microsoft.VisualBasic/FileSystem.cs'",
120 "FileSystem.cs",
121 FileSystem.Dir("./Microsoft.VisualBasic/FileSystem.cs", FileAttribute.Normal)) ;