-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ServiceCollectionExtensionsTests.cs
36 lines (28 loc) · 1.06 KB
/
ServiceCollectionExtensionsTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NodaTime;
namespace VMelnalksnis.NordigenDotNet.DependencyInjection.Tests;
public sealed class ServiceCollectionExtensionsTests
{
[Fact]
public void AddNordigenDotNet_ShouldRegisterRequiredServices()
{
var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(new List<KeyValuePair<string, string?>>
{
new($"{NordigenOptions.SectionName}:{nameof(NordigenOptions.SecretId)}", $"{Guid.NewGuid():D}"),
new($"{NordigenOptions.SectionName}:{nameof(NordigenOptions.SecretKey)}", $"{Guid.NewGuid():N}"),
})
.Build();
var serviceCollection = new ServiceCollection();
serviceCollection
.AddSingleton<IClock>(SystemClock.Instance)
.AddSingleton(DateTimeZoneProviders.Tzdb)
.AddNordigenDotNet(configuration);
var serviceProvider = serviceCollection.BuildServiceProvider();
var nordigenClient = serviceProvider.GetRequiredService<INordigenClient>();
nordigenClient.Should().NotBeNull();
}
}