blob: 05530274bc2e4f52616ad5ab175e281b136485d4 (
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
|
using System;
using System.Net;
using System.Text.Json;
using IOL.VippsEcommerce.Models;
using Microsoft.Extensions.DependencyInjection;
using Xunit.Sdk;
namespace IOL.VippsEcommerce.Tests
{
public static class Helpers
{
public static IVippsEcommerceService GetVippsEcommerceService(Action<VippsConfiguration> conf) {
var services = new ServiceCollection();
services.AddVippsEcommerceService(conf);
var provider = services.BuildServiceProvider();
var vippsEcommerceService = provider.GetService<IVippsEcommerceService>();
if (vippsEcommerceService == default) {
throw new NullException(nameof(vippsEcommerceService));
}
return vippsEcommerceService;
}
public static VippsConfiguration GetVippsValidConfiguration() {
var json = System.IO.File.ReadAllText("configuration.json");
var configuration = JsonSerializer.Deserialize<VippsConfiguration>(json);
return configuration;
}
}
}
|