public void LoginGoogle_Invalid([ValueSource("BlankCases")] string oauthToken) { ManualResetEvent evt = new ManualResetEvent(false); INError result = null; INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Google(oauthToken); client.Login(message, (INSession session) => { evt.Set(); }, (INError error) => { result = error; evt.Set(); }); evt.WaitOne(500, false); Assert.NotNull(result); if (oauthToken == string.Empty) { Assert.AreEqual("Access token is required", result.Message); } else { Assert.AreEqual("Invalid Google access token, no spaces or control characters allowed", result.Message); } }
public void LoginEmail_Valid() { ManualResetEvent evt = new ManualResetEvent(false); INSession result = null; string piece = random.GetString().Substring(8); string email = String.Format("{0}@{0}.com", piece); string password = TestContext.CurrentContext.Random.GetString(); INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Email(email, password); client.Register(message, (INSession _) => { client.Login(message, (INSession session) => { result = session; evt.Set(); }, (INError error) => { evt.Set(); }); }, (INError error) => { evt.Set(); }); evt.WaitOne(1000, false); Assert.NotNull(result); Assert.NotNull(result.Token); }
public void RegisterCustom_Invalid([ValueSource("BlankCases")] string id) { ManualResetEvent evt = new ManualResetEvent(false); INError result = null; INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Custom(id); client.Register(message, (INSession session) => { evt.Set(); }, (INError error) => { result = error; evt.Set(); }); evt.WaitOne(500, false); Assert.NotNull(result); if (id == string.Empty) { Assert.AreEqual("Custom ID is required", result.Message); } else { Assert.AreEqual("Invalid custom ID, no spaces or control characters allowed", result.Message); } }
public void LoginEmail_Invalid([ValueSource("BlankCases")] string email, [ValueSource("BlankCases")] string password) { ManualResetEvent evt = new ManualResetEvent(false); INError result = null; INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Email(email, password); client.Login(message, (INSession session) => { evt.Set(); }, (INError error) => { result = error; evt.Set(); }); evt.WaitOne(500, false); Assert.NotNull(result); if (email == string.Empty) { Assert.AreEqual("Email address is required", result.Message); } else { Assert.AreEqual("Invalid email address, no spaces or control characters allowed", result.Message); } }
public void LoginDevice_Valid() { ManualResetEvent evt = new ManualResetEvent(false); INSession result = null; string id = random.GetString(); INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Device(id); client.Register(message, (INSession _) => { client.Login(message, (INSession session) => { result = session; evt.Set(); }, (INError error) => { evt.Set(); }); }, (INError error) => { evt.Set(); }); evt.WaitOne(1000, false); Assert.NotNull(result); Assert.NotNull(result.Token); }
private static INError RegisterEmailError(string email, string password) { ManualResetEvent evt = new ManualResetEvent(false); INError result = null; INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Email(email, password); client.Register(message, (INSession session) => { evt.Set(); }, (INError error) => { result = error; evt.Set(); }); evt.WaitOne(500, false); return(result); }
public void RegisterCustom_Valid() { ManualResetEvent evt = new ManualResetEvent(false); INSession result = null; INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Custom(random.GetString()); client.Register(message, (INSession session) => { result = session; evt.Set(); }, (INError error) => { evt.Set(); }); evt.WaitOne(500, false); Assert.NotNull(result); Assert.NotNull(result.Token); }
public void LoginSteam_Invalid([ValueSource("BlankCases")] string sessionToken) { ManualResetEvent evt = new ManualResetEvent(false); INError result = null; INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Steam(sessionToken); client.Login(message, (INSession session) => { evt.Set(); }, (INError error) => { result = error; evt.Set(); }); evt.WaitOne(500, false); Assert.NotNull(result); Assert.AreEqual("Steam login not available", result.Message); }
public void LoginDevice_Invalid_NoId() { ManualResetEvent evt = new ManualResetEvent(false); INError result = null; string id = random.GetString(); INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Device(id); client.Login(message, (INSession session) => { evt.Set(); }, (INError error) => { result = error; evt.Set(); }); evt.WaitOne(500, false); Assert.NotNull(result); Assert.AreEqual("ID not found", result.Message); }
public void GetServerTime_Valid() { ManualResetEvent evt = new ManualResetEvent(false); long serverTime = 0; string id = TestContext.CurrentContext.Random.GetString(); INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Device(id); client.Register(message, (INSession session) => { client.Connect(session); Thread.Sleep(500); serverTime = client.ServerTime; evt.Set(); }, (INError _) => { evt.Set(); }); evt.WaitOne(1000, false); Assert.That(serverTime, Is.Not.EqualTo(0)); client.Disconnect(); }
public void Connect_Valid() { ManualResetEvent evt = new ManualResetEvent(false); var connected = false; string id = TestContext.CurrentContext.Random.GetString(); INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Device(id); client.Register(message, (INSession session) => { client.Connect(session, (bool _) => { connected = true; evt.Set(); }); }, (INError _) => { evt.Set(); }); evt.WaitOne(500, false); Assert.IsTrue(connected); client.Disconnect(); }
public void LoginEmail_Invalid_Email() { ManualResetEvent evt = new ManualResetEvent(false); INError result = null; string email = random.GetString(); string password = random.GetString(); INClient client = NClient.Default(DefaultServerKey); var message = NAuthenticateMessage.Email(email, password); client.Login(message, (INSession session) => { evt.Set(); }, (INError error) => { result = error; evt.Set(); }); evt.WaitOne(500, false); Assert.NotNull(result); Assert.AreEqual("Invalid email address format", result.Message); }