-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding correct regex for FI and NO phones
Incl Tests
- Loading branch information
Showing
3 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
using System; | ||
using System.Globalization; | ||
using Klarna.Offline; | ||
using Klarna.Offline.Entities; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Klarna.Entities; | ||
using MerchantConfig = Klarna.Offline.Entities.MerchantConfig; | ||
|
||
namespace OfflineTest | ||
{ | ||
[TestClass] | ||
public class OfflineOrderTest | ||
{ | ||
[TestMethod] | ||
public void MustValidateSwedishPhone() | ||
{ | ||
OfflineOrder t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("sv-se"), "SEK", "SE", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+46700024576", | ||
"ref"); | ||
} | ||
|
||
[TestMethod] | ||
public void MustValidateNorwegianPhone() | ||
{ | ||
OfflineOrder t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("nb-no"), "NOK", "NO", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+4790000000", | ||
"ref"); | ||
t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("nb-no"), "NOK", "NO", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+4740000000", | ||
"ref"); | ||
t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("nb-no"), "NOK", "NO", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+4759000000", | ||
"ref"); | ||
|
||
} | ||
|
||
[TestMethod] | ||
public void MustValidateFinnishPhone() | ||
{ | ||
OfflineOrder t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("fi-fi"), "EUR", "FI", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+358401234567", | ||
"ref"); | ||
t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("fi-fi"), "EUR", "FI", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+358501234", | ||
"ref"); | ||
t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("fi-fi"), "EUR", "FI", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+35845733654578", | ||
"ref"); | ||
t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("fi-fi"), "EUR", "FI", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+35850457894", | ||
"ref"); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentException))] | ||
public void MustThrowErrorOnToLongFIPhone() | ||
{ | ||
OfflineOrder t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("fi-fi"), "EUR", "FI", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+3584012345673332231312312", | ||
"ref"); | ||
} | ||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentException))] | ||
public void MustThrowErrorOnToShortFIPhone() | ||
{ | ||
OfflineOrder t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("fi-fi"), "EUR", "FI", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+35840123", | ||
"ref"); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentException))] | ||
public void MustThrowErrorOnWrongSEhone() | ||
{ | ||
OfflineOrder t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("sv-se"), "SEK", "SE", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+4670002457622", | ||
"ref"); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentException))] | ||
public void MustThrowErrorOnWrongNOPhone() | ||
{ | ||
OfflineOrder t = new OfflineOrder(new Cart(), | ||
new Klarna.Offline.Entities.MerchantConfig(CultureInfo.CreateSpecificCulture("nb-no"), "NOK", "NO", | ||
"testid", "testid", MerchantConfig.Server.Test), | ||
"test", | ||
"+47900000000", | ||
"ref"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters