From adef68b7475014393424ea2f13e88bec4b373690 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Thu, 3 Nov 2016 01:33:56 +0800 Subject: [PATCH] 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. --- TLSharp.Tests/TLSharpTests.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/TLSharp.Tests/TLSharpTests.cs b/TLSharp.Tests/TLSharpTests.cs index 2d93942..3f7b594 100644 --- a/TLSharp.Tests/TLSharpTests.cs +++ b/TLSharp.Tests/TLSharpTests.cs @@ -134,6 +134,11 @@ namespace TLSharp.Tests if (string.IsNullOrWhiteSpace(NumberToSendMessage)) 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(); await client.ConnectAsync(); @@ -143,7 +148,7 @@ namespace TLSharp.Tests var user = result.users.lists .Where(x => x.GetType() == typeof(TLUser)) .Cast() - .FirstOrDefault(x => x.phone == NumberToSendMessage); + .FirstOrDefault(x => x.phone == normalizedNumber); if (user == null) { @@ -153,7 +158,6 @@ namespace TLSharp.Tests await client.SendTypingAsync(new TLInputPeerUser() { user_id = user.id }); Thread.Sleep(3000); await client.SendMessageAsync(new TLInputPeerUser() { user_id = user.id }, "TEST"); - } [TestMethod]