get apiHash and apiId in the constructor

This commit is contained in:
ahmadali shafiee 2016-04-18 15:35:30 +04:30
parent 504b63a6d7
commit 4a44709150
2 changed files with 18 additions and 12 deletions

View file

@ -19,6 +19,10 @@ namespace TLSharp.Tests
private string UserNameToSendMessage { get; set; }
private string apiHash = "";
private int apiId = 0;
[TestInitialize]
public void Init()
{
@ -41,7 +45,7 @@ namespace TLSharp.Tests
public async Task AuthUser()
{
var store = new FileSessionStore();
var client = new TelegramClient(store, "session");
var client = new TelegramClient(store, "session", apiHash, apiId);
await client.Connect();
@ -57,7 +61,7 @@ namespace TLSharp.Tests
public async Task CheckPhones()
{
var store = new FileSessionStore();
var client = new TelegramClient(store, "session");
var client = new TelegramClient(store, "session", apiHash, apiId);
await client.Connect();
var result = await client.IsPhoneRegistered(NumberToAuthenticate);
@ -70,7 +74,7 @@ namespace TLSharp.Tests
// User should be already authenticated!
var store = new FileSessionStore();
var client = new TelegramClient(store, "session");
var client = new TelegramClient(store, "session", apiHash, apiId);
await client.Connect();
@ -85,7 +89,7 @@ namespace TLSharp.Tests
public async Task ImportByUserName()
{
var store = new FileSessionStore();
var client = new TelegramClient(store, "session");
var client = new TelegramClient(store, "session", apiHash, apiId);
await client.Connect();
@ -100,7 +104,7 @@ namespace TLSharp.Tests
public async Task ImportByUserNameAndSendMessage()
{
var store = new FileSessionStore();
var client = new TelegramClient(store, "session");
var client = new TelegramClient(store, "session", apiHash, apiId);
await client.Connect();
@ -119,7 +123,7 @@ namespace TLSharp.Tests
// User should be already authenticated!
var store = new FileSessionStore();
var client = new TelegramClient(store, "session");
var client = new TelegramClient(store, "session", apiHash, apiId);
await client.Connect();
Assert.IsTrue(client.IsUserAuthorized());
@ -135,7 +139,7 @@ namespace TLSharp.Tests
public async Task GetHistory()
{
var store = new FileSessionStore();
var client = new TelegramClient(store, "session");
var client = new TelegramClient(store, "session", apiHash, apiId);
await client.Connect();
Assert.IsTrue(client.IsUserAuthorized());
@ -153,7 +157,7 @@ namespace TLSharp.Tests
public async Task UploadAndSendMedia()
{
var store = new FileSessionStore();
var client = new TelegramClient(store, "session");
var client = new TelegramClient(store, "session", apiHash, apiId);
await client.Connect();
Assert.IsTrue(client.IsUserAuthorized());
@ -178,7 +182,7 @@ namespace TLSharp.Tests
public async Task TestConnection()
{
var store = new FakeSessionStore();
var client = new TelegramClient(store, "");
var client = new TelegramClient(store, "", apiHash, apiId);
Assert.IsTrue(await client.Connect());
}