forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetSetAttributes.cs
More file actions
40 lines (34 loc) · 1.55 KB
/
GetSetAttributes.cs
File metadata and controls
40 lines (34 loc) · 1.55 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
// 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 class File_GetSetAttributes : BaseGetSetAttributes
{
protected override FileAttributes GetAttributes(string path) => File.GetAttributes(path);
protected override void SetAttributes(string path, FileAttributes attributes) => File.SetAttributes(path, attributes);
protected override bool CanBeReadOnly => false;
// Getting only throws for File, not FileInfo
[Theory, MemberData(nameof(TrailingCharacters))]
public void GetAttributes_MissingFile(char trailingChar)
{
Assert.Throws<FileNotFoundException>(() => GetAttributes(GetTestFilePath() + trailingChar));
}
// Getting only throws for File, not FileInfo
[Theory,
InlineData(":bar"),
InlineData(":bar:$DATA")]
[PlatformSpecific(TestPlatforms.Windows)]
public void GetAttributes_MissingAlternateDataStream_Windows(string streamName)
{
string path = CreateItem();
streamName = path + streamName;
Assert.Throws<FileNotFoundException>(() => GetAttributes(streamName));
}
[Theory, MemberData(nameof(TrailingCharacters))]
public void GetAttributes_MissingDirectory(char trailingChar)
{
Assert.Throws<DirectoryNotFoundException>(() => GetAttributes(Path.Combine(GetTestFilePath(), "dir" + trailingChar)));
}
}
}