Beispiel #1
0
        public void AsyncRequestScoresTest()
        {
            // Test that requesting scores work properly
            ScoresResponse?r = null;

            lb.RequestScoresAsync(uniqueLevelName,
                                  delegate(ScoresResponse response, ServerException error) {
                r = response;
                callbackDone.Set();
            });
            callbackDone.WaitOne();

            // Confirm the server returns at least 1 score
            Assert.IsTrue(r.HasValue);
            Assert.GreaterOrEqual(r.Value.leaders.Length, 1);
        }
Beispiel #2
0
        public void AsyncUnableToConnectToServer()
        {
            // Test that if the server is unreachable, an error returned
            // And make sure that even if the request fails, the response is
            // still valid
            lb = new Leaderboards("localhost", 9999);

            ServerException ex = null;
            ScoresResponse? r  = null;

            lb.RequestScoresAsync(uniqueLevelName,
                                  delegate(ScoresResponse response, ServerException error) {
                r  = response;
                ex = error;
                callbackDone.Set();
            });
            callbackDone.WaitOne();

            // make sure an error was returned
            Assert.NotNull(ex);

            // make sure the response is valid
            Assert.IsTrue(r.HasValue);
            Assert.AreEqual(r.Value.level, uniqueLevelName);
            Assert.IsNull(r.Value.leaders);
        }
Beispiel #3
0
 public void AsyncInvalidServerPort2()
 {
     // Test that if the server port is invalid, an exception is thrown
     lb = new Leaderboards("localhost", (int)Math.Pow(2, 16));
     lb.RequestScoresAsync(uniqueLevelName, null);
 }
Beispiel #4
0
 public void AsyncInvalidServerHost()
 {
     // Test that if the server host is invalid, an exception is thrown
     lb = new Leaderboards("gibberish" + Guid.NewGuid(), 2693);
     lb.RequestScoresAsync(uniqueLevelName, null);
 }
Beispiel #5
0
 // fetches the actual leaderboard scores
 protected void LoadLevelStats()
 {
     DisplayMessage("Loading scores for " + currentLevelName);
     lb.RequestScoresAsync(currentLevelName,
                           new Action <ScoresResponse, ServerException>(OnServerResponse));
 }