mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
SendNumberTest: remove the + from the phone number in app.config
NumberToAuthenticate works fine for the AuthTest if we put a "+" before our international prefix when writing the number, but because this test compares the numbers we got from the Contacts List with the one in app.config, it could not find it due to this prefix. Let's rather be prepared for that.
This commit is contained in:
parent
738a84937e
commit
adef68b747
|
|
@ -134,6 +134,11 @@ namespace TLSharp.Tests
|
||||||
if (string.IsNullOrWhiteSpace(NumberToSendMessage))
|
if (string.IsNullOrWhiteSpace(NumberToSendMessage))
|
||||||
throw new Exception($"Please fill the '{nameof(NumberToSendMessage)}' setting in app.config file first");
|
throw new Exception($"Please fill the '{nameof(NumberToSendMessage)}' setting in app.config file first");
|
||||||
|
|
||||||
|
// this is because the contacts in the address come without the "+" prefix
|
||||||
|
var normalizedNumber = NumberToSendMessage.StartsWith("+") ?
|
||||||
|
NumberToSendMessage.Substring(1, NumberToSendMessage.Length - 1) :
|
||||||
|
NumberToSendMessage;
|
||||||
|
|
||||||
var client = NewClient();
|
var client = NewClient();
|
||||||
|
|
||||||
await client.ConnectAsync();
|
await client.ConnectAsync();
|
||||||
|
|
@ -143,7 +148,7 @@ namespace TLSharp.Tests
|
||||||
var user = result.users.lists
|
var user = result.users.lists
|
||||||
.Where(x => x.GetType() == typeof(TLUser))
|
.Where(x => x.GetType() == typeof(TLUser))
|
||||||
.Cast<TLUser>()
|
.Cast<TLUser>()
|
||||||
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
.FirstOrDefault(x => x.phone == normalizedNumber);
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
|
|
@ -153,7 +158,6 @@ namespace TLSharp.Tests
|
||||||
await client.SendTypingAsync(new TLInputPeerUser() { user_id = user.id });
|
await client.SendTypingAsync(new TLInputPeerUser() { user_id = user.id });
|
||||||
Thread.Sleep(3000);
|
Thread.Sleep(3000);
|
||||||
await client.SendMessageAsync(new TLInputPeerUser() { user_id = user.id }, "TEST");
|
await client.SendMessageAsync(new TLInputPeerUser() { user_id = user.id }, "TEST");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue