Skip to content

Commit 1d76310

Browse files
committed
Simplify test: since we have deterministic clocks, there's no more need for a hard-coded value.
1 parent c7e396d commit 1d76310

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Net;
22
using FluentAssertions;
3-
using FluentAssertions.Extensions;
43
using JsonApiDotNetCore.Configuration;
54
using JsonApiDotNetCore.Serialization.Objects;
65
using Microsoft.AspNetCore.Authentication;
@@ -12,8 +11,6 @@ namespace JsonApiDotNetCoreTests.IntegrationTests.AtomicOperations.QueryStrings;
1211

1312
public sealed class AtomicQueryStringTests : IClassFixture<IntegrationTestContext<TestableStartup<OperationsDbContext>, OperationsDbContext>>
1413
{
15-
private static readonly DateTime FrozenTime = 30.July(2018).At(13, 46, 12).AsUtc();
16-
1714
private readonly IntegrationTestContext<TestableStartup<OperationsDbContext>, OperationsDbContext> _testContext;
1815
private readonly OperationsFakers _fakers = new();
1916

@@ -26,11 +23,7 @@ public AtomicQueryStringTests(IntegrationTestContext<TestableStartup<OperationsD
2623

2724
testContext.ConfigureServicesAfterStartup(services =>
2825
{
29-
services.AddSingleton<ISystemClock>(new FrozenSystemClock
30-
{
31-
UtcNow = FrozenTime
32-
});
33-
26+
services.AddSingleton<ISystemClock, FrozenSystemClock>();
3427
services.AddResourceDefinition<MusicTrackReleaseDefinition>();
3528
});
3629
}
@@ -279,10 +272,12 @@ public async Task Cannot_use_sparse_fieldset_on_operations_endpoint()
279272
public async Task Can_use_Queryable_handler_on_resource_endpoint()
280273
{
281274
// Arrange
275+
var clock = _testContext.Factory.Services.GetRequiredService<ISystemClock>();
276+
282277
List<MusicTrack> musicTracks = _fakers.MusicTrack.Generate(3);
283-
musicTracks[0].ReleasedAt = FrozenTime.AddMonths(5);
284-
musicTracks[1].ReleasedAt = FrozenTime.AddMonths(-5);
285-
musicTracks[2].ReleasedAt = FrozenTime.AddMonths(-1);
278+
musicTracks[0].ReleasedAt = clock.UtcNow.AddMonths(5);
279+
musicTracks[1].ReleasedAt = clock.UtcNow.AddMonths(-5);
280+
musicTracks[2].ReleasedAt = clock.UtcNow.AddMonths(-1);
286281

287282
await _testContext.RunOnDatabaseAsync(async dbContext =>
288283
{

0 commit comments

Comments
 (0)