public void ShouldListUsers(Cloud cloud) { Gamer[] gamers = new Gamer[2]; // Create first user cloud.Login(LoginNetwork.Email, "*****@*****.**", "123") .ExpectSuccess(result1 => { gamers[0] = result1; // Second user return cloud.Login(LoginNetwork.Email, "*****@*****.**", "123"); }) .ExpectSuccess(result2 => { gamers[1] = result2; // Query for a specific user by e-mail return cloud.ListUsers("*****@*****.**"); }) .ExpectSuccess(result => { Assert(result.Count == 1, "Expected one result only"); Assert(result[0].UserId == gamers[1].GamerId, "Expected to return user 2"); Assert(result[0].Network == LoginNetwork.Email, "Network is e-mail"); Assert(result[0].NetworkId == "*****@*****.**", "Invalid network ID"); Assert(result[0]["profile"]["displayName"] == "user2", "Invalid profile display name"); // Query for all users in a paginated way return cloud.ListUsers("@", 1); }) .ExpectSuccess(result => { Assert(result.Count == 1, "Expected one result per page"); Assert(result.Total >= 2, "Expected at least two results total"); Assert(result.HasNext, "Should have next page"); Assert(!result.HasPrevious, "Should not have previous page"); // Next page return result.FetchNext(); }) .ExpectSuccess(nextPage => { Assert(nextPage.HasPrevious, "Should have previous page"); CompleteTest(); }); }
public void ShouldChangePassword(Cloud cloud) { cloud.Login( network: LoginNetwork.Email, networkId: RandomEmailAddress(), networkSecret: "Password123") .Then(gamer => gamer.Account.ChangePassword("Password124")) .Then(pswResult => { Assert(pswResult, "Change password failed"); }) .CompleteTestIfSuccessful(); }
public void ShouldCheckIfUserExists(Cloud cloud) { // Ensures that a fake account has been created cloud.Login( network: LoginNetwork.Email, networkId: "*****@*****.**", networkSecret: "Password123") .Then(loginResult => cloud.UserExists( network: LoginNetwork.Email, networkId: "*****@*****.**")) .Then(checkResult => { Assert(checkResult, "UserExists failed"); cloud.UserExists(LoginNetwork.Email, "*****@*****.**") .ExpectFailure(dummy => { CompleteTest(); }); }); }
public void ShouldRestoreSession(Cloud cloud) { cloud.Login( network: LoginNetwork.Email, networkId: "*****@*****.**", networkSecret: "Password123") // Resume the session with the credentials just received .Then(gamer => cloud.ResumeSession( gamerId: gamer.GamerId, gamerSecret: gamer.GamerSecret)) .Then(resumeResult => { Assert(resumeResult != null, "Resume failed"); }) .CompleteTestIfSuccessful(); }
public void ShouldPreventRegistration(Cloud cloud) { // Resume the session with the credentials just received cloud.Login( network: LoginNetwork.Email, networkId: "*****@*****.**", networkSecret: "Password123", preventRegistration: true) .ExpectFailure(resumeResult => { Assert(resumeResult.HttpStatusCode == 400, "400 expected"); Assert(resumeResult.ServerData["name"] == "PreventRegistration", "PreventRegistration error expected"); CompleteTest(); }); }
public void ShouldLoginAndRunBatch(Cloud cloud) { Bundle batchNode = Bundle.CreateObject( "name", "nonexistingBatch", "domain", "private", "params", Bundle.CreateObject()); cloud.Login( network: LoginNetwork.Email, networkId: "*****@*****.**", networkSecret: "Password123", preventRegistration: false, additionalOptions: Bundle.CreateObject("thenBatch", batchNode) ).ExpectFailure(ex => { Assert(ex.ServerData["name"] == "HookError", "Message should be HookError"); Assert(ex.ServerData["message"].AsString().EndsWith("does not exist"), "Should indicate nonexisting batch"); CompleteTest(); }); }
public void ShouldFailToConvertToExistingAccount(Cloud cloud) { // Ensures that a fake account has been created cloud.Login( network: LoginNetwork.Email, networkId: "*****@*****.**", networkSecret: "Password123") .ExpectSuccess(dummyGamer => { // Create an anonymous account return cloud.LoginAnonymously(); }) .ExpectSuccess(gamer => { // Then try to convert it to the same e-mail as the fake account created at first gamer.Account.Convert( network: LoginNetwork.Email, networkId: "*****@*****.**", networkSecret: "Anotherp4ss") .ExpectFailure(conversionResult => { Assert(conversionResult.HttpStatusCode == 400, "400 expected"); Assert(conversionResult.ServerData["message"] == "UserExists", "UserExists error expected"); CompleteTest(); }); }); }
public void ShouldFailToChangeEmailAddressToExistingOne(Cloud cloud) { cloud.Login( network: LoginNetwork.Email, networkId: RandomEmailAddress(), networkSecret: "Password123") .ExpectSuccess(gamer => { gamer.Account.ChangeEmailAddress("*****@*****.**") .ExpectFailure(pswResult => { Assert(pswResult.HttpStatusCode == 400, "400 expected"); Assert(pswResult.ServerData["message"] == "UserExists", "UserExists error expected"); CompleteTest(); }); }); }