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

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Pfister <steve.pfister@microsoft.com>2019-10-31 05:01:51 +0300
committerSteve Pfister <steve.pfister@microsoft.com>2019-10-31 05:01:51 +0300
commitd994544ba1118bfb477ded7ff9e3b40d73c0f45d (patch)
treefa60bb63bc1c198dd6555fecdd00adba7bf3072a /src/System.IO.FileSystem/tests
parent49f1c453f75e36948d0386d862378eb0dff51455 (diff)
Backport of https://github.com/dotnet/corefx/pull/34560
Fixes https://github.com/mono/mono/issues/17304
Diffstat (limited to 'src/System.IO.FileSystem/tests')
-rw-r--r--src/System.IO.FileSystem/tests/Base/FileGetSetAttributes.cs35
-rw-r--r--src/System.IO.FileSystem/tests/FileInfo/GetSetAttributes.cs13
2 files changed, 43 insertions, 5 deletions
diff --git a/src/System.IO.FileSystem/tests/Base/FileGetSetAttributes.cs b/src/System.IO.FileSystem/tests/Base/FileGetSetAttributes.cs
index 408666e819..434af1cb5f 100644
--- a/src/System.IO.FileSystem/tests/Base/FileGetSetAttributes.cs
+++ b/src/System.IO.FileSystem/tests/Base/FileGetSetAttributes.cs
@@ -16,9 +16,16 @@ namespace System.IO.Tests
public void SettingAttributes_Unix(FileAttributes attributes)
{
string path = CreateItem();
- SetAttributes(path, attributes);
- Assert.Equal(attributes, GetAttributes(path));
- SetAttributes(path, 0);
+ AssertSettingAttributes(path, attributes);
+ }
+
+ [Theory]
+ [InlineData(FileAttributes.Hidden)]
+ [PlatformSpecific(TestPlatforms.OSX | TestPlatforms.FreeBSD)]
+ public void SettingAttributes_OSXAndFreeBSD(FileAttributes attributes)
+ {
+ string path = CreateItem();
+ AssertSettingAttributes(path, attributes);
}
[Theory]
@@ -33,6 +40,11 @@ namespace System.IO.Tests
public void SettingAttributes_Windows(FileAttributes attributes)
{
string path = CreateItem();
+ AssertSettingAttributes(path, attributes);
+ }
+
+ private void AssertSettingAttributes(string path, FileAttributes attributes)
+ {
SetAttributes(path, attributes);
Assert.Equal(attributes, GetAttributes(path));
SetAttributes(path, 0);
@@ -48,8 +60,16 @@ namespace System.IO.Tests
public void SettingInvalidAttributes_Unix(FileAttributes attributes)
{
string path = CreateItem();
- SetAttributes(path, attributes);
- Assert.Equal(FileAttributes.Normal, GetAttributes(path));
+ AssertSettingInvalidAttributes(path, attributes);
+ }
+
+ [Theory]
+ [InlineData(FileAttributes.Hidden)]
+ [PlatformSpecific(TestPlatforms.AnyUnix & ~(TestPlatforms.OSX | TestPlatforms.FreeBSD))]
+ public void SettingInvalidAttributes_UnixExceptOSXAndFreeBSD(FileAttributes attributes)
+ {
+ string path = CreateItem();
+ AssertSettingInvalidAttributes(path, attributes);
}
[Theory]
@@ -62,6 +82,11 @@ namespace System.IO.Tests
public void SettingInvalidAttributes_Windows(FileAttributes attributes)
{
string path = CreateItem();
+ AssertSettingInvalidAttributes(path, attributes);
+ }
+
+ private void AssertSettingInvalidAttributes(string path, FileAttributes attributes)
+ {
SetAttributes(path, attributes);
Assert.Equal(FileAttributes.Normal, GetAttributes(path));
}
diff --git a/src/System.IO.FileSystem/tests/FileInfo/GetSetAttributes.cs b/src/System.IO.FileSystem/tests/FileInfo/GetSetAttributes.cs
index 89a92f4fb2..1bdfb98db2 100644
--- a/src/System.IO.FileSystem/tests/FileInfo/GetSetAttributes.cs
+++ b/src/System.IO.FileSystem/tests/FileInfo/GetSetAttributes.cs
@@ -28,5 +28,18 @@ namespace System.IO.Tests
test.Refresh();
Assert.Equal(false, test.IsReadOnly);
}
+
+ [Theory]
+ [InlineData(".", true)]
+ [InlineData("", false)]
+ [PlatformSpecific(TestPlatforms.OSX)]
+ public void HiddenAttributeSetCorrectly_OSX(string filePrefix, bool hidden)
+ {
+ string testFilePath = Path.Combine(TestDirectory, $"{filePrefix}{GetTestFileName()}");
+ FileInfo fileInfo = new FileInfo(testFilePath);
+ fileInfo.Create().Dispose();
+
+ Assert.Equal(hidden, (fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden);
+ }
}
}