From edf7a243f546c7fefdbcbba959edcc77dc2b0c8f Mon Sep 17 00:00:00 2001 From: Valters Melnalksnis Date: Wed, 16 Oct 2024 07:45:42 +0300 Subject: [PATCH] test: pass correct instant to date filter --- .../TransactionsControllerTests.cs | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/Gnomeshade.WebApi.Tests.Integration/V1/Controllers/TransactionsControllerTests.cs b/tests/Gnomeshade.WebApi.Tests.Integration/V1/Controllers/TransactionsControllerTests.cs index 8342b699..b39e2b2d 100644 --- a/tests/Gnomeshade.WebApi.Tests.Integration/V1/Controllers/TransactionsControllerTests.cs +++ b/tests/Gnomeshade.WebApi.Tests.Integration/V1/Controllers/TransactionsControllerTests.cs @@ -73,23 +73,24 @@ public async Task PutTransaction() var detailedTransactions = await _client.GetDetailedTransactionsAsync(new(null, null)); detailedTransactions.Should().Contain(detailed => detailed.Id == transactionId); - var transferCreation = new TransferCreation - { - TransactionId = transactionId, - SourceAmount = 1, - SourceAccountId = _account1.Currencies.First().Id, - TargetAmount = 1, - TargetAccountId = _account2.Currencies.First().Id, - Order = 2, - ValuedAt = SystemClock.Instance.GetCurrentInstant(), - }; - - await _client.CreateTransferAsync(transactionId, _account1.Id, _account2.Id); - var currentTime = SystemClock.Instance.GetCurrentInstant(); - var expectedDate = currentTime + Duration.FromDays(2); - await _client.PutTransferAsync(Guid.NewGuid(), transferCreation with { ValuedAt = expectedDate, Order = 3 }); - - (await _client.GetDetailedTransactionsAsync(new(Instant.MinValue, currentTime))) + var firstTransfer = await _client.CreateTransferAsync(transactionId, _account1.Id, _account2.Id); + + var bookedAt = firstTransfer.BookedAt!.Value; + var expectedDate = bookedAt + Duration.FromDays(2); + await _client.PutTransferAsync( + Guid.NewGuid(), + new() + { + TransactionId = transactionId, + SourceAmount = 1, + SourceAccountId = _account1.Currencies.First().Id, + TargetAmount = 1, + TargetAccountId = _account2.Currencies.First().Id, + Order = 2, + ValuedAt = expectedDate, + }); + + (await _client.GetDetailedTransactionsAsync(new(Instant.MinValue, bookedAt))) .Should() .NotContain(detailedTransaction => detailedTransaction.Id == transactionId);