// TODO: Find out why ArgumentOutOfRange tests does not release directories properly\r
//\r
\r
-using NUnit.Framework;\r
-using System.IO;\r
-using System.Text;\r
using System;\r
+using System.Diagnostics;\r
using System.Globalization;\r
+using System.IO;\r
+using System.Text;\r
using System.Threading;\r
-using System.Diagnostics;\r
\r
-namespace MonoTests.System.IO {\r
+using NUnit.Framework;\r
+\r
+namespace MonoTests.System.IO\r
+{\r
\r
[TestFixture]\r
-public class DirectoryTest : Assertion {\r
- \r
- string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.System.IO.Tests");\r
+public class DirectoryTest\r
+{\r
+ static readonly string TempSubFolder = "MonoTests.System.IO.Tests";\r
+ string TempFolder = Path.Combine (Path.GetTempPath (), TempSubFolder);\r
static readonly char DSC = Path.DirectorySeparatorChar;\r
\r
[SetUp]\r
}\r
\r
[TearDown]\r
- public void TearDown () {\r
+ public void TearDown ()\r
+ {\r
if (Directory.Exists (TempFolder))\r
Directory.Delete (TempFolder, true);\r
}\r
DeleteDirectory (path);\r
try {\r
DirectoryInfo info = Directory.CreateDirectory (path);\r
- AssertEquals ("test#01", true, info.Exists);\r
- AssertEquals ("test#02", ".1", info.Extension);\r
- AssertEquals ("test#03", true, info.FullName.EndsWith ("DirectoryTest.Test.1"));\r
- AssertEquals ("test#04", "DirectoryTest.Test.1", info.Name);\r
+ Assert.IsTrue (info.Exists, "#1");\r
+ Assert.AreEqual (".1", info.Extension, "#2");\r
+ Assert.IsTrue (info.FullName.EndsWith ("DirectoryTest.Test.1"), "#3");\r
+ Assert.AreEqual ("DirectoryTest.Test.1", info.Name, "#4");\r
} finally {\r
- DeleteDirectory (path); \r
+ DeleteDirectory (path);\r
}\r
}\r
\r
+ /* Commented out: a directory named ":" is legal in unix\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
public void CreateDirectoryNotSupportedException ()\r
{\r
DeleteDirectory (":");\r
- DirectoryInfo info = Directory.CreateDirectory (":");\r
+ try {\r
+ DirectoryInfo info = Directory.CreateDirectory (":");\r
+ Assert.Fail ("#1");\r
+ } catch (ArgumentException ex) {\r
+ // The path is not of a legal form\r
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");\r
+ Assert.IsNull (ex.InnerException, "#3");\r
+ Assert.IsNotNull (ex.Message, "#4");\r
+ Assert.IsNull (ex.ParamName, "#5");\r
+ }\r
DeleteDirectory (":");\r
}\r
+ */\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))]\r
- public void CreateDirectoryArgumentNullException ()\r
+ public void CreateDirectory_Path_Null ()\r
{\r
- DirectoryInfo info = Directory.CreateDirectory (null as string); \r
+ try {\r
+ Directory.CreateDirectory (null as string);\r
+ Assert.Fail ("#1");\r
+ } catch (ArgumentNullException ex) {\r
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+ Assert.IsNull (ex.InnerException, "#3");\r
+ Assert.IsNotNull (ex.Message, "#4");\r
+ Assert.AreEqual ("path", ex.ParamName, "#5");\r
+ }\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))]\r
- public void CreateDirectoryArgumentException1 ()\r
+ public void CreateDirectory_Path_Empty ()\r
{\r
- DirectoryInfo info = Directory.CreateDirectory ("");\r
+ try {\r
+ Directory.CreateDirectory (string.Empty);\r
+ Assert.Fail ("#1");\r
+ } catch (ArgumentException ex) {\r
+ // Path cannot be the empty string or all whitespace\r
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");\r
+ Assert.IsNull (ex.InnerException, "#3");\r
+ Assert.IsNotNull (ex.Message, "#4");\r
+ Assert.IsNull (ex.ParamName, "#5");\r
+ }\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))]\r
- public void CreateDirectoryArgumentException2 ()\r
+ public void CreateDirectory_Path_Whitespace ()\r
{\r
- DirectoryInfo info = Directory.CreateDirectory (" "); \r
+ try {\r
+ Directory.CreateDirectory (" ");\r
+ Assert.Fail ("#1");\r
+ } catch (ArgumentException ex) {\r
+ // The path is not of a legal form\r
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");\r
+ Assert.IsNull (ex.InnerException, "#3");\r
+ Assert.IsNotNull (ex.Message, "#4");\r
+ Assert.IsNull (ex.ParamName, "#5");\r
+ }\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))]\r
- public void CreateDirectoryArgumentException3 ()\r
+ public void CreateDirectory_Path_InvalidChars ()\r
{\r
string path = TempFolder + DSC + "DirectoryTest.Test";\r
DeleteDirectory (path);\r
try {\r
- path += Path.InvalidPathChars [0];\r
+ path += '\x00';\r
path += ".2";\r
- DirectoryInfo info = Directory.CreateDirectory (path); \r
+ DirectoryInfo info = Directory.CreateDirectory (path);\r
+ Assert.Fail ("#1");\r
+ } catch (ArgumentException ex) {\r
+ // The path contains illegal characters\r
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");\r
+ Assert.IsNull (ex.InnerException, "#3");\r
+ Assert.IsNotNull (ex.Message, "#4");\r
+ Assert.IsNull (ex.ParamName, "#5");\r
} finally {\r
DeleteDirectory (path);\r
}\r
DirectoryInfo info1 = Directory.CreateDirectory (path);\r
DirectoryInfo info2 = Directory.CreateDirectory (path);\r
\r
- AssertEquals ("test#01", true, info2.Exists);\r
- AssertEquals ("test#02", true, info2.FullName.EndsWith ("DirectoryTest.Test.Exists"));\r
- AssertEquals ("test#03", "DirectoryTest.Test.Exists", info2.Name);\r
+ Assert.IsTrue (info2.Exists, "#1");\r
+ Assert.IsTrue (info2.FullName.EndsWith ("DirectoryTest.Test.Exists"), "#2");\r
+ Assert.AreEqual ("DirectoryTest.Test.Exists", info2.Name, "#3");\r
} finally {\r
- DeleteDirectory (path); \r
+ DeleteDirectory (path);\r
}\r
}\r
\r
fstream.Close();\r
\r
DirectoryInfo dinfo = Directory.CreateDirectory (path);\r
- AssertEquals ("test#01", false, dinfo.Exists);\r
- AssertEquals ("test#02", true, dinfo.FullName.EndsWith ("DirectoryTest.Test.ExistsAsFile"));\r
- AssertEquals ("test#03", "DirectoryTest.Test.ExistsAsFile", dinfo.Name);\r
+#if NET_2_0\r
+ Assert.Fail ("#1");\r
+ } catch (IOException ex) {\r
+ Assert.AreEqual (typeof (IOException), ex.GetType (), "#2");\r
+ // exception message contains the path\r
+ Assert.IsTrue (ex.Message.Contains (path), "#3");\r
+ Assert.IsNull (ex.InnerException, "#4");\r
+#else\r
+ Assert.IsFalse (dinfo.Exists, "#2");\r
+ Assert.IsTrue (dinfo.FullName.EndsWith ("DirectoryTest.Test.ExistsAsFile"), "#3");\r
+ Assert.AreEqual ("DirectoryTest.Test.ExistsAsFile", dinfo.Name, "#4");\r
+#endif\r
} finally {\r
- DeleteDirectory (path); \r
+ DeleteDirectory (path);\r
DeleteFile (path);\r
}\r
}\r
DeleteDirectory (path);\r
try {\r
Directory.CreateDirectory (path);\r
- AssertEquals ("test#01", true, Directory.Exists (path));\r
+ Assert.IsTrue (Directory.Exists (path), "#1");\r
\r
Directory.CreateDirectory (path + DSC + "DirectoryTest.Test.Delete.1.2");\r
- AssertEquals ("test#02", true, Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"));\r
+ Assert.IsTrue (Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"), "#2");\r
\r
Directory.Delete (path + DSC + "DirectoryTest.Test.Delete.1.2");\r
- AssertEquals ("test#03", false, Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"));\r
- AssertEquals ("test#04", true, Directory.Exists (path));\r
+ Assert.IsFalse (Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"), "#3");\r
+ Assert.IsTrue (Directory.Exists (path), "#4");\r
\r
Directory.Delete (path);\r
- AssertEquals ("test#05", false, Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"));\r
- AssertEquals ("test#06", false, Directory.Exists (path)); \r
+ Assert.IsFalse (Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"), "#5");\r
+ Assert.IsFalse (Directory.Exists (path), "#6");\r
\r
Directory.CreateDirectory (path);\r
Directory.CreateDirectory (path + DSC + "DirectoryTest.Test.Delete.1.2");\r
- AssertEquals ("test#07", true, Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"));\r
- AssertEquals ("test#08", true, Directory.Exists (path));\r
+ Assert.IsTrue (Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"), "#7");\r
+ Assert.IsTrue (Directory.Exists (path), "#8");\r
\r
Directory.Delete (path, true);\r
- AssertEquals ("test#09", false, Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"));\r
- AssertEquals ("test#10", false, Directory.Exists (path));\r
+ Assert.IsFalse (Directory.Exists (path + DSC + "DirectoryTest.Test.Delete.1.2"), "#9");\r
+ Assert.IsFalse (Directory.Exists (path), "#10");\r
} finally {\r
DeleteDirectory (path);\r
}\r
[ExpectedException(typeof(ArgumentException))]\r
public void DeleteArgumentException ()\r
{\r
- Directory.Delete (""); \r
+ Directory.Delete (string.Empty);\r
}\r
\r
[Test] \r
[ExpectedException(typeof(ArgumentException))]\r
public void DeleteArgumentException2 ()\r
{\r
- Directory.Delete (" "); \r
+ Directory.Delete (" ");\r
}\r
\r
[Test] \r
[ExpectedException(typeof(ArgumentNullException))]\r
public void DeleteArgumentNullException ()\r
{\r
- Directory.Delete (null as string); \r
+ Directory.Delete (null as string);\r
}\r
\r
[Test] \r
string path = TempFolder + DSC + "DirectoryTest.Test.5";\r
DeleteDirectory (path);\r
\r
- Directory.Delete (path); \r
+ Directory.Delete (path);\r
}\r
\r
[Test] \r
} finally {\r
if (s != null)\r
s.Close ();\r
- DeleteDirectory (path); \r
+ DeleteDirectory (path);\r
};\r
}\r
\r
[Test]\r
- public void Exists ()\r
+ public void DeleteDirectoryOnExistingFileName ()\r
{\r
- AssertEquals ("test#01", false, Directory.Exists (null as string));\r
+ string path = TempFolder + DSC + "DirectoryTest.Test.ExistsAsFile";\r
+ DeleteDirectory (path);\r
+ DeleteFile (path);\r
+ try {\r
+ FileStream fstream = File.Create (path);\r
+ fstream.Close ();\r
+\r
+ Directory.Delete (path);\r
+ Assert.Fail ("#1");\r
+ }\r
+ catch (IOException ex) {\r
+ Assert.AreEqual (typeof (IOException), ex.GetType (), "#2");\r
+ // exception message DOES NOT contains the path\r
+ Assert.IsFalse (ex.Message.IndexOf (path) >= 0, "#3");\r
+ Assert.IsNull (ex.InnerException, "#4");\r
+ }\r
+ finally {\r
+ DeleteDirectory (path);\r
+ DeleteFile (path);\r
+ }\r
}\r
\r
[Test]\r
- [Category("NotDotNet")]\r
- public void ExistsAccessDenied ()\r
+ public void Exists ()\r
{\r
- // bug #78239\r
+ Assert.IsFalse (Directory.Exists (null as string));\r
+ }\r
\r
- if (Path.DirectorySeparatorChar == '\\')\r
+#if !TARGET_JVM // We don't support yet the Process class.\r
+ [Test] // bug #78239\r
+ public void ExistsAccessDenied ()\r
+ {\r
+ if (!RunningOnUnix)\r
return; // this test does not work on Windows.\r
\r
string path = TempFolder + DSC + "ExistsAccessDenied";\r
- Process p;\r
\r
Directory.CreateDirectory (path);\r
- Process.Start ("/bin/chmod", "000 " + path).WaitForExit ();\r
+ Mono.Posix.Syscall.chmod (path, 0);\r
try {\r
- AssertEquals ("#1", false, Directory.Exists(path + DSC + "b"));\r
+ Assert.IsFalse (Directory.Exists(path + DSC + "b"));\r
} finally {\r
- Process.Start ("/bin/chmod", "755 " + path).WaitForExit ();\r
+ Mono.Posix.Syscall.chmod (path, (Mono.Posix.FileMode) 755);\r
Directory.Delete (path);\r
}\r
}\r
+#endif\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))] \r
+ [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM\r
+ [ExpectedException(typeof(ArgumentNullException))]\r
public void GetCreationTimeException1 ()\r
{\r
Directory.GetCreationTime (null as string);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM\r
public void GetCreationTimeException2 ()\r
{\r
- Directory.GetCreationTime ("");\r
+ Directory.GetCreationTime (string.Empty);\r
}\r
\r
[Test]\r
#if !NET_2_0\r
[ExpectedException(typeof(IOException))]\r
#endif\r
+ [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM\r
public void GetCreationTimeException_NonExistingPath ()\r
{\r
string path = TempFolder + DSC + "DirectoryTest.GetCreationTime.1";\r
\r
#if NET_2_0\r
DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();\r
- Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);\r
- Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);\r
- Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);\r
- Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);\r
- Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);\r
- Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);\r
+ Assert.AreEqual (expectedTime.Year, time.Year, "#1");\r
+ Assert.AreEqual (expectedTime.Month, time.Month, "#2");\r
+ Assert.AreEqual (expectedTime.Day, time.Day, "#3");\r
+ Assert.AreEqual (expectedTime.Hour, time.Hour, "#4");\r
+ Assert.AreEqual (expectedTime.Second, time.Second, "#5");\r
+ Assert.AreEqual (expectedTime.Millisecond, time.Millisecond, "#6");\r
#endif\r
} finally {\r
DeleteDirectory (path);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM\r
public void GetCreationTimeException4 ()\r
{\r
Directory.GetCreationTime (" ");\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM\r
public void GetCreationTimeException5 ()\r
{\r
Directory.GetCreationTime (Path.InvalidPathChars [0].ToString ());\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))] \r
+ [ExpectedException(typeof(ArgumentNullException))]\r
+ [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM\r
public void GetCreationTimeUtcException1 ()\r
{\r
Directory.GetCreationTimeUtc (null as string);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM\r
public void GetCreationTimeUtcException2 ()\r
{\r
- Directory.GetCreationTimeUtc ("");\r
+ Directory.GetCreationTimeUtc (string.Empty);\r
}\r
\r
[Test]\r
#if !NET_2_0\r
[ExpectedException (typeof (IOException))]\r
#endif\r
+ [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM\r
public void GetCreationTimeUtc_NonExistingPath ()\r
{\r
string path = TempFolder + DSC + "DirectoryTest.GetCreationTimeUtc.1";\r
DateTime time = Directory.GetCreationTimeUtc (path);\r
\r
#if NET_2_0\r
- Assertion.AssertEquals ("#1", 1601, time.Year);\r
- Assertion.AssertEquals ("#2", 1, time.Month);\r
- Assertion.AssertEquals ("#3", 1, time.Day);\r
- Assertion.AssertEquals ("#4", 0, time.Hour);\r
- Assertion.AssertEquals ("#5", 0, time.Second);\r
- Assertion.AssertEquals ("#6", 0, time.Millisecond);\r
+ Assert.AreEqual (1601, time.Year, "#1");\r
+ Assert.AreEqual (1, time.Month, "#2");\r
+ Assert.AreEqual (1, time.Day, "#3");\r
+ Assert.AreEqual (0, time.Hour, "#4");\r
+ Assert.AreEqual (0, time.Second, "#5");\r
+ Assert.AreEqual (0, time.Millisecond, "#6");\r
#endif\r
} finally {\r
DeleteDirectory (path);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM\r
public void GetCreationTimeUtcException4 ()\r
{\r
Directory.GetCreationTimeUtc (" ");\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetCreationTime not supported for TARGET_JVM\r
public void GetCreationTimeUtcException5 ()\r
{\r
Directory.GetCreationTime (Path.InvalidPathChars [0].ToString ());\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))] \r
- public void GetLastAccessTimeException1 ()\r
+ [ExpectedException(typeof(ArgumentNullException))]\r
+ [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM\r
+ public void GetLastAccessTime_Null ()\r
{\r
Directory.GetLastAccessTime (null as string);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM\r
public void GetLastAccessTimeException2 ()\r
{\r
- Directory.GetLastAccessTime ("");\r
+ Directory.GetLastAccessTime (string.Empty);\r
}\r
\r
[Test]\r
#if !NET_2_0\r
[ExpectedException (typeof (IOException))]\r
#endif\r
+ [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM\r
public void GetLastAccessTime_NonExistingPath ()\r
{\r
string path = TempFolder + DSC + "DirectoryTest.GetLastAccessTime.1";\r
\r
#if NET_2_0\r
DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();\r
- Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);\r
- Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);\r
- Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);\r
- Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);\r
- Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);\r
- Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);\r
+ Assert.AreEqual (expectedTime.Year, time.Year, "#1");\r
+ Assert.AreEqual (expectedTime.Month, time.Month, "#2");\r
+ Assert.AreEqual (expectedTime.Day, time.Day, "#3");\r
+ Assert.AreEqual (expectedTime.Hour, time.Hour, "#4");\r
+ Assert.AreEqual (expectedTime.Second, time.Second, "#5");\r
+ Assert.AreEqual (expectedTime.Millisecond, time.Millisecond, "#6");\r
#endif\r
} finally {\r
DeleteDirectory (path);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM\r
public void GetLastAccessTimeException4 ()\r
{\r
Directory.GetLastAccessTime (" ");\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM\r
public void GetLastAccessTimeException5 ()\r
{\r
Directory.GetLastAccessTime (Path.InvalidPathChars [0].ToString ());\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))] \r
- public void GetLastAccessTimeUtcException1 ()\r
+ [ExpectedException(typeof(ArgumentNullException))]\r
+ [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM\r
+ public void GetLastAccessTimeUtc_Null ()\r
{\r
Directory.GetLastAccessTimeUtc (null as string);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM\r
public void GetLastAccessTimeUtcException2 ()\r
{\r
- Directory.GetLastAccessTimeUtc ("");\r
+ Directory.GetLastAccessTimeUtc (string.Empty);\r
}\r
\r
[Test]\r
#if !NET_2_0\r
[ExpectedException (typeof (IOException))]\r
#endif\r
+ [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM\r
public void GetLastAccessTimeUtc_NonExistingPath ()\r
{\r
string path = TempFolder + DSC + "DirectoryTest.GetLastAccessTimeUtc.1";\r
DateTime time = Directory.GetLastAccessTimeUtc (path);\r
\r
#if NET_2_0\r
- Assertion.AssertEquals ("#1", 1601, time.Year);\r
- Assertion.AssertEquals ("#2", 1, time.Month);\r
- Assertion.AssertEquals ("#3", 1, time.Day);\r
- Assertion.AssertEquals ("#4", 0, time.Hour);\r
- Assertion.AssertEquals ("#5", 0, time.Second);\r
- Assertion.AssertEquals ("#6", 0, time.Millisecond);\r
+ Assert.AreEqual (1601, time.Year, "#1");\r
+ Assert.AreEqual (1, time.Month, "#2");\r
+ Assert.AreEqual (1, time.Day, "#3");\r
+ Assert.AreEqual (0, time.Hour, "#4");\r
+ Assert.AreEqual (0, time.Second, "#5");\r
+ Assert.AreEqual (0, time.Millisecond, "#6");\r
#endif\r
} finally {\r
DeleteDirectory (path);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM\r
public void GetLastAccessTimeUtcException4 ()\r
{\r
Directory.GetLastAccessTimeUtc (" ");\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // GetLastAccessTime not supported for TARGET_JVM\r
public void GetLastAccessTimeUtcException5 ()\r
{\r
Directory.GetLastAccessTimeUtc (Path.InvalidPathChars [0].ToString ());\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))] \r
+ [ExpectedException(typeof(ArgumentNullException))]\r
public void GetLastWriteTimeException1 ()\r
{\r
Directory.GetLastWriteTime (null as string);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
public void GetLastWriteTimeException2 ()\r
{\r
- Directory.GetLastWriteTime ("");\r
+ Directory.GetLastWriteTime (string.Empty);\r
}\r
\r
[Test]\r
\r
#if NET_2_0\r
DateTime expectedTime = (new DateTime (1601, 1, 1)).ToLocalTime ();\r
- Assertion.AssertEquals ("#1", expectedTime.Year, time.Year);\r
- Assertion.AssertEquals ("#2", expectedTime.Month, time.Month);\r
- Assertion.AssertEquals ("#3", expectedTime.Day, time.Day);\r
- Assertion.AssertEquals ("#4", expectedTime.Hour, time.Hour);\r
- Assertion.AssertEquals ("#5", expectedTime.Second, time.Second);\r
- Assertion.AssertEquals ("#6", expectedTime.Millisecond, time.Millisecond);\r
+ Assert.AreEqual (expectedTime.Year, time.Year, "#1");\r
+ Assert.AreEqual (expectedTime.Month, time.Month, "#2");\r
+ Assert.AreEqual (expectedTime.Day, time.Day, "#3");\r
+ Assert.AreEqual (expectedTime.Hour, time.Hour, "#4");\r
+ Assert.AreEqual (expectedTime.Second, time.Second, "#5");\r
+ Assert.AreEqual (expectedTime.Millisecond, time.Millisecond, "#6");\r
#endif\r
} finally {\r
DeleteDirectory (path);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
public void GetLastWriteTimeException4 ()\r
{\r
Directory.GetLastWriteTime (" ");\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
public void GetLastWriteTimeException5 ()\r
{\r
Directory.GetLastWriteTime (Path.InvalidPathChars [0].ToString ());\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))] \r
+ [ExpectedException(typeof(ArgumentNullException))]\r
public void GetLastWriteTimeUtcException1 ()\r
{\r
Directory.GetLastWriteTimeUtc (null as string);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
public void GetLastWriteTimeUtcException2 ()\r
{\r
- Directory.GetLastWriteTimeUtc ("");\r
+ Directory.GetLastWriteTimeUtc (string.Empty);\r
}\r
\r
[Test]\r
DateTime time = Directory.GetLastWriteTimeUtc (path);\r
\r
#if NET_2_0\r
- Assertion.AssertEquals ("#1", 1601, time.Year);\r
- Assertion.AssertEquals ("#2", 1, time.Month);\r
- Assertion.AssertEquals ("#3", 1, time.Day);\r
- Assertion.AssertEquals ("#4", 0, time.Hour);\r
- Assertion.AssertEquals ("#5", 0, time.Second);\r
- Assertion.AssertEquals ("#6", 0, time.Millisecond);\r
+ Assert.AreEqual (1601, time.Year, "#1");\r
+ Assert.AreEqual (1, time.Month, "#2");\r
+ Assert.AreEqual (1, time.Day, "#3");\r
+ Assert.AreEqual (0, time.Hour, "#4");\r
+ Assert.AreEqual (0, time.Second, "#5");\r
+ Assert.AreEqual (0, time.Millisecond, "#6");\r
#endif\r
} finally {\r
DeleteDirectory (path);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
public void GetLastWriteTimeUtcException4 ()\r
{\r
Directory.GetLastWriteTimeUtc (" ");\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
public void GetLastWriteTimeUtcException5 ()\r
{\r
Directory.GetLastWriteTimeUtc (Path.InvalidPathChars[0].ToString ());\r
}\r
\r
[Test]\r
- public void Move ()\r
+ public void Move_DestDirName_Empty ()\r
+ {\r
+ try {\r
+ Directory.Move (TempFolder, string.Empty);\r
+ Assert.Fail ("#A1");\r
+ } catch (ArgumentException ex) {\r
+ // Empty file name is not legal\r
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");\r
+ Assert.IsNull (ex.InnerException, "#A3");\r
+ Assert.IsNotNull (ex.Message, "#A4");\r
+ Assert.IsNotNull (ex.ParamName, "#A5");\r
+ Assert.AreEqual ("destDirName", ex.ParamName, "#A6");\r
+ }\r
+\r
+ try {\r
+ Directory.Move (TempFolder, " ");\r
+ Assert.Fail ("#B1");\r
+ } catch (ArgumentException ex) {\r
+ // The path is not of a legal form\r
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");\r
+ Assert.IsNull (ex.InnerException, "#B3");\r
+ Assert.IsNotNull (ex.Message, "#B4");\r
+ }\r
+ }\r
+\r
+ [Test]\r
+ public void Move_DestDirName_Null ()\r
+ {\r
+ try {\r
+ Directory.Move (TempFolder, (string) null);\r
+ Assert.Fail ("#1");\r
+ } catch (ArgumentNullException ex) {\r
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+ Assert.IsNull (ex.InnerException, "#3");\r
+ Assert.IsNotNull (ex.Message, "#4");\r
+ Assert.IsNotNull (ex.ParamName, "#5");\r
+ Assert.AreEqual ("destDirName", ex.ParamName, "#6");\r
+ }\r
+ }\r
+\r
+ [Test]\r
+ public void Move_SourceDirName_Empty ()\r
+ {\r
+ try {\r
+ Directory.Move (string.Empty, TempFolder);\r
+ Assert.Fail ("#A1");\r
+ } catch (ArgumentException ex) {\r
+ // Empty file name is not legal\r
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#A2");\r
+ Assert.IsNull (ex.InnerException, "#A3");\r
+ Assert.IsNotNull (ex.Message, "#A4");\r
+ Assert.IsNotNull (ex.ParamName, "#A5");\r
+ Assert.AreEqual ("sourceDirName", ex.ParamName, "#A6");\r
+ }\r
+\r
+ try {\r
+ Directory.Move (" ", TempFolder);\r
+ Assert.Fail ("#B1");\r
+ } catch (ArgumentException ex) {\r
+ // The path is not of a legal form\r
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#B2");\r
+ Assert.IsNull (ex.InnerException, "#B3");\r
+ Assert.IsNotNull (ex.Message, "#B4");\r
+ }\r
+ }\r
+\r
+ [Test]\r
+ public void Move_SourceDirName_Null ()\r
+ {\r
+ try {\r
+ Directory.Move ((string) null, TempFolder);\r
+ Assert.Fail ("#1");\r
+ } catch (ArgumentNullException ex) {\r
+ Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");\r
+ Assert.IsNull (ex.InnerException, "#3");\r
+ Assert.IsNotNull (ex.Message, "#4");\r
+ Assert.IsNotNull (ex.ParamName, "#5");\r
+ Assert.AreEqual ("sourceDirName", ex.ParamName, "#6");\r
+ }\r
+ }\r
+\r
+ [Test]\r
+ public void MoveDirectory ()\r
{\r
string path = TempFolder + DSC + "DirectoryTest.Test.9";\r
string path2 = TempFolder + DSC + "DirectoryTest.Test.10";\r
try {\r
Directory.CreateDirectory (path);\r
Directory.CreateDirectory (path + DSC + "dir");\r
- AssertEquals ("test#01", true, Directory.Exists (path + DSC + "dir"));\r
+ Assert.IsTrue (Directory.Exists (path + DSC + "dir"), "#1");\r
\r
Directory.Move (path, path2);\r
- AssertEquals ("test#02", false, Directory.Exists (path + DSC + "dir")); \r
- AssertEquals ("test#03", true, Directory.Exists (path2 + DSC + "dir"));\r
- \r
+ Assert.IsFalse (Directory.Exists (path + DSC + "dir"), "#2");\r
+ Assert.IsTrue (Directory.Exists (path2 + DSC + "dir"), "#3");\r
} finally {\r
DeleteDirectory (path);\r
DeleteDirectory (path2);\r
if (Directory.Exists (path2 + DSC + "dir"))\r
- Directory.Delete (path2 + DSC + "dir", true); \r
+ Directory.Delete (path2 + DSC + "dir", true);\r
}\r
}\r
- \r
+\r
[Test]\r
- [ExpectedException(typeof(IOException))]\r
- public void MoveException1 ()\r
+ [ExpectedException (typeof (IOException))]\r
+ public void MoveDirectory_Same ()\r
{\r
string path = TempFolder + DSC + "DirectoryTest.Test.8";\r
- DeleteDirectory (path); \r
+ DeleteDirectory (path);\r
try {\r
- Directory.Move (path, path); \r
+ Directory.Move (path, path);\r
} finally {\r
DeleteDirectory (path);\r
}\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))]\r
- public void MoveException2 ()\r
+ public void MoveFile ()\r
{\r
- string path = TempFolder + DSC + "DirectoryTest.Test.11";\r
- DeleteDirectory (path); \r
+ string tempFile1 = Path.Combine (TempFolder, "temp1.txt");\r
+ string tempFile2 = Path.Combine (TempFolder, "temp2.txt");\r
+\r
+ using (StreamWriter sw = File.CreateText (tempFile1)) {\r
+ sw.Write ("temp1");\r
+ }\r
+ Assert.IsFalse (File.Exists (tempFile2), "#1");\r
+ Directory.Move (tempFile1, tempFile2);\r
+ Assert.IsFalse (File.Exists (tempFile1), "#2");\r
+ Assert.IsTrue (File.Exists (tempFile2), "#3");\r
+ using (StreamReader sr = File.OpenText (tempFile2)) {\r
+ Assert.AreEqual ("temp1", sr.ReadToEnd (), "#4");\r
+ }\r
+ }\r
+\r
+ [Test]\r
+ public void MoveFile_DestDir_Exists ()\r
+ {\r
+ string tempFile = Path.Combine (TempFolder, "temp1.txt");\r
+ string tempDir = Path.Combine (TempFolder, "temp2");\r
+\r
+ using (StreamWriter sw = File.CreateText (tempFile)) {\r
+ sw.Write ("temp1");\r
+ }\r
+ Directory.CreateDirectory (tempDir);\r
+\r
try {\r
- Directory.Move ("", path); \r
- } finally {\r
- DeleteDirectory (path);\r
+ Directory.Move (tempFile, tempDir);\r
+ Assert.Fail ("#A1");\r
+ } catch (IOException ex) {\r
+ // Cannot create a file when that file already exists\r
+ Assert.AreEqual (typeof (IOException), ex.GetType (), "#A2");\r
+ Assert.IsNull (ex.InnerException, "#A3");\r
+ Assert.IsNotNull (ex.Message, "#A4");\r
}\r
+\r
+ Assert.IsTrue (File.Exists (tempFile), "#B1");\r
+ Assert.IsFalse (File.Exists (tempDir), "#B2");\r
+ Assert.IsTrue (Directory.Exists (tempDir), "#B3");\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))]\r
- public void MoveException3 ()\r
+ public void MoveFile_DestFile_Exists ()\r
{\r
- string path = TempFolder + DSC + "DirectoryTest.Test.12";\r
- DeleteDirectory (path); \r
+ string tempFile1 = Path.Combine (TempFolder, "temp1.txt");\r
+ string tempFile2 = Path.Combine (TempFolder, "temp2.txt");\r
+\r
+ using (StreamWriter sw = File.CreateText (tempFile1)) {\r
+ sw.Write ("temp1");\r
+ }\r
+ using (StreamWriter sw = File.CreateText (tempFile2)) {\r
+ sw.Write ("temp2");\r
+ }\r
+\r
try {\r
- Directory.Move (" ", path);\r
- } finally {\r
- DeleteDirectory (path);\r
+ Directory.Move (tempFile1, tempFile2);\r
+ Assert.Fail ("#A1");\r
+ } catch (IOException ex) {\r
+ // Cannot create a file when that file already exists\r
+ Assert.AreEqual (typeof (IOException), ex.GetType (), "#A2");\r
+ Assert.IsNull (ex.InnerException, "#A3");\r
+ Assert.IsNotNull (ex.Message, "#A4");\r
+ }\r
+\r
+ Assert.IsTrue (File.Exists (tempFile1), "#B1");\r
+ using (StreamReader sr = File.OpenText (tempFile1)) {\r
+ Assert.AreEqual ("temp1", sr.ReadToEnd (), "#B2");\r
+ }\r
+\r
+ Assert.IsTrue (File.Exists (tempFile2), "#C1");\r
+ using (StreamReader sr = File.OpenText (tempFile2)) {\r
+ Assert.AreEqual ("temp2", sr.ReadToEnd (), "#C2");\r
+ }\r
+ }\r
+\r
+ [Test]\r
+ public void MoveFile_Same ()\r
+ {\r
+ string tempFile = Path.Combine (TempFolder, "temp.txt");\r
+\r
+ try {\r
+ Directory.Move (tempFile, tempFile);\r
+ Assert.Fail ("#1");\r
+ } catch (IOException ex) {\r
+ // Source and destination path must be different\r
+ Assert.AreEqual (typeof (IOException), ex.GetType (), "#2");\r
+ Assert.IsNull (ex.InnerException, "#3");\r
+ Assert.IsNotNull (ex.Message, "#4");\r
}\r
}\r
\r
{\r
string path = TempFolder + DSC + "DirectoryTest.Test.13";\r
path += Path.InvalidPathChars [0];\r
- string path2 = TempFolder + DSC + "DirectoryTest.Test.13"; \r
+ string path2 = TempFolder + DSC + "DirectoryTest.Test.13";\r
DeleteDirectory (path);\r
DeleteDirectory (path2);\r
try {\r
- Directory.CreateDirectory (path2); \r
+ Directory.CreateDirectory (path2);\r
Directory.Move (path2, path);\r
} finally {\r
DeleteDirectory (path);\r
string path = TempFolder + DSC + "DirectoryTest.Test.14";\r
DeleteDirectory (path);\r
try {\r
- Directory.Move (path, path + "Test.Test"); \r
+ Directory.Move (path, path + "Test.Test");\r
} finally {\r
DeleteDirectory (path);\r
DeleteDirectory (path + "Test.Test");\r
\r
[Test]\r
[ExpectedException(typeof(IOException))]\r
- public void MoveException6 ()\r
+ public void MoveDirectory_Dest_SubDir ()\r
{\r
string path = TempFolder + DSC + "DirectoryTest.Test.15";\r
DeleteDirectory (path);\r
try {\r
- Directory.CreateDirectory (path); \r
+ Directory.CreateDirectory (path);\r
Directory.Move (path, path + DSC + "dir");\r
} finally {\r
DeleteDirectory (path);\r
- DeleteDirectory (path + DSC + "dir"); \r
+ DeleteDirectory (path + DSC + "dir");\r
}\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(IOException))]\r
- public void MoveException7 ()\r
+ [ExpectedException (typeof (IOException))]\r
+ public void MoveDirectory_Dest_Exists ()\r
{\r
string path = TempFolder + DSC + "DirectoryTest.Test.16";\r
string path2 = TempFolder + DSC + "DirectoryTest.Test.17";\r
\r
DeleteDirectory (path);\r
- DeleteDirectory (path2); \r
+ DeleteDirectory (path2);\r
try {\r
Directory.CreateDirectory (path);\r
Directory.CreateDirectory (path2);\r
Directory.Move (path, path2);\r
} finally {\r
DeleteDirectory (path);\r
- DeleteDirectory (path2); \r
+ DeleteDirectory (path2);\r
}\r
}\r
\r
[Test]\r
- [Ignore("Unix doesnt support CreationTime")]\r
+ [Category("TargetJvmNotSupported")] // CreationTime not supported for TARGET_JVM\r
public void CreationTime ()\r
{\r
+ if (RunningOnUnix)\r
+ Assert.Ignore ("Unix doesn't support CreationTime");\r
+\r
string path = TempFolder + DSC + "DirectoryTest.CreationTime.1";\r
DeleteDirectory (path);\r
\r
Directory.CreateDirectory (path);\r
Directory.SetCreationTime (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
\r
- DateTime time = Directory.GetCreationTime (path); \r
- AssertEquals ("test#01", 2003, time.Year);\r
- AssertEquals ("test#02", 6, time.Month);\r
- AssertEquals ("test#03", 4, time.Day);\r
- AssertEquals ("test#04", 6, time.Hour);\r
- AssertEquals ("test#05", 4, time.Minute);\r
- AssertEquals ("test#06", 0, time.Second);\r
+ DateTime time = Directory.GetCreationTime (path);\r
+ Assert.AreEqual (2003, time.Year, "#A1");\r
+ Assert.AreEqual (6, time.Month, "#A2");\r
+ Assert.AreEqual (4, time.Day, "#A3");\r
+ Assert.AreEqual (6, time.Hour, "#A4");\r
+ Assert.AreEqual (4, time.Minute, "#A5");\r
+ Assert.AreEqual (0, time.Second, "#A6");\r
\r
time = TimeZone.CurrentTimeZone.ToLocalTime (Directory.GetCreationTimeUtc (path));\r
- AssertEquals ("test#07", 2003, time.Year);\r
- AssertEquals ("test#08", 6, time.Month);\r
- AssertEquals ("test#09", 4, time.Day);\r
- AssertEquals ("test#10", 6, time.Hour);\r
- AssertEquals ("test#11", 4, time.Minute);\r
- AssertEquals ("test#12", 0, time.Second);\r
+ Assert.AreEqual (2003, time.Year, "#B1");\r
+ Assert.AreEqual (6, time.Month, "#B2");\r
+ Assert.AreEqual (4, time.Day, "#B3");\r
+ Assert.AreEqual (6, time.Hour, "#B4");\r
+ Assert.AreEqual (4, time.Minute, "#B5");\r
+ Assert.AreEqual (0, time.Second, "#B6");\r
\r
Directory.SetCreationTimeUtc (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
time = TimeZone.CurrentTimeZone.ToUniversalTime (Directory.GetCreationTime (path));\r
- AssertEquals ("test#13", 2003, time.Year);\r
- AssertEquals ("test#14", 6, time.Month);\r
- AssertEquals ("test#15", 4, time.Day);\r
- AssertEquals ("test#16", 6, time.Hour);\r
- AssertEquals ("test#17", 4, time.Minute);\r
- AssertEquals ("test#18", 0, time.Second);\r
-\r
- time = Directory.GetCreationTimeUtc (path); \r
- AssertEquals ("test#19", 2003, time.Year);\r
- AssertEquals ("test#20", 6, time.Month);\r
- AssertEquals ("test#21", 4, time.Day);\r
- AssertEquals ("test#22", 6, time.Hour);\r
- AssertEquals ("test#23", 4, time.Minute);\r
- AssertEquals ("test#24", 0, time.Second);\r
+ Assert.AreEqual (2003, time.Year, "#C1");\r
+ Assert.AreEqual (6, time.Month, "#C2");\r
+ Assert.AreEqual (4, time.Day, "#C3");\r
+ Assert.AreEqual (6, time.Hour, "#C4");\r
+ Assert.AreEqual (4, time.Minute, "#C5");\r
+ Assert.AreEqual (0, time.Second, "#C6");\r
+\r
+ time = Directory.GetCreationTimeUtc (path);\r
+ Assert.AreEqual (2003, time.Year, "#D1");\r
+ Assert.AreEqual (6, time.Month, "#D2");\r
+ Assert.AreEqual (4, time.Day, "#D3");\r
+ Assert.AreEqual (6, time.Hour, "#D4");\r
+ Assert.AreEqual (4, time.Minute, "#D5");\r
+ Assert.AreEqual (0, time.Second, "#D6");\r
} finally {\r
- DeleteDirectory (path); \r
+ DeleteDirectory (path);\r
}\r
}\r
\r
[Test]\r
+ [Category("TargetJvmNotSupported")] // LastAccessTime not supported for TARGET_JVM\r
public void LastAccessTime ()\r
{\r
string path = TempFolder + DSC + "DirectoryTest.AccessTime.1";\r
Directory.CreateDirectory (path);\r
Directory.SetLastAccessTime (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
\r
- DateTime time = Directory.GetLastAccessTime (path); \r
- AssertEquals ("test#01", 2003, time.Year);\r
- AssertEquals ("test#02", 6, time.Month);\r
- AssertEquals ("test#03", 4, time.Day);\r
- AssertEquals ("test#04", 6, time.Hour);\r
- AssertEquals ("test#05", 4, time.Minute);\r
- AssertEquals ("test#06", 0, time.Second);\r
+ DateTime time = Directory.GetLastAccessTime (path);\r
+ Assert.AreEqual (2003, time.Year, "#A1");\r
+ Assert.AreEqual (6, time.Month, "#A2");\r
+ Assert.AreEqual (4, time.Day, "#A3");\r
+ Assert.AreEqual (6, time.Hour, "#A4");\r
+ Assert.AreEqual (4, time.Minute, "#A5");\r
+ Assert.AreEqual (0, time.Second, "#A6");\r
\r
time = TimeZone.CurrentTimeZone.ToLocalTime (Directory.GetLastAccessTimeUtc (path));\r
- AssertEquals ("test#07", 2003, time.Year);\r
- AssertEquals ("test#08", 6, time.Month);\r
- AssertEquals ("test#09", 4, time.Day);\r
- AssertEquals ("test#10", 6, time.Hour);\r
- AssertEquals ("test#11", 4, time.Minute);\r
- AssertEquals ("test#12", 0, time.Second);\r
+ Assert.AreEqual (2003, time.Year, "#B1");\r
+ Assert.AreEqual (6, time.Month, "#B2");\r
+ Assert.AreEqual (4, time.Day, "#B3");\r
+ Assert.AreEqual (6, time.Hour, "#B4");\r
+ Assert.AreEqual (4, time.Minute, "#B5");\r
+ Assert.AreEqual (0, time.Second, "#B6");\r
\r
Directory.SetLastAccessTimeUtc (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
time = TimeZone.CurrentTimeZone.ToUniversalTime (Directory.GetLastAccessTime (path));\r
- AssertEquals ("test#13", 2003, time.Year);\r
- AssertEquals ("test#14", 6, time.Month);\r
- AssertEquals ("test#15", 4, time.Day);\r
- AssertEquals ("test#16", 6, time.Hour);\r
- AssertEquals ("test#17", 4, time.Minute);\r
- AssertEquals ("test#18", 0, time.Second);\r
-\r
- time = Directory.GetLastAccessTimeUtc (path); \r
- AssertEquals ("test#19", 2003, time.Year);\r
- AssertEquals ("test#20", 6, time.Month);\r
- AssertEquals ("test#21", 4, time.Day);\r
- AssertEquals ("test#22", 6, time.Hour);\r
- AssertEquals ("test#23", 4, time.Minute);\r
- AssertEquals ("test#24", 0, time.Second);\r
+ Assert.AreEqual (2003, time.Year, "#C1");\r
+ Assert.AreEqual (6, time.Month, "#C2");\r
+ Assert.AreEqual (4, time.Day, "#C3");\r
+ Assert.AreEqual (6, time.Hour, "#C4");\r
+ Assert.AreEqual (4, time.Minute, "#C5");\r
+ Assert.AreEqual (0, time.Second, "#C6");\r
+\r
+ time = Directory.GetLastAccessTimeUtc (path);\r
+ Assert.AreEqual (2003, time.Year, "#D1");\r
+ Assert.AreEqual (6, time.Month, "#D2");\r
+ Assert.AreEqual (4, time.Day, "#D3");\r
+ Assert.AreEqual (6, time.Hour, "#D4");\r
+ Assert.AreEqual (4, time.Minute, "#D5");\r
+ Assert.AreEqual (0, time.Second, "#D6");\r
} finally {\r
DeleteDirectory (path);\r
}\r
public void LastWriteTime ()\r
{\r
string path = TempFolder + DSC + "DirectoryTest.WriteTime.1";\r
- DeleteDirectory (path); \r
+ DeleteDirectory (path);\r
\r
try {\r
Directory.CreateDirectory (path);\r
Directory.SetLastWriteTime (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
\r
- DateTime time = Directory.GetLastWriteTime (path); \r
- AssertEquals ("test#01", 2003, time.Year);\r
- AssertEquals ("test#02", 6, time.Month);\r
- AssertEquals ("test#03", 4, time.Day);\r
- AssertEquals ("test#04", 6, time.Hour);\r
- AssertEquals ("test#05", 4, time.Minute);\r
- AssertEquals ("test#06", 0, time.Second);\r
+ DateTime time = Directory.GetLastWriteTime (path);\r
+ Assert.AreEqual (2003, time.Year, "#A1");\r
+ Assert.AreEqual (6, time.Month, "#A2");\r
+ Assert.AreEqual (4, time.Day, "#A3");\r
+ Assert.AreEqual (6, time.Hour, "#A4");\r
+ Assert.AreEqual (4, time.Minute, "#A5");\r
+ Assert.AreEqual (0, time.Second, "#A6");\r
\r
time = TimeZone.CurrentTimeZone.ToLocalTime (Directory.GetLastWriteTimeUtc (path));\r
- AssertEquals ("test#07", 2003, time.Year);\r
- AssertEquals ("test#08", 6, time.Month);\r
- AssertEquals ("test#09", 4, time.Day);\r
- AssertEquals ("test#10", 6, time.Hour);\r
- AssertEquals ("test#11", 4, time.Minute);\r
- AssertEquals ("test#12", 0, time.Second);\r
+ Assert.AreEqual (2003, time.Year, "#B1");\r
+ Assert.AreEqual (6, time.Month, "#B2");\r
+ Assert.AreEqual (4, time.Day, "#B3");\r
+ Assert.AreEqual (6, time.Hour, "#B4");\r
+ Assert.AreEqual (4, time.Minute, "#B5");\r
+ Assert.AreEqual (0, time.Second, "#B6");\r
\r
Directory.SetLastWriteTimeUtc (path, new DateTime (2003, 6, 4, 6, 4, 0));\r
time = TimeZone.CurrentTimeZone.ToUniversalTime (Directory.GetLastWriteTime (path));\r
- AssertEquals ("test#13", 2003, time.Year);\r
- AssertEquals ("test#14", 6, time.Month);\r
- AssertEquals ("test#15", 4, time.Day);\r
- AssertEquals ("test#16", 6, time.Hour);\r
- AssertEquals ("test#17", 4, time.Minute);\r
- AssertEquals ("test#18", 0, time.Second);\r
-\r
- time = Directory.GetLastWriteTimeUtc (path); \r
- AssertEquals ("test#19", 2003, time.Year);\r
- AssertEquals ("test#20", 6, time.Month);\r
- AssertEquals ("test#21", 4, time.Day);\r
- AssertEquals ("test#22", 6, time.Hour);\r
- AssertEquals ("test#23", 4, time.Minute);\r
- AssertEquals ("test#24", 0, time.Second);\r
+ Assert.AreEqual (2003, time.Year, "#C1");\r
+ Assert.AreEqual (6, time.Month, "#C2");\r
+ Assert.AreEqual (4, time.Day, "#C3");\r
+ Assert.AreEqual (6, time.Hour, "#C4");\r
+ Assert.AreEqual (4, time.Minute, "#C5");\r
+ Assert.AreEqual (0, time.Second, "#C6");\r
+\r
+ time = Directory.GetLastWriteTimeUtc (path);\r
+ Assert.AreEqual (2003, time.Year, "#D1");\r
+ Assert.AreEqual (6, time.Month, "#D2");\r
+ Assert.AreEqual (4, time.Day, "#D3");\r
+ Assert.AreEqual (6, time.Hour, "#D4");\r
+ Assert.AreEqual (4, time.Minute, "#D5");\r
+ Assert.AreEqual (0, time.Second, "#D6");\r
} finally {\r
- DeleteDirectory (path); \r
+ DeleteDirectory (path);\r
}\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))] \r
+ [ExpectedException(typeof(ArgumentNullException))]\r
public void SetLastWriteTimeException1 ()\r
{\r
DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
[ExpectedException(typeof(ArgumentException))] \r
public void SetLastWriteTimeException2 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
- Directory.SetLastWriteTime ("", time);\r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
+ Directory.SetLastWriteTime (string.Empty, time);\r
}\r
\r
[Test]\r
[ExpectedException(typeof(FileNotFoundException))]\r
public void SetLastWriteTimeException3 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
string path = TempFolder + DSC + "DirectoryTest.SetLastWriteTime.2";\r
DeleteDirectory (path);\r
try {\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
public void SetLastWriteTimeException4 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetLastWriteTime (" ", time);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
public void SetLastWriteTimeException5 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetLastWriteTime (Path.InvalidPathChars [0].ToString (), time);\r
}\r
\r
// [Test]\r
-// [ExpectedException(typeof(ArgumentOutOfRangeException))] \r
+// [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
// public void SetLastWriteTimeException6 ()\r
// {\r
// DateTime time = new DateTime (1003, 4, 6, 6, 4, 2);\r
// string path = TempFolder + Path.DirectorySeparatorChar + "DirectoryTest.SetLastWriteTime.1";\r
//\r
// try {\r
-// if (!Directory.Exists (path)) \r
+// if (!Directory.Exists (path))\r
// Directory.CreateDirectory (path);\r
// \r
// Directory.SetLastWriteTime (path, time);\r
// }\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))] \r
+ [ExpectedException(typeof(ArgumentNullException))]\r
public void SetLastWriteTimeUtcException1 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetLastWriteTimeUtc (null as string, time);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
public void SetLastWriteTimeUtcException2 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
- Directory.SetLastWriteTimeUtc ("", time);\r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
+ Directory.SetLastWriteTimeUtc (string.Empty, time);\r
}\r
\r
[Test]\r
[ExpectedException(typeof(FileNotFoundException))]\r
public void SetLastWriteTimeUtcException3 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
string path = TempFolder + DSC + "DirectoryTest.SetLastWriteTimeUtc.2";\r
DeleteDirectory (path);\r
try {\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
public void SetLastWriteTimeUtcException4 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetLastWriteTimeUtc (" ", time);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
public void SetLastWriteTimeUtcException5 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetLastWriteTimeUtc (Path.InvalidPathChars [0].ToString (), time);\r
}\r
\r
// [Test]\r
-// [ExpectedException(typeof(ArgumentOutOfRangeException))] \r
+// [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
// public void SetLastWriteTimeUtcException6 ()\r
// {\r
// DateTime time = new DateTime (1000, 4, 6, 6, 4, 2);\r
// }\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))] \r
+ [ExpectedException(typeof(ArgumentNullException))]\r
+ [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM\r
public void SetLastAccessTimeException1 ()\r
{\r
DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM\r
public void SetLastAccessTimeException2 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
- Directory.SetLastAccessTime ("", time);\r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
+ Directory.SetLastAccessTime (string.Empty, time);\r
}\r
\r
[Test]\r
[ExpectedException(typeof(FileNotFoundException))]\r
+ [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM\r
public void SetLastAccessTimeException3 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTime.2";\r
DeleteDirectory (path);\r
try {\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM\r
public void SetLastAccessTimeException4 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetLastAccessTime (" ", time);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM\r
public void SetLastAccessTimeException5 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetLastAccessTime (Path.InvalidPathChars [0].ToString (), time);\r
}\r
\r
// [Test]\r
-// [ExpectedException(typeof(ArgumentOutOfRangeException))] \r
+// [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
// public void SetLastAccessTimeException6 ()\r
// {\r
// DateTime time = new DateTime (1003, 4, 6, 6, 4, 2);\r
// string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTime.1";\r
//\r
-// if (!Directory.Exists (path)) \r
+// if (!Directory.Exists (path))\r
// Directory.CreateDirectory (path);\r
// try {\r
// Directory.SetLastAccessTime (path, time);\r
// }\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))] \r
+ [ExpectedException(typeof(ArgumentNullException))]\r
+ [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM\r
public void SetLastAccessTimeUtcException1 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetLastAccessTimeUtc (null as string, time);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM\r
public void SetLastAccessTimeUtcException2 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
- Directory.SetLastAccessTimeUtc ("", time);\r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
+ Directory.SetLastAccessTimeUtc (string.Empty, time);\r
}\r
\r
[Test]\r
[ExpectedException(typeof(FileNotFoundException))]\r
+ [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM\r
public void SetLastAccessTimeUtcException3 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTimeUtc.2";\r
DeleteDirectory (path);\r
try {\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM\r
public void SetLastAccessTimeUtcException4 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetLastAccessTimeUtc (" ", time);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetLastAccessTime not supported for TARGET_JVM\r
public void SetLastAccessTimeUtcException5 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetLastAccessTimeUtc (Path.InvalidPathChars [0].ToString (), time);\r
}\r
\r
// [Test]\r
-// [ExpectedException(typeof(ArgumentOutOfRangeException))] \r
+// [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
// public void SetLastAccessTimeUtcException6 ()\r
// {\r
// DateTime time = new DateTime (1000, 4, 6, 6, 4, 2);\r
\r
[Test]\r
[ExpectedException(typeof(ArgumentNullException))]\r
+ [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM\r
public void SetCreationTimeException1 ()\r
{\r
DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM\r
public void SetCreationTimeException2 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
- Directory.SetCreationTime ("", time);\r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
+ Directory.SetCreationTime (string.Empty, time);\r
}\r
\r
[Test]\r
[ExpectedException(typeof(FileNotFoundException))]\r
+ [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM\r
public void SetCreationTimeException3 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
string path = TempFolder + DSC + "DirectoryTest.SetCreationTime.2";\r
DeleteDirectory (path);\r
\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM\r
public void SetCreationTimeException4 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetCreationTime (" ", time);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM\r
public void SetCreationTimeException5 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetCreationTime (Path.InvalidPathChars [0].ToString (), time);\r
}\r
\r
// [Test]\r
-// [ExpectedException(typeof(ArgumentOutOfRangeException))] \r
+// [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
// public void SetCreationTimeException6 ()\r
// {\r
// DateTime time = new DateTime (1003, 4, 6, 6, 4, 2);\r
// string path = TempFolder + DSC + "DirectoryTest.SetCreationTime.1";\r
//\r
-// if (!Directory.Exists (path)) \r
+// if (!Directory.Exists (path))\r
// Directory.CreateDirectory (path);\r
// try {\r
// Directory.SetCreationTime (path, time);\r
-// DeleteDirectory (path); \r
+// DeleteDirectory (path);\r
// } finally {\r
// DeleteDirectory (path);\r
// }\r
// }\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentNullException))] \r
+ [ExpectedException(typeof(ArgumentNullException))]\r
+ [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM\r
public void SetCreationTimeUtcException1 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetCreationTimeUtc (null as string, time);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM\r
public void SetCreationTimeUtcException2 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
- Directory.SetCreationTimeUtc ("", time);\r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
+ Directory.SetCreationTimeUtc (string.Empty, time);\r
}\r
\r
[Test]\r
[ExpectedException(typeof(FileNotFoundException))]\r
+ [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM\r
public void SetCreationTimeUtcException3 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
string path = TempFolder + DSC + "DirectoryTest.SetLastAccessTimeUtc.2";\r
DeleteDirectory (path);\r
\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM\r
public void SetCreationTimeUtcException4 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetCreationTimeUtc (" ", time);\r
}\r
\r
[Test]\r
- [ExpectedException(typeof(ArgumentException))] \r
+ [ExpectedException(typeof(ArgumentException))]\r
+ [Category("TargetJvmNotSupported")] // SetCreationTime not supported for TARGET_JVM\r
public void SetCreationTimeUtcException5 ()\r
{\r
- DateTime time = new DateTime (2003, 4, 6, 6, 4, 2); \r
+ DateTime time = new DateTime (2003, 4, 6, 6, 4, 2);\r
Directory.SetCreationTimeUtc (Path.InvalidPathChars [0].ToString (), time);\r
}\r
\r
// [Test]\r
-// [ExpectedException(typeof(ArgumentOutOfRangeException))] \r
+// [ExpectedException(typeof(ArgumentOutOfRangeException))]\r
// public void SetCreationTimeUtcException6 ()\r
// {\r
// DateTime time = new DateTime (1000, 4, 6, 6, 4, 2);\r
return;\r
}\r
\r
- Assert ("Directory Not Found", false);\r
+ Assert.Fail ("Directory Not Found");\r
} finally {\r
DeleteDirectory (DirPath);\r
}\r
}\r
\r
+ [Test] // bug #346123\r
+ public void GetDirectories_Backslash ()\r
+ {\r
+ if (!RunningOnUnix)\r
+ // on Windows, backslash is used as directory separator\r
+ return;\r
+\r
+ string dir = Path.Combine (TempFolder, @"sub\dir");\r
+ Directory.CreateDirectory (dir);\r
+\r
+ Assert.IsTrue (Directory.Exists (dir), "#A1");\r
+ Assert.IsFalse (Directory.Exists (Path.Combine (TempFolder, "dir")), "#A2");\r
+\r
+ string [] dirs = Directory.GetDirectories (TempFolder);\r
+ Assert.AreEqual (1, dirs.Length, "#B1");\r
+ Assert.AreEqual (dir, dirs [0], "#B2");\r
+ }\r
+\r
[Test]\r
public void GetParentOfRootDirectory ()\r
{\r
DirectoryInfo info;\r
\r
info = Directory.GetParent (Path.GetPathRoot (Path.GetTempPath ()));\r
- AssertEquals (null, info);\r
+ Assert.IsNull (info);\r
}\r
\r
[Test]\r
return;\r
}\r
\r
- Assert ("File Not Found", false);\r
+ Assert.Fail ("File Not Found");\r
} finally {\r
if (File.Exists (DirPath))\r
File.Delete (DirPath);\r
- \r
- } \r
+ }\r
+ }\r
+\r
+ [Test] // bug #346123\r
+ public void GetFiles_Backslash ()\r
+ {\r
+ if (!RunningOnUnix)\r
+ // on Windows, backslash is used as directory separator\r
+ return;\r
+\r
+ string file = Path.Combine (TempFolder, @"doc\temp1.file");\r
+ File.Create (file).Close ();\r
+\r
+ Assert.IsTrue (File.Exists (file), "#A1");\r
+ Assert.IsFalse (File.Exists (Path.Combine (TempFolder, "temp1.file")), "#A2");\r
+\r
+ string [] files = Directory.GetFiles (TempFolder);\r
+ Assert.AreEqual (1, files.Length, "#B1");\r
+ Assert.AreEqual (file, files [0], "#B2");\r
}\r
\r
+ [Test] // bug #82212 and bug #325107\r
+ public void GetFiles_Pattern ()\r
+ {\r
+ string [] files = Directory.GetFiles (TempFolder, "*.*");\r
+ Assert.IsNotNull (files, "#A1");\r
+ Assert.AreEqual (0, files.Length, "#A2");\r
+\r
+ string tempFile1 = Path.Combine (TempFolder, "tempFile1");\r
+ File.Create (tempFile1).Close ();\r
+\r
+ files = Directory.GetFiles (TempFolder, "*.*");\r
+ Assert.IsNotNull (files, "#B1");\r
+ Assert.AreEqual (1, files.Length, "#B2");\r
+ Assert.AreEqual (tempFile1, files [0], "#B3");\r
+\r
+ string tempFile2 = Path.Combine (TempFolder, "FileTemp2.tmp");\r
+ File.Create (tempFile2).Close ();\r
+\r
+ files = Directory.GetFiles (TempFolder, "*.*");\r
+ Assert.IsNotNull (files, "#C1");\r
+ Assert.AreEqual (2, files.Length, "#C2");\r
+\r
+ files = Directory.GetFiles (TempFolder, "temp*.*");\r
+ Assert.IsNotNull (files, "#D1");\r
+ Assert.AreEqual (1, files.Length, "#D2");\r
+ Assert.AreEqual (tempFile1, files [0], "#D3");\r
+\r
+ string tempFile3 = Path.Combine (TempFolder, "tempFile3.txt");\r
+ File.Create (tempFile3).Close ();\r
+\r
+ files = Directory.GetFiles (TempFolder, "*File*.*");\r
+ Assert.IsNotNull (files, "#E1");\r
+ Assert.AreEqual (3, files.Length, "#E2");\r
+\r
+ files = Directory.GetFiles (TempFolder, "*File*.tmp");\r
+ Assert.IsNotNull (files, "#F1");\r
+ Assert.AreEqual (1, files.Length, "#F2");\r
+ Assert.AreEqual (tempFile2, files [0], "#F3");\r
+\r
+ files = Directory.GetFiles (TempFolder, "*tempFile*");\r
+ Assert.IsNotNull (files, "#G1");\r
+ Assert.AreEqual (2, files.Length, "#G2");\r
+\r
+ files = Directory.GetFiles (TempFolder, "*tempFile1");\r
+ Assert.IsNotNull (files, "#H1");\r
+ Assert.AreEqual (1, files.Length, "#H2");\r
+ Assert.AreEqual (tempFile1, files [0], "#H3");\r
+\r
+ files = Directory.GetFiles (TempFolder, "*.txt");\r
+ Assert.IsNotNull (files, "#I1");\r
+ Assert.AreEqual (1, files.Length, "#I2");\r
+ Assert.AreEqual (tempFile3, files [0], "#I3");\r
+\r
+ files = Directory.GetFiles (TempFolder, "*.t*");\r
+ Assert.IsNotNull (files, "#J1");\r
+ Assert.AreEqual (2, files.Length, "#J2");\r
+\r
+ files = Directory.GetFiles (TempFolder, "temp*.*");\r
+ Assert.IsNotNull (files, "#K1");\r
+ Assert.AreEqual (2, files.Length, "#K2");\r
+\r
+ File.Delete (tempFile1);\r
+\r
+ files = Directory.GetFiles (TempFolder, "temp*.*");\r
+ Assert.IsNotNull (files, "#L1");\r
+ Assert.AreEqual (1, files.Length, "#L2");\r
+ Assert.AreEqual (tempFile3, files [0], "#L3");\r
+\r
+ files = Directory.GetFiles (TempFolder, ".*");\r
+ Assert.IsNotNull (files, "#M1");\r
+ Assert.AreEqual (0, files.Length, "#M2");\r
+\r
+ string tempFile4 = Path.Combine (TempFolder, "tempFile4.");\r
+ File.Create (tempFile4).Close ();\r
+\r
+ files = Directory.GetFiles (TempFolder, "temp*.");\r
+ Assert.IsNotNull (files, "#N1");\r
+ Assert.AreEqual (1, files.Length, "#N2");\r
+ if (RunningOnUnix)\r
+ Assert.AreEqual (tempFile4, files [0], "#N3");\r
+ else // on Windows, the trailing dot is automatically trimmed\r
+ Assert.AreEqual (Path.Combine (TempFolder, "tempFile4"), files [0], "#N3");\r
+ }\r
+\r
+ [Test]\r
+ public void GetFiles_580090 ()\r
+ {\r
+ string cwd = Directory.GetCurrentDirectory ();\r
+ Directory.SetCurrentDirectory (Path.GetTempPath ());\r
+\r
+ string tempFile = Path.Combine (TempFolder, "tempFile.txt");\r
+ File.Create (tempFile).Close ();\r
+\r
+ try {\r
+ string [] files = Directory.GetFiles (".", TempSubFolder + DSC + "*.t*");\r
+ Assert.IsNotNull (files, "#J1");\r
+ Assert.AreEqual (1, files.Length, "#J2");\r
+ }\r
+ finally {\r
+ Directory.SetCurrentDirectory (cwd);\r
+ }\r
+ }\r
+\r
+\r
[Test]\r
[ExpectedException (typeof (ArgumentNullException))]\r
public void SetCurrentDirectoryNull ()\r
dir.GetFiles ("*.nonext");\r
}\r
\r
-\r
[Test]\r
public void FilenameOnly () // bug 78209\r
{\r
Directory.GetParent ("somefile");\r
}\r
\r
+ private static bool RunningOnUnix {\r
+ get {\r
+ // check for Unix platforms - see FAQ for more details\r
+ // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F\r
+ int platform = (int) Environment.OSVersion.Platform;\r
+ return ((platform == 4) || (platform == 128) || (platform == 6));\r
+ }\r
+ }\r
+\r
private void DeleteDirectory (string path)\r
{\r
if (Directory.Exists (path))\r
- Directory.Delete (path, true); \r
+ Directory.Delete (path, true);\r
}\r
\r
private void DeleteFile (string path)\r