public static async Task<MixPlayGameListingModel> CreateTestGame(MixerConnection connection, ChannelModel channel) { UserModel user = await UsersServiceUnitTests.GetCurrentUser(connection); IEnumerable<MixPlayGameListingModel> gameListings = await connection.MixPlay.GetOwnedMixPlayGames(channel); MixPlayGameListingModel previousTestGame = gameListings.FirstOrDefault(g => g.name.Equals(MixPlayServiceUnitTests.GameName)); if (previousTestGame != null) { await MixPlayServiceUnitTests.DeleteTestGame(connection, previousTestGame); } MixPlayGameModel game = new MixPlayGameModel() { name = MixPlayServiceUnitTests.GameName, ownerId = user.id, }; game = await connection.MixPlay.CreateMixPlayGame(game); Assert.IsNotNull(game); Assert.IsTrue(game.id > 0); game.controlVersion = "2.0"; game = await connection.MixPlay.UpdateMixPlayGame(game); Assert.IsNotNull(game); Assert.IsTrue(game.id > 0); gameListings = await connection.MixPlay.GetOwnedMixPlayGames(channel); Assert.IsNotNull(gameListings); Assert.IsTrue(gameListings.Count() > 0); MixPlayGameListingModel gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id)); Assert.IsNotNull(gameListing); MixPlayGameVersionModel version = gameListing.versions.First(); MixPlaySceneModel defaultScene = new MixPlaySceneModel() { sceneID = "default", }; defaultScene.buttons.Add(MixPlayClientUnitTests.CreateTestButton()); defaultScene.joysticks.Add(MixPlayClientUnitTests.CreateTestJoystick()); version.controls.scenes.Add(defaultScene); version.controlVersion = "2.0"; version = await connection.MixPlay.UpdateMixPlayGameVersion(version); gameListings = await connection.MixPlay.GetOwnedMixPlayGames(channel); Assert.IsNotNull(gameListings); Assert.IsTrue(gameListings.Count() > 0); gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id)); Assert.IsNotNull(gameListing); return gameListing; }
public void CreateUpdateDeleteControl() { this.MixPlayWrapper(async(MixerConnection connection, MixPlayClient client) => { MixPlayConnectedSceneModel testScene = await this.CreateScene(client); this.ClearPackets(); MixPlayControlModel testControl = MixPlayClientUnitTests.CreateTestButton(); List <MixPlayControlModel> controls = new List <MixPlayControlModel>() { testControl, MixPlayClientUnitTests.CreateTestJoystick() }; bool result = await client.CreateControlsWithResponse(testScene, controls); Assert.IsTrue(result); testScene = await this.GetScene(client); testControl = testScene.buttons.FirstOrDefault(c => c.controlID.Equals(ButtonControlID)); Assert.IsNotNull(testControl); controls = new List <MixPlayControlModel>() { testControl }; MixPlayConnectedControlCollectionModel controlCollection = await client.UpdateControlsWithResponse(testScene, controls); Assert.IsNotNull(controlCollection); Assert.IsNotNull(controlCollection.buttons); testScene = await this.GetScene(client); testControl = testScene.buttons.FirstOrDefault(c => c.controlID.Equals(ButtonControlID)); Assert.IsNotNull(testControl); result = await client.DeleteControlsWithResponse(testScene, controls); Assert.IsTrue(result); await this.DeleteScene(client, testScene); }); }