mirror of
https://github.com/sochix/TLSharp.git
synced 2026-04-06 06:55:06 +00:00
Add proper exception messages
This commit is contained in:
parent
27216da193
commit
b0a824988d
3 changed files with 33 additions and 5 deletions
|
|
@ -21,15 +21,30 @@ namespace TLSharp.Tests
|
|||
{
|
||||
// Setup your phone numbers in app.config
|
||||
NumberToAuthenticate = ConfigurationManager.AppSettings["numberToAuthenticate"];
|
||||
if (string.IsNullOrEmpty(NumberToAuthenticate))
|
||||
throw new InvalidOperationException("NumberToAuthenticate is null");
|
||||
|
||||
RegisteredNumber = ConfigurationManager.AppSettings["registeredNumber"];
|
||||
if (string.IsNullOrEmpty(RegisteredNumber))
|
||||
throw new InvalidOperationException("RegisteredNumber is null");
|
||||
|
||||
UnregisteredNumber = ConfigurationManager.AppSettings["unregisteredNumber"];
|
||||
}
|
||||
if (string.IsNullOrEmpty(UnregisteredNumber))
|
||||
throw new InvalidOperationException("UnregisteredNumber is null");
|
||||
|
||||
if (NumberToAuthenticate == UnregisteredNumber)
|
||||
throw new InvalidOperationException("NumberToAuthenticate eqauls UnregisteredNumber but shouldn't!");
|
||||
|
||||
if (RegisteredNumber == UnregisteredNumber)
|
||||
throw new InvalidOperationException("RegisteredNumber eqauls UnregisteredNumber but shouldn't!");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task AuthUser()
|
||||
{
|
||||
var store = new FileSessionStore();
|
||||
var client = new TelegramClient(store, "session");
|
||||
|
||||
await client.Connect();
|
||||
|
||||
var hash = await client.SendCodeRequest(NumberToAuthenticate);
|
||||
|
|
@ -70,6 +85,7 @@ namespace TLSharp.Tests
|
|||
|
||||
var store = new FileSessionStore();
|
||||
var client = new Core.TelegramClient(store, "session");
|
||||
|
||||
await client.Connect();
|
||||
|
||||
Assert.IsTrue(client.IsUserAuthorized());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue