-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Expand file tree
/
Copy pathGetSetAttributes.cs
More file actions
45 lines (38 loc) · 1.6 KB
/
GetSetAttributes.cs
File metadata and controls
45 lines (38 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Xunit;
namespace System.IO.Tests
{
public partial class FileInfo_GetSetAttributes : InfoGetSetAttributes<FileInfo>
{
protected override bool CanBeReadOnly => true;
protected override FileAttributes GetAttributes(string path) => new FileInfo(path).Attributes;
protected override void SetAttributes(string path, FileAttributes attributes) => new FileInfo(path).Attributes = attributes;
protected override FileInfo CreateInfo(string path) => new FileInfo(path);
[Fact]
public void IsReadOnly_SetAndGet()
{
FileInfo test = new FileInfo(GetTestFilePath());
test.Create().Dispose();
// Set to True
test.IsReadOnly = true;
test.Refresh();
Assert.True(test.IsReadOnly);
// Set To False
test.IsReadOnly = false;
test.Refresh();
Assert.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);
}
}
}