private static string[] SetupLobbyFilter(LobbyFilterContent lobbyFilterEmpty) { string[] lobbyFilter = null; switch (lobbyFilterEmpty) { case LobbyFilterContent.LobbyFilterEmpty: lobbyFilter = new string[0]; break; case LobbyFilterContent.LobbyFilterNonEmpty: lobbyFilter = new[] { "InLobbyFilterList" }; break; } return(lobbyFilter); }
public void GetGameUpdate_SetSameValue( [Values( LobbyFilterContent.LobbyFilterEmpty, LobbyFilterContent.LobbyFilterNonEmpty, LobbyFilterContent.LobbyFilterIsNull)] LobbyFilterContent lobbyFilterCase, [Values( LobbyType.Default, LobbyType.SqlLobby)] LobbyType lobbyType, [Values("NotInLobbyFilterList", "InLobbyFilterList")] string propertyName, [Values( "yyy", new string[] { "x", "y" }, new byte[] { 1, 2, 3 })] object propertyValue) { UnifiedTestClient client1 = null; UnifiedTestClient client2 = null; var lobbyName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name + "_Lobby"); var lobbyFilter = SetupLobbyFilter(lobbyFilterCase); try { // authenticate client and check if the Lobbystats event will be received // Remarks: The event cannot be checked for a specific lobby count because // previous tests may have created lobbies. client1 = this.CreateMasterClientAndAuthenticate(this.Player1); if (string.IsNullOrEmpty(this.Player1) || client1.Token == null) { Assert.Ignore("This test does not work correctly for old clients without userId and token"); } client1.JoinLobby(lobbyName, (byte)lobbyType); var roomProperties = new Hashtable() { { "z", "w" }, { propertyName, propertyValue } }; // create a new game for the lobby var gameName = this.GenerateRandomizedRoomName(MethodBase.GetCurrentMethod().Name); var createGameResponse = client1.CreateGame(gameName, true, true, 0, roomProperties, lobbyFilter, null); this.ConnectAndAuthenticate(client1, createGameResponse.Address, client1.UserId); client1.CreateGame(gameName, true, true, 0, roomProperties, lobbyFilter, null); // give the game server some time to report the game to the master server Thread.Sleep(3000); var authParameter = new Dictionary <byte, object> { { (byte)Operations.ParameterCode.LobbyStats, true } }; // check if new game is listed in lobby statistics client2 = this.CreateMasterClientAndAuthenticate(this.Player2, authParameter); if (this.AuthPolicy == AuthPolicy.UseAuthOnce) // in this case we should send OpSettings to master { client2.SendRequest(new OperationRequest { OperationCode = (byte)OperationCode.ServerSettings, Parameters = new Dictionary <byte, object> { { SettingsRequestParameters.LobbyStats, true } }, }); } client2.JoinLobby(lobbyName, (byte)lobbyType); client1.SendRequest(new OperationRequest { OperationCode = OperationCode.SetProperties, Parameters = new Dictionary <byte, object> { { ParameterCode.Properties, new Hashtable { { propertyName, propertyValue } } }, } }); Thread.Sleep(100); client2.CheckThereIsNoEvent((byte)Events.EventCode.GameListUpdate, this.WaitTimeout); } finally { DisposeClients(client1, client2); } }