remove NodaTime dependency and refactor to System.DateTimeOffset
This commit is contained in:
-2
@@ -28,8 +28,6 @@ public sealed class ServiceCollectionExtensionsTests
|
||||
var serviceCollection = new ServiceCollection();
|
||||
|
||||
serviceCollection
|
||||
.AddSingleton<IClock>(SystemClock.Instance)
|
||||
.AddSingleton(DateTimeZoneProviders.Tzdb)
|
||||
.AddNordigenDotNet(configuration);
|
||||
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
|
||||
@@ -6,8 +6,6 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using NodaTime;
|
||||
|
||||
using VMelnalksnis.NordigenDotNet.Requisitions;
|
||||
|
||||
using Xunit.Abstractions;
|
||||
@@ -41,12 +39,12 @@ public sealed class AccountClientTests : IClassFixture<ServiceProviderFixture>,
|
||||
_requisition.Accounts.Should().HaveCount(2);
|
||||
|
||||
var account = await _nordigenClient.Accounts.Get(_accountId);
|
||||
var currentInstant = SystemClock.Instance.GetCurrentInstant();
|
||||
var now = DateTimeOffset.Now;
|
||||
using (new AssertionScope())
|
||||
{
|
||||
account.Id.Should().Be(_accountId);
|
||||
account.Created.Should().BeLessThan(account.LastAccessed).And.BeLessThan(currentInstant);
|
||||
account.LastAccessed.Should().BeGreaterThan(currentInstant - Duration.FromMinutes(1));
|
||||
account.Created.Should().BeBefore(account.LastAccessed).And.BeBefore(now);
|
||||
account.LastAccessed.Should().BeAfter(now.AddMinutes(-1));
|
||||
account.Iban.Should().Be("GL3343697694912188");
|
||||
account.InstitutionId.Should().Be(IntegrationInstitutionId);
|
||||
account.Status.Should().BeDefined();
|
||||
@@ -90,13 +88,11 @@ public sealed class AccountClientTests : IClassFixture<ServiceProviderFixture>,
|
||||
[Fact]
|
||||
public async Task GetTransactions_ShouldReturnExpected()
|
||||
{
|
||||
var currentInstant = SystemClock.Instance.GetCurrentInstant();
|
||||
var currentZone = DateTimeZoneProviders.Tzdb.GetSystemDefault();
|
||||
var currentDate = currentInstant.InZone(currentZone).Date;
|
||||
var now = DateTimeOffset.Now;
|
||||
|
||||
var dateTo = currentInstant;
|
||||
var dateFrom = dateTo - Duration.FromDays(7);
|
||||
var transactions = await _nordigenClient.Accounts.GetTransactions(_accountId, new Interval(dateFrom, dateTo));
|
||||
var dateTo = now;
|
||||
var dateFrom = dateTo.AddDays(-7);
|
||||
var transactions = await _nordigenClient.Accounts.GetTransactions(_accountId, dateFrom, dateTo);
|
||||
var allTransactions = await _nordigenClient.Accounts.GetTransactions(_accountId);
|
||||
|
||||
using (new AssertionScope())
|
||||
@@ -109,9 +105,9 @@ public sealed class AccountClientTests : IClassFixture<ServiceProviderFixture>,
|
||||
pendingTransaction.TransactionAmount.Currency.Should().Be("EUR");
|
||||
pendingTransaction.TransactionAmount.Amount.Should().Be(10m);
|
||||
pendingTransaction.UnstructuredInformation.Should().Be("Reserved PAYMENT Emperor's Burgers");
|
||||
pendingTransaction.ValueDate.Should().Be(currentDate - Period.FromDays(2));
|
||||
pendingTransaction.ValueDate.Should().Be(now.AddDays(-2));
|
||||
|
||||
var date = currentDate - Period.FromDays(1);
|
||||
var date = now.AddDays(-1);
|
||||
var transactionId = $"{date:yyyyMMdd}01927908-1";
|
||||
var bookedTransaction = transactions.Booked.First(transaction => transaction.TransactionId == transactionId);
|
||||
bookedTransaction.TransactionAmount.Currency.Should().Be("EUR");
|
||||
|
||||
+2
-3
@@ -2,12 +2,11 @@
|
||||
// Licensed under the Apache License 2.0.
|
||||
// See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using NodaTime;
|
||||
|
||||
using VMelnalksnis.NordigenDotNet.Agreements;
|
||||
|
||||
using Xunit.Abstractions;
|
||||
@@ -39,7 +38,7 @@ public sealed class AgreementClientTests : IClassFixture<ServiceProviderFixture>
|
||||
|
||||
using (new AssertionScope())
|
||||
{
|
||||
createdAgreement.Created.Should().BeGreaterThan(SystemClock.Instance.GetCurrentInstant() - Duration.FromSeconds(5));
|
||||
createdAgreement.Created.Should().BeAfter(DateTimeOffset.Now.AddSeconds(-5));
|
||||
createdAgreement.Accepted.Should().BeNull();
|
||||
createdAgreement.MaxHistoricalDays.Should().Be(90);
|
||||
createdAgreement.AccessValidForDays.Should().Be(90);
|
||||
|
||||
+2
-3
@@ -2,14 +2,13 @@
|
||||
// Licensed under the Apache License 2.0.
|
||||
// See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using NodaTime;
|
||||
|
||||
using VMelnalksnis.NordigenDotNet.Requisitions;
|
||||
|
||||
using Xunit.Abstractions;
|
||||
@@ -66,7 +65,7 @@ public sealed class RequisitionsClientTests : IClassFixture<ServiceProviderFixtu
|
||||
using (new AssertionScope())
|
||||
{
|
||||
requisition.Should().BeEquivalentTo(createdRequisition);
|
||||
requisition.Created.Should().BeGreaterThan(SystemClock.Instance.GetCurrentInstant() - Duration.FromSeconds(5));
|
||||
requisition.Created.Should().BeAfter(DateTimeOffset.Now.AddSeconds(5));
|
||||
requisition.Redirect.Should().Be(creation.Redirect);
|
||||
requisition.Status.Should().Be(RequisitionStatus.Cr);
|
||||
requisition.InstitutionId.Should().BeEquivalentTo(creation.InstitutionId);
|
||||
|
||||
@@ -16,10 +16,11 @@ public sealed class RoutesTests
|
||||
[ClassData(typeof(TransactionsUriTestData))]
|
||||
public void TransactionsUri_ShouldHaveExpectedQueryParameters(
|
||||
Guid id,
|
||||
Interval? interval,
|
||||
DateTimeOffset? dateFrom,
|
||||
DateTimeOffset? dateTo,
|
||||
NameValueCollection expectedParameters)
|
||||
{
|
||||
var uriValue = Routes.Accounts.TransactionsUri(id, interval);
|
||||
var uriValue = Routes.Accounts.TransactionsUri(id, dateFrom, dateTo);
|
||||
var uriBuilder = new UriBuilder(uriValue);
|
||||
|
||||
var queryDictionary = HttpUtility.ParseQueryString(uriBuilder.Query);
|
||||
|
||||
@@ -17,15 +17,15 @@ internal sealed class TransactionsUriTestData : IEnumerable<object?[]>
|
||||
{
|
||||
yield return new object?[] { Guid.NewGuid(), null, new NameValueCollection() };
|
||||
|
||||
var dateFrom = Instant.FromUtc(2022, 05, 01, 12, 00);
|
||||
var dateTo = Instant.FromUtc(2022, 05, 12, 13, 00);
|
||||
var dateFrom = new DateTimeOffset(2022, 05, 01, 12, 00, 00, TimeSpan.Zero);
|
||||
var dateTo = new DateTimeOffset(2022, 05, 12, 13, 00, 00, TimeSpan.Zero);
|
||||
var collection = new NameValueCollection
|
||||
{
|
||||
{ "date_from", "2022-05-01" },
|
||||
{ "date_to", "2022-05-12" },
|
||||
};
|
||||
|
||||
yield return new object?[] { Guid.NewGuid(), new Interval(dateFrom, dateTo), collection };
|
||||
yield return new object?[] { Guid.NewGuid(), dateFrom, dateTo, collection };
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
||||
Reference in New Issue
Block a user