diff options
Diffstat (limited to 'src/IOL.VippsEcommerce.Tests/Helpers.cs')
| -rw-r--r-- | src/IOL.VippsEcommerce.Tests/Helpers.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/IOL.VippsEcommerce.Tests/Helpers.cs b/src/IOL.VippsEcommerce.Tests/Helpers.cs new file mode 100644 index 0000000..0553027 --- /dev/null +++ b/src/IOL.VippsEcommerce.Tests/Helpers.cs @@ -0,0 +1,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; + } + } +}
\ No newline at end of file |
