-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
GetSetTimes.cs
65 lines (57 loc) · 3.06 KB
/
GetSetTimes.cs
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
namespace System.IO.Tests
{
public class DirectoryInfo_GetSetTimes : InfoGetSetTimes<DirectoryInfo>
{
protected override bool CanBeReadOnly => false;
protected override DirectoryInfo GetExistingItem(bool _) => Directory.CreateDirectory(GetTestFilePath());
protected override DirectoryInfo GetMissingItem() => new DirectoryInfo(GetTestFilePath());
protected override DirectoryInfo CreateSymlink(string path, string pathToTarget) => (DirectoryInfo)Directory.CreateSymbolicLink(path, pathToTarget);
protected override string GetItemPath(DirectoryInfo item) => item.FullName;
protected override void InvokeCreate(DirectoryInfo item) => item.Create();
public override IEnumerable<TimeFunction> TimeFunctions(bool requiresRoundtripping = false)
{
if (IOInputs.SupportsGettingCreationTime && (!requiresRoundtripping || IOInputs.SupportsSettingCreationTime))
{
yield return TimeFunction.Create(
((testDir, time) => {testDir.CreationTime = time; }),
((testDir) => testDir.CreationTime),
DateTimeKind.Local);
yield return TimeFunction.Create(
((testDir, time) => {testDir.CreationTimeUtc = time; }),
((testDir) => testDir.CreationTimeUtc),
DateTimeKind.Unspecified);
yield return TimeFunction.Create(
((testDir, time) => { testDir.CreationTimeUtc = time; }),
((testDir) => testDir.CreationTimeUtc),
DateTimeKind.Utc);
}
yield return TimeFunction.Create(
((testDir, time) => {testDir.LastAccessTime = time; }),
((testDir) => testDir.LastAccessTime),
DateTimeKind.Local);
yield return TimeFunction.Create(
((testDir, time) => {testDir.LastAccessTimeUtc = time; }),
((testDir) => testDir.LastAccessTimeUtc),
DateTimeKind.Unspecified);
yield return TimeFunction.Create(
((testDir, time) => { testDir.LastAccessTimeUtc = time; }),
((testDir) => testDir.LastAccessTimeUtc),
DateTimeKind.Utc);
yield return TimeFunction.Create(
((testDir, time) => {testDir.LastWriteTime = time; }),
((testDir) => testDir.LastWriteTime),
DateTimeKind.Local);
yield return TimeFunction.Create(
((testDir, time) => {testDir.LastWriteTimeUtc = time; }),
((testDir) => testDir.LastWriteTimeUtc),
DateTimeKind.Unspecified);
yield return TimeFunction.Create(
((testDir, time) => { testDir.LastWriteTimeUtc = time; }),
((testDir) => testDir.LastWriteTimeUtc),
DateTimeKind.Utc);
}
}
}