public async Task It_Creates_The_Game() { //--arrange var numberOfHumanPlayers = 2; var newGame = new NewGameRequest(TestUserName, numberOfHumanPlayers); //--act var result = await GamesClient.CreateGame(newGame, TestEnvironmentSettings.BaseApiUrl); //--assert result.NumberOfHumanPlayers.ShouldBe(newGame.NumberOfHumanPlayers); result.NumberOfAiPlayers.ShouldBe(newGame.NumberOfAiPlayers); result.GridSize.ShouldBe(50); result.Id.ShouldBeGreaterThan(0); result.Status.ShouldBe(GameStatus.NotStarted); result.GenerationNumber.ShouldBe(0); result.RoundNumber.ShouldBe(0); result.TotalDeadCells.ShouldBe(0); result.TotalRegeneratedCells.ShouldBe(0); result.TotalLiveCells.ShouldBe(0); result.EndOfGameCountDown.ShouldBeNull(); result.GrowthCycles.ShouldNotBeNull(); //--there should be no growth cycles if the game hasn't started result.GrowthCycles.Count.ShouldBe(0); result.StartingGameState.ShouldBeNull(); }
private XboxClient(Connection connection) { Profile = new ProfileClient(connection); Friends = new FriendsClient(connection); Games = new GamesClient(connection); Achievements = new AchievementsClient(connection); Search = new SearchClient(connection); }
public void FullGameTest() { var client = new GamesClient(GetApiKey()); client.GetGame(2015, 2266, true, true, true); TryDeserialize <DataArrayContainer <Game> >(client.LastResponse); }
public void ListOfGamesTest() { var client = new GamesClient(GetApiKey()); client.GetGames(season: 2015); TryDeserialize <DataArrayContainer <Game> >(client.LastResponse); }
/* "premium_upgrade", ReservedTestProductIDs.Purchased, ReservedTestProductIDs.Canceled, ReservedTestProductIDs.Refunded, ReservedTestProductIDs.Unavailable, */ /// <summary> /// See parent. /// </summary> /// <param name="bundle"></param> protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Create the interface used to interact with Google Play. mGooglePlayClient = new GamesClient.Builder(this, this, this) .SetGravityForPopups((int)(GravityFlags.Bottom | GravityFlags.CenterHorizontal)) .Create(); pGooglePlayClient.RegisterConnectionCallbacks (this); pGooglePlayClient.IsConnectionFailedListenerRegistered (this); // Create a new connection to the Google Play Service mBillingConnection = new InAppBillingServiceConnection (this, InAppBillingKey.Key); pBillingConnection.OnConnected += async () => { // Clear out the test purchase so that it can be tested again. Remove this // to test starting with test purchase already completed. //bool response = pBillingConnection.BillingHandler.ConsumePurchase("inapp:"+ PackageName +":android.test.purchased"); // Attach to the various error handlers to report issues pBillingConnection.BillingHandler.OnGetProductsError += (int responseCode, Bundle ownedItems) => { Console.WriteLine("Error getting products"); }; pBillingConnection.BillingHandler.OnInvalidOwnedItemsBundleReturned += (Bundle ownedItems) => { Console.WriteLine("Invalid owned items bundle returned"); }; pBillingConnection.BillingHandler.OnProductPurchasedError += (int responseCode, string sku) => { Console.WriteLine("Error purchasing item {0}",sku); }; pBillingConnection.BillingHandler.OnPurchaseConsumedError += (int responseCode, string token) => { Console.WriteLine("Error consuming previous purchase"); }; pBillingConnection.BillingHandler.InAppBillingProcesingError += (message) => { Console.WriteLine("In app billing processing error {0}",message); }; // Load inventory or available products await GetInventory(); // Load any items already purchased UpdatePurchasedItems(); }; // Create our OpenGL view, and display it Game1.Activity = this; var g = new Game1 (); SetContentView (g.Window); g.Run (); }
public async Task It_Returns_The_Specified_Game() { //--arrange var newGame = await CreateValidGameForTesting(TestUserName, numberOfHumanPlayers : 1); //--act var gameState = await GamesClient.GetGameState(newGame.Id, TestEnvironmentSettings.BaseApiUrl); //--assert gameState.Id.ShouldBe(newGame.Id); gameState.NumberOfHumanPlayers.ShouldBe(newGame.NumberOfHumanPlayers); gameState.NumberOfAiPlayers.ShouldBe(newGame.NumberOfAiPlayers); }
public async Task It_Returns_A_400_Bad_Request_If_The_User_Has_Already_Joined_The_Game() { //--arrange var newGame = await CreateValidGameForTesting(TestUserName, 2, 0); var joinGameResult = new JoinGameRequest(newGame.Id, TestUserName); //--act var exception = Assert.ThrowsAsync <ApiException>(async() => await GamesClient.JoinGame(joinGameResult, TestEnvironmentSettings.BaseApiUrl)); //--assert exception.ResponseStatusCode.ShouldBe(HttpStatusCode.BadRequest); }
public async Task It_Returns_A_409_Conflict_If_The_Game_Is_Already_Full() { //--arrange var newGame = await CreateValidGameForTesting(TestUserName, 1, 0); var joinGameResult = new JoinGameRequest(newGame.Id, "some user name"); //--act var exception = Assert.ThrowsAsync <ApiException>(async() => await GamesClient.JoinGame(joinGameResult, TestEnvironmentSettings.BaseApiUrl)); //--assert exception.ResponseStatusCode.ShouldBe(HttpStatusCode.Conflict); }
public void AcceptInvite(string invitationId) { //auto accept _roomFragment = new RoomFragment(); SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.FragmentContainer, _roomFragment) .Commit(); var builder = RoomConfig.InvokeBuilder(this); builder.SetInvitationIdToAccept(invitationId); builder.SetMessageReceivedListener(this); GamesClient.JoinRoom(builder.Build()); Window.AddFlags(WindowManagerFlags.KeepScreenOn); }
public async Task It_Returns_The_Active_Skills() { //--arrange //--act var activeSkills = await GamesClient.GetActiveSkills(TestEnvironmentSettings.BaseApiUrl); //--assert activeSkills.ShouldNotBeNull(); activeSkills.Count.ShouldBeGreaterThan(0); foreach (var activeSkill in activeSkills) { activeSkill.Id.ShouldNotBe(0); activeSkill.Name.Length.ShouldBeGreaterThan(0); activeSkill.NumberOfToastChanges.ShouldBeGreaterThan(0); } }
public async Task It_Returns_The_Passive_Skills() { //--arrange //--act var passiveSkills = await GamesClient.GetPassiveSkills(TestEnvironmentSettings.BaseApiUrl); //--assert passiveSkills.ShouldNotBeNull(); passiveSkills.Count.ShouldBeGreaterThan(6); foreach (var passiveSkill in passiveSkills) { passiveSkill.Id.ShouldNotBe(0); passiveSkill.Name.Length.ShouldBeGreaterThan(0); passiveSkill.IncreasePerPoint.ShouldBeGreaterThan(0); } }
public void Setup(GameHelperListener listener, int clientsToUse) { this.listener = listener; requestClients = clientsToUse; List <string> scopesList = new List <string>(); if (0 != (clientsToUse & CLIENT_GAMES)) { scopesList.Add(Scopes.Games); } if (0 != (clientsToUse & CLIENT_PLUS)) { scopesList.Add(Scopes.PlusLogin); } if (0 != (clientsToUse & CLIENT_APPSTATE)) { scopesList.Add(Scopes.AppState); } if (0 != (clientsToUse & CLIENT_GAMES)) { gamesClient = new GamesClient.Builder(activity, this, this) .SetGravityForPopups((int)(GravityFlags.Top | GravityFlags.CenterHorizontal)) .SetScopes(scopesList.ToArray()) .Create(); } if (0 != (clientsToUse & CLIENT_PLUS)) { plusCient = new PlusClient.Builder(activity, this, this) .SetScopes(scopesList.ToArray()) .Build(); } if (0 != (clientsToUse & CLIENT_APPSTATE)) { appStateClient = new AppStateClient.Builder(activity, this, this) .SetScopes(scopesList.ToArray()) .Create(); } }
public async Task It_Returns_Next_Round_Available_If_All_Players_Have_Pushed_Their_Points() { //--arrange var newGame = await CreateValidGameForTesting(TestUserName, 1, 1); var firstPlayer = newGame.Players.First(x => x.Human); var skillExpenditureRequest = new SkillExpenditureRequest(firstPlayer.Id); for (int i = 0; i < firstPlayer.MutationPoints; i++) { skillExpenditureRequest.IncreaseRegeneration(); } //--act var result = await GamesClient.PushSkillExpenditures(newGame.Id, firstPlayer.Id, skillExpenditureRequest, TestEnvironmentSettings.BaseApiUrl); //--assert result.NextRoundAvailable.ShouldBe(true); }
public async Task It_Returns_A_400_Bad_Request_If_The_Player_Attempted_To_Push_Too_Many_Active_Cell_Changes() { //--arrange var newGame = await CreateValidGameForTesting(TestUserName, 2, 0); var firstPlayer = newGame.Players[0]; var skillExpenditureRequest = new SkillExpenditureRequest(firstPlayer.Id); skillExpenditureRequest.AddMoistureDroplet(1); skillExpenditureRequest.AddMoistureDroplet(2); skillExpenditureRequest.AddMoistureDroplet(3); skillExpenditureRequest.AddMoistureDroplet(4); //--act var exception = Assert.ThrowsAsync <ApiException>(async() => await GamesClient.PushSkillExpenditures(newGame.Id, firstPlayer.Id, skillExpenditureRequest, TestEnvironmentSettings.BaseApiUrl)); //--assert exception.ResponseStatusCode.ShouldBe(HttpStatusCode.BadRequest); }
public async Task It_Returns_The_Updated_Player() { //--arrange var newGame = await CreateValidGameForTesting(TestUserName, 2, 0); var joinGameRequest = new JoinGameRequest(newGame.Id, TestUserName2); //--have another player join so that the game is started await GamesClient.JoinGame(joinGameRequest, TestEnvironmentSettings.BaseApiUrl); var firstPlayer = newGame.Players[0]; var skillExpenditureRequest = new SkillExpenditureRequest(firstPlayer.Id); skillExpenditureRequest.IncreaseBudding(); //--act var result = await GamesClient.PushSkillExpenditures(newGame.Id, firstPlayer.Id, skillExpenditureRequest, TestEnvironmentSettings.BaseApiUrl); //--assert result.UpdatedPlayer.MutationPoints.ShouldBe(firstPlayer.MutationPoints - 1); }
public async Task It_Returns_Next_Round_Not_Available_If_Not_All_Players_Have_Pushed_Their_Points() { //--arrange var newGame = await CreateValidGameForTesting(TestUserName, 2, 0); var joinGameRequest = new JoinGameRequest(newGame.Id, TestUserName2); //--have another player join so that the game is started await GamesClient.JoinGame(joinGameRequest, TestEnvironmentSettings.BaseApiUrl); var firstPlayer = newGame.Players[0]; var skillExpenditureRequest = new SkillExpenditureRequest(firstPlayer.Id); for (int i = 0; i < firstPlayer.MutationPoints; i++) { skillExpenditureRequest.IncreaseRegeneration(); } //--act var result = await GamesClient.PushSkillExpenditures(newGame.Id, firstPlayer.Id, skillExpenditureRequest, TestEnvironmentSettings.BaseApiUrl); //--assert result.NextRoundAvailable.ShouldBe(false); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _client = ((GameActivity)Activity).GamesClient; }
public async Task It_Automatically_Starts_The_Game_If_There_Is_Only_One_Human_Player() { //--arrange var numberOfHumanPlayers = 1; var numberOfAiPlayers = 1; var newGame = new NewGameRequest(TestUserName, numberOfHumanPlayers, numberOfAiPlayers); var totalNumberOfPlayers = numberOfHumanPlayers + numberOfAiPlayers; //--act var result = await GamesClient.CreateGame(newGame, TestEnvironmentSettings.BaseApiUrl); //--assert result.NumberOfHumanPlayers.ShouldBe(newGame.NumberOfHumanPlayers); result.NumberOfAiPlayers.ShouldBe(newGame.NumberOfAiPlayers); result.GridSize.ShouldBe(50); result.Id.ShouldBeGreaterThan(0); result.Status.ShouldBe(GameStatus.Started); result.RoundNumber.ShouldBe(1); result.TotalDeadCells.ShouldBe(0); result.TotalRegeneratedCells.ShouldBe(0); //--we start with 1 live cell per player result.TotalLiveCells.ShouldBe(totalNumberOfPlayers); //--there starting game state will be empty result.StartingGameState.ShouldNotBeNull(); result.StartingGameState.FungalCells.Count.ShouldBe(0); result.GrowthCycles.ShouldNotBeNull(); //--there should be a single growth cycle that places each player's starting cell result.GrowthCycles.Count.ShouldBe(1); var growthCycle = result.GrowthCycles[0]; //--every player will start with some mutation points to spend at the start of the game growthCycle.MutationPointsEarned.Count.ShouldBe(2); foreach (var keyValuePair in growthCycle.MutationPointsEarned) { keyValuePair.Value.ShouldBeGreaterThan(0); } //--there should be one toast change (i.e. new live cell placed) for each player growthCycle.ToastChanges.Count.ShouldBe(totalNumberOfPlayers); var maxCellIndex = result.NumberOfCells - 1; AssertToastChangeIsCorrect(growthCycle.ToastChanges[0], maxCellIndex); AssertToastChangeIsCorrect(growthCycle.ToastChanges[1], maxCellIndex); growthCycle.ToastChanges[0].Index.ShouldNotBe(growthCycle.ToastChanges[1].Index); result.Players.ShouldNotBeNull(); result.Players.Count.ShouldBe(totalNumberOfPlayers); var player = result.Players.First(x => x.Human); AssertHumanPlayerLooksRight(player); player.Name.ShouldBe(TestUserName); player.Status.ShouldBe("Joined"); player = result.Players.First(x => !x.Human); player.Id.ShouldNotBeNullOrEmpty(); player.Name.ShouldNotBeNull(); player.Status.ShouldBe("Joined"); }
public void It_Throws_A_GameStateNotFoundException_If_It_Cant_Find_The_Game() { //--arrange var invalidGameID = -1; var expectedException = new GameNotFoundException(invalidGameID); //--act var exception = Assert.ThrowsAsync <GameNotFoundException>(async() => await GamesClient.GetGameState(invalidGameID, TestEnvironmentSettings.BaseApiUrl)); //--assert exception.Message.ShouldBe(expectedException.Message); }
public void Setup(GameHelperListener listener, int clientsToUse) { this.listener = listener; requestClients = clientsToUse; List<string> scopesList = new List<string>(); if (0 != (clientsToUse & CLIENT_GAMES)) { scopesList.Add(Scopes.Games); } if (0 != (clientsToUse & CLIENT_PLUS)) { scopesList.Add(Scopes.PlusLogin); } if (0 != (clientsToUse & CLIENT_APPSTATE)) { scopesList.Add(Scopes.AppState); } if (0 != (clientsToUse & CLIENT_GAMES)) { gamesClient = new GamesClient.Builder(activity, this, this) .SetGravityForPopups((int)(GravityFlags.Top | GravityFlags.CenterHorizontal)) .SetScopes(scopesList.ToArray()) .Create(); } if (0 != (clientsToUse & CLIENT_PLUS)) { plusCient = new PlusClient.Builder(activity, this, this) .SetScopes(scopesList.ToArray()) .Build(); } if (0 != (clientsToUse & CLIENT_APPSTATE)) { appStateClient = new AppStateClient.Builder(activity, this, this) .SetScopes(scopesList.ToArray()) .Create(); } }