public void SyncRequestScoresTest() { // Test that requesting scores work properly ScoresResponse r = lb.RequestScores(uniqueLevelName); // Confirm the server returns at least 1 score Assert.GreaterOrEqual(r.leaders.Length, 1); }
public void SyncSubmittingTest() { // Test that submitting a score works properly Score submittedScore = new Score(1, "abc", "xyz"); lb.SubmitScore(uniqueLevelName, submittedScore); // Confirm the top score is the one just submitted ScoresResponse r = lb.RequestScores(uniqueLevelName); Assert.AreEqual(submittedScore, r.leaders[0]); }
public void AsyncNullCallbackIsAllowed() { // Test that submitting a score works properly // Test that passing a null callback is okay Score submittedScore = new Score(1, "abc", "xyz"); lb.SubmitScoreAsync(uniqueLevelName, submittedScore, null); Thread.Sleep(1000); // wait a second // Confirm the top score is the one just submitted // Note: uses synchronous RequestScores for simplicity ScoresResponse r = lb.RequestScores(uniqueLevelName); Assert.AreEqual(submittedScore, r.leaders[0]); }
// callback for when server responds void OnServerResponse(ScoresResponse scores, ServerException error) { // make sure this response isn't out of date if (scores.level == currentLevelName) { if (error != null) { QueueMessage("Unable to contact server, please check your connection."); } else if (scores.leaders != null) { QueueNames(scores.leaders); } } }
public void AsyncSubmittingTest() { // Test that submitting a score works properly Score submittedScore = new Score(1, "abc", "xyz"); lb.SubmitScoreAsync(uniqueLevelName, submittedScore, delegate(SubmissionResponse response, ServerException error) { callbackDone.Set(); }); callbackDone.WaitOne(); // Confirm the top score is the one just submitted // Note: uses synchronous RequestScores for simplicity ScoresResponse r = lb.RequestScores(uniqueLevelName); Assert.AreEqual(submittedScore, r.leaders[0]); }