public void CreateUpdateDeleteControl() { this.InteractiveWrapper(async(MixerConnection connection, InteractiveClient interactiveClient) => { InteractiveConnectedSceneModel testScene = await this.CreateScene(interactiveClient); this.ClearPackets(); InteractiveControlModel testControl = InteractiveClientUnitTests.CreateTestButton(); List <InteractiveControlModel> controls = new List <InteractiveControlModel>() { testControl, InteractiveClientUnitTests.CreateTestJoystick() }; bool result = await interactiveClient.CreateControlsWithResponse(testScene, controls); Assert.IsTrue(result); testScene = await this.GetScene(interactiveClient); testControl = testScene.buttons.FirstOrDefault(c => c.controlID.Equals(ButtonControlID)); Assert.IsNotNull(testControl); controls = new List <InteractiveControlModel>() { testControl }; InteractiveConnectedControlCollectionModel controlCollection = await interactiveClient.UpdateControlsWithResponse(testScene, controls); Assert.IsNotNull(controlCollection); Assert.IsNotNull(controlCollection.buttons); testScene = await this.GetScene(interactiveClient); testControl = testScene.buttons.FirstOrDefault(c => c.controlID.Equals(ButtonControlID)); Assert.IsNotNull(testControl); result = await interactiveClient.DeleteControlsWithResponse(testScene, controls); Assert.IsTrue(result); await this.DeleteScene(interactiveClient, testScene); }); }
public static async Task <InteractiveGameListingModel> CreateTestGame(MixerConnection connection, ChannelModel channel) { UserModel user = await UsersServiceUnitTests.GetCurrentUser(connection); IEnumerable <InteractiveGameListingModel> gameListings = await connection.Interactive.GetOwnedInteractiveGames(channel); InteractiveGameListingModel previousTestGame = gameListings.FirstOrDefault(g => g.name.Equals(InteractiveServiceUnitTests.InteractiveGameName)); if (previousTestGame != null) { await InteractiveServiceUnitTests.DeleteTestGame(connection, previousTestGame); } InteractiveGameModel game = new InteractiveGameModel() { name = InteractiveServiceUnitTests.InteractiveGameName, ownerId = user.id, }; game = await connection.Interactive.CreateInteractiveGame(game); Assert.IsNotNull(game); Assert.IsTrue(game.id > 0); game.controlVersion = "2.0"; game = await connection.Interactive.UpdateInteractiveGame(game); Assert.IsNotNull(game); Assert.IsTrue(game.id > 0); gameListings = await connection.Interactive.GetOwnedInteractiveGames(channel); Assert.IsNotNull(gameListings); Assert.IsTrue(gameListings.Count() > 0); InteractiveGameListingModel gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id)); Assert.IsNotNull(gameListing); InteractiveGameVersionModel version = gameListing.versions.First(); InteractiveSceneModel defaultScene = new InteractiveSceneModel() { sceneID = "default", }; defaultScene.buttons.Add(InteractiveClientUnitTests.CreateTestButton()); defaultScene.joysticks.Add(InteractiveClientUnitTests.CreateTestJoystick()); version.controls.scenes.Add(defaultScene); version.controlVersion = "2.0"; version = await connection.Interactive.UpdateInteractiveGameVersion(version); gameListings = await connection.Interactive.GetOwnedInteractiveGames(channel); Assert.IsNotNull(gameListings); Assert.IsTrue(gameListings.Count() > 0); gameListing = gameListings.FirstOrDefault(gl => gl.id.Equals(game.id)); Assert.IsNotNull(gameListing); return(gameListing); }