49 lines
1.8 KiB
C#
49 lines
1.8 KiB
C#
using Bogus;
|
|
using Knoks.Core;
|
|
using Knoks.Framework.Services;
|
|
using Microsoft.Extensions.Logging;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Xunit;
|
|
|
|
namespace Knoks.Test.Integrations.Framework
|
|
{
|
|
public class TwilioPhoneServiceTests
|
|
{
|
|
static Randomizer _randomizer = new Randomizer();
|
|
static TwilioPhoneService _twilioService = new TwilioPhoneService(new Logger<TwilioPhoneService>(new LoggerFactory()),
|
|
new TwilioPhoneSettings
|
|
{
|
|
AccountSid = "ACd9847cf167126a6df23867a0bb7e4f34",
|
|
AuthToken = "b95f607caa90d393080b6871bef046c0",
|
|
});
|
|
|
|
[Theory(DisplayName = "Phone Loockup - Ok")]
|
|
[InlineData("+972(054)#123456", null, "IL")]
|
|
[InlineData("(054)#123456", "IL", "IL")]
|
|
[InlineData("+7-926-#123456", null, "RU")]
|
|
[InlineData("8(900)312-34-56", "RU", "RU")]
|
|
[InlineData("+44-1689-123456", null, "GB")]
|
|
[InlineData("+19135123456", null, "US")]
|
|
[InlineData("(913) 512-3456", "US", "US")]
|
|
[InlineData("+491573#123456", null, "DE")]
|
|
[InlineData("01573 #123456", "DE", "DE")]
|
|
public async Task TwilioLoockupOk(string number, string countryCode, string expectedCountryCode)
|
|
{
|
|
|
|
var phone = await _twilioService.Lookup(_randomizer.Replace(number), countryCode);
|
|
Assert.Equal(expectedCountryCode, phone.CountryCode2);
|
|
}
|
|
|
|
[Theory(DisplayName = "Phone Loockup - Error")]
|
|
[InlineData("972054", null)]
|
|
[InlineData("054", "IL")]
|
|
[InlineData("+972(012)1234567", "IL")]
|
|
public async Task TwilioLoockupError(string number, string countryCode)
|
|
{
|
|
var phone = await _twilioService.Lookup(number, countryCode);
|
|
Assert.Null(phone);
|
|
}
|
|
}
|
|
}
|