about summary refs log tree commit diff
path: root/Tests/LibMatrix.Tests/Fixtures/TestFixture.cs
blob: ef49b3ea9c29b93ea32f13ed7b5234480511a902 (plain) (blame)
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
37
using ArcaneLibs.Extensions;
using LibMatrix.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Xunit.Microsoft.DependencyInjection;
using Xunit.Microsoft.DependencyInjection.Abstracts;

namespace LibMatrix.Tests.Fixtures;

public class TestFixture : TestBedFixture {
    protected override void AddServices(IServiceCollection services, IConfiguration? configuration) {
        services.AddSingleton<TieredStorageService>(x =>
            new TieredStorageService(
                cacheStorageProvider: null,
                dataStorageProvider: null
            )
        );

        services.AddRoryLibMatrixServices();

        services.AddSingleton<Config>(config => {
            var conf = new Config();
            configuration?.GetSection("Configuration").Bind(conf);

            File.WriteAllText("configuration.json", conf.ToJson());

            return conf;
        });
    }

    protected override ValueTask DisposeAsyncCore()
        => new();

    protected override IEnumerable<TestAppSettings> GetTestAppSettings() {
        yield return new TestAppSettings { Filename = "appsettings.json", IsOptional = true };
    }
}