Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c0448a8

Browse files
committed
Check actual set time for test (#20820)
There is already a test that checks the time is in range. The time here shouldn't change at all- and the range I was using wasn't tolerant enough for all of our targets.
1 parent 8dbc04c commit c0448a8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/System.IO.FileSystem/tests/Base/InfoGetSetTimes.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Collections.Generic;
6+
using System.Linq;
57
using Xunit;
68

79
namespace System.IO.Tests
@@ -46,16 +48,24 @@ public void ExistsThenDelete_ReturnsDefaultValues()
4648
[Fact]
4749
public void TimesStillSetAfterDelete()
4850
{
49-
DateTime beforeTime = DateTime.UtcNow.AddSeconds(-1);
5051
T item = GetExistingItem();
5152

5253
// Refresh to fill state
5354
item.Refresh();
54-
DateTime afterTime = DateTime.UtcNow.AddSeconds(1);
5555

56-
// Deleting doesn't change any info state
56+
// Get our initial times
57+
var times = new Dictionary<TimeFunction, DateTime>();
58+
foreach (var timeFunction in TimeFunctions())
59+
{
60+
times.Add(timeFunction, timeFunction.Getter(item));
61+
}
62+
63+
// Deleting shouldn't change any info state
5764
item.Delete();
58-
ValidateSetTimes(item, beforeTime, afterTime);
65+
Assert.All(times, time =>
66+
{
67+
Assert.Equal(time.Value, time.Key.Getter(item));
68+
});
5969
}
6070
}
6171
}

0 commit comments

Comments
 (0)