From 1719fd9f19f80a2f267abd68d70d102e7d58bf44 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Sun, 23 Oct 2016 18:44:37 +0800 Subject: [PATCH] Tests: avoid NullReferenceException Instead of throwing cryptic NullReferenceException when this test fails, let's give more information about what is going on, to the developer. --- TLSharp.Tests/TLSharpTests.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TLSharp.Tests/TLSharpTests.cs b/TLSharp.Tests/TLSharpTests.cs index c65ba68..ed03a6c 100644 --- a/TLSharp.Tests/TLSharpTests.cs +++ b/TLSharp.Tests/TLSharpTests.cs @@ -99,6 +99,12 @@ namespace TLSharp.Tests .Where(x => x.GetType() == typeof(TLUser)) .Cast() .FirstOrDefault(x => x.phone == NumberToSendMessage); + + if (user == null) + { + throw new System.Exception("Number was not found in Contacts List of user: " + NumberToSendMessage); + } + await client.SendTypingAsync(new TLInputPeerUser() { user_id = user.id }); Thread.Sleep(3000); await client.SendMessageAsync(new TLInputPeerUser() { user_id = user.id }, "TEST");