Skip to content

Commit d0465d8

Browse files
authored
Use a fake clock in the test (#36625)
1 parent a18ae25 commit d0465d8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Identity/test/Identity.Test/SecurityStampValidatorTest.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,11 @@ public async Task OnValidateIdentityDoesNotExtendExpirationWhenSlidingIsDisabled
285285
var services = new ServiceCollection();
286286
services.AddSingleton(options.Object);
287287
services.AddSingleton(signInManager.Object);
288-
var clock = new SystemClock();
288+
var clock = new TestClock()
289+
{
290+
// Second precision
291+
UtcNow = new DateTimeOffset(2013, 6, 11, 12, 34, 56, 0, TimeSpan.Zero)
292+
};
289293
services.AddSingleton<ISecurityStampValidator>(new SecurityStampValidator<PocoUser>(options.Object, signInManager.Object, clock, new LoggerFactory()));
290294
httpContext.Setup(c => c.RequestServices).Returns(services.BuildServiceProvider());
291295
var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme);

src/Identity/test/InMemory.Test/TestClock.cs renamed to src/Identity/test/Shared/TestClock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System;
55
using Microsoft.AspNetCore.Authentication;
66

7-
namespace Microsoft.AspNetCore.Identity.InMemory
7+
namespace Microsoft.AspNetCore.Identity.Test
88
{
99
public class TestClock : ISystemClock
1010
{

0 commit comments

Comments
 (0)