aboutsummaryrefslogtreecommitdiffstats
path: root/src/IOL.VippsEcommerce.Tests/Helpers.cs
blob: 53dd49b664e7487a2d46d597f1d67f940e04c59f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using System;
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;
	}
}