aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/IOL.VippsEcommerce.Tests/ConfigurationTests.cs (renamed from src/IOL.VippsEcommerce.Tests/Integration/InitialisationTests.cs)25
-rw-r--r--src/IOL.VippsEcommerce.Tests/Helpers.cs30
-rw-r--r--src/IOL.VippsEcommerce.Tests/PaymentInitiationTests.cs13
-rw-r--r--src/IOL.VippsEcommerce.Tests/configuration.json14
4 files changed, 60 insertions, 22 deletions
diff --git a/src/IOL.VippsEcommerce.Tests/Integration/InitialisationTests.cs b/src/IOL.VippsEcommerce.Tests/ConfigurationTests.cs
index 6035c15..aa05a7d 100644
--- a/src/IOL.VippsEcommerce.Tests/Integration/InitialisationTests.cs
+++ b/src/IOL.VippsEcommerce.Tests/ConfigurationTests.cs
@@ -1,11 +1,9 @@
-using System.Collections.Generic;
-using System.Text.Json;
using IOL.VippsEcommerce.Models;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
using Xunit.Abstractions;
-namespace IOL.VippsEcommerce.Tests.Integration
+namespace IOL.VippsEcommerce.Tests
{
public class InitialisationTests
{
@@ -17,29 +15,19 @@ namespace IOL.VippsEcommerce.Tests.Integration
[Fact]
public void Succeed_On_Valid_Minimal_Configuration() {
- var services = new ServiceCollection();
- services.AddVippsEcommerceService(o => {
+ var vippsEcommerceService = Helpers.GetVippsEcommerceService(o => {
o.ApiUrl = "https://validuri.no";
o.ClientId = "asdf";
o.ClientSecret = "asdf";
o.SecondarySubscriptionKey = "asdf";
});
- var provider = services.BuildServiceProvider();
- var vippsEcommerceService = provider.GetService<IVippsEcommerceService>();
- if (vippsEcommerceService == default) {
- _helper.WriteLine(nameof(IVippsEcommerceService) + " was default");
- return;
- }
vippsEcommerceService.Configuration.Verify();
- Assert.True(true);
}
-
[Fact]
public void Configuration_Follows_Through_Initialisation() {
- var services = new ServiceCollection();
- services.AddVippsEcommerceService(o => {
+ var vippsEcommerceService = Helpers.GetVippsEcommerceService(o => {
o.ApiUrl = "https://validuri.no";
o.ClientId = "asdf";
o.ClientSecret = "asdf";
@@ -54,13 +42,6 @@ namespace IOL.VippsEcommerce.Tests.Integration
o.CacheEncryptionKey = "asdf";
o.ConfigurationMode = VippsConfigurationMode.ONLY_OBJECT;
});
- var provider = services.BuildServiceProvider();
- var vippsEcommerceService = provider.GetService<IVippsEcommerceService>();
-
- if (vippsEcommerceService == default) {
- _helper.WriteLine(nameof(IVippsEcommerceService) + " was default");
- return;
- }
foreach (var prop in typeof(VippsConfiguration).GetProperties()) {
var value = prop.GetValue(vippsEcommerceService.Configuration, null);
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
diff --git a/src/IOL.VippsEcommerce.Tests/PaymentInitiationTests.cs b/src/IOL.VippsEcommerce.Tests/PaymentInitiationTests.cs
new file mode 100644
index 0000000..d802fb1
--- /dev/null
+++ b/src/IOL.VippsEcommerce.Tests/PaymentInitiationTests.cs
@@ -0,0 +1,13 @@
+using Xunit.Abstractions;
+
+namespace IOL.VippsEcommerce.Tests
+{
+ public class PaymentInitiationTests
+ {
+ private readonly ITestOutputHelper _helper;
+
+ public PaymentInitiationTests(ITestOutputHelper helper) {
+ _helper = helper;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce.Tests/configuration.json b/src/IOL.VippsEcommerce.Tests/configuration.json
new file mode 100644
index 0000000..6f88533
--- /dev/null
+++ b/src/IOL.VippsEcommerce.Tests/configuration.json
@@ -0,0 +1,14 @@
+{
+ "ApiUrl": "",
+ "ClientId": "",
+ "ClientSecret": "",
+ "PrimarySubscriptionKey": "",
+ "SecondarySubscriptionKey": "",
+ "MerchantSerialNumber": "",
+ "SystemName": "",
+ "SystemVersion": "",
+ "SystemPluginName": "",
+ "SystemPluginVersion": "",
+ "CacheDirectoryPath": "",
+ "CacheEncryptionKey": ""
+} \ No newline at end of file