Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorAlexander Köplinger <alex.koeplinger@outlook.com>2017-07-05 18:54:47 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2017-07-07 17:17:56 +0300
commit167d1a6c195dec75dfaa647410b702e5d0ca0b8f (patch)
treedf0728552fec175846d77a2acb640462c7da3d63 /mcs
parent4de15018317be1b7642e654acca788e750dedd29 (diff)
[corlib] Add test for deleting non-existing file
It shouldn't throw in that case. Helps cover https://bugzilla.xamarin.com/show_bug.cgi?id=57629 (note that we don't explicitly test on a readonly FS as that is hard to do in a unit test, but running this test on Android should suffice).
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/corlib/Test/System.IO/DriveInfoTest.cs33
-rw-r--r--mcs/class/corlib/Test/System.IO/FileTest.cs6
-rw-r--r--mcs/class/test-helpers/NunitHelpers.cs5
3 files changed, 33 insertions, 11 deletions
diff --git a/mcs/class/corlib/Test/System.IO/DriveInfoTest.cs b/mcs/class/corlib/Test/System.IO/DriveInfoTest.cs
index 44d4f78cd95..1d78d88b3a3 100644
--- a/mcs/class/corlib/Test/System.IO/DriveInfoTest.cs
+++ b/mcs/class/corlib/Test/System.IO/DriveInfoTest.cs
@@ -41,23 +41,30 @@ namespace MonoTests.System.IO
public class DriveInfoTest
{
[Test]
- [Category ("MobileNotWorking")]
public void Constructor ()
{
- var drive = new DriveInfo (Environment.OSVersion.Platform == PlatformID.Unix ? "/" : "C:\\");
+ if (Environment.OSVersion.Platform != PlatformID.Win32NT)
+ Assert.Ignore ("The Jenkins builders don't have '/' mounted, just testing Windows for now.");
+
+ var drive = new DriveInfo ("C:\\");
ValidateDriveInfo (drive);
Assert.AreEqual (DriveType.Fixed, drive.DriveType);
}
[Test]
+ public void ConstructorThrowsOnNonExistingDrive ()
+ {
+ Assert.Throws<ArgumentException> (() => new DriveInfo ("/monodriveinfotest"));
+ }
+
+ [Test]
public void GetDrivesNotEmpty ()
{
var drives = DriveInfo.GetDrives ();
- Assert.That (drives, Is.Not.Empty);
+ CollectionAssert.IsNotEmpty (drives);
}
[Test]
- [Category ("MobileNotWorking")]
public void GetDrivesValidInfo ()
{
var drives = DriveInfo.GetDrives ();
@@ -69,17 +76,21 @@ namespace MonoTests.System.IO
void ValidateDriveInfo (DriveInfo d)
{
- Assert.That (d.Name, Is.Not.Empty);
- Assert.That (d.VolumeLabel, Is.Not.Empty);
+ AssertHelper.IsNotEmpty (d.Name);
+ AssertHelper.IsNotEmpty (d.VolumeLabel);
Assert.NotNull (d.RootDirectory);
- AssertHelper.GreaterOrEqual (d.AvailableFreeSpace, 0);
- AssertHelper.GreaterOrEqual (d.TotalFreeSpace, 0);
- AssertHelper.GreaterOrEqual (d.TotalSize, 0);
+ if (d.DriveFormat != null) {
+ Assert.AreNotEqual ("", d.DriveFormat);
+ Assert.AreNotEqual (DriveType.Unknown, d.DriveType, "DriveFormat=" + d.DriveFormat);
+ }
- Assert.That (d.DriveFormat, Is.Not.Empty);
- if (d.DriveType == DriveType.Fixed)
+ if (d.DriveType == DriveType.Fixed) { // just consider fixed drives for now
Assert.True (d.IsReady);
+ AssertHelper.GreaterOrEqual (d.AvailableFreeSpace, 0);
+ AssertHelper.GreaterOrEqual (d.TotalFreeSpace, 0);
+ AssertHelper.GreaterOrEqual (d.TotalSize, 0);
+ }
}
}
}
diff --git a/mcs/class/corlib/Test/System.IO/FileTest.cs b/mcs/class/corlib/Test/System.IO/FileTest.cs
index 4fc95243fe0..4528027b24e 100644
--- a/mcs/class/corlib/Test/System.IO/FileTest.cs
+++ b/mcs/class/corlib/Test/System.IO/FileTest.cs
@@ -533,6 +533,12 @@ namespace MonoTests.System.IO
}
[Test]
+ public void Delete_NonExisting_NoException ()
+ {
+ File.Delete (Path.Combine (Directory.GetDirectoryRoot (Directory.GetCurrentDirectory ()), "monononexistingfile.dat"));
+ }
+
+ [Test]
public void GetAttributes_Archive ()
{
if (RunningOnUnix)
diff --git a/mcs/class/test-helpers/NunitHelpers.cs b/mcs/class/test-helpers/NunitHelpers.cs
index 5bc3211f89a..20ea722a155 100644
--- a/mcs/class/test-helpers/NunitHelpers.cs
+++ b/mcs/class/test-helpers/NunitHelpers.cs
@@ -30,6 +30,11 @@ namespace NUnit.Framework
{
Assert.That(collection, new EmptyCollectionConstraint(), message, args);
}
+
+ public static void IsNotEmpty(IEnumerable collection, string message = null, params object[] args)
+ {
+ Assert.That(collection, Is.Not.Empty, message, args);
+ }
}
static class FileAssert