public void BasicInputCopyTest() { var input = new SliderInput(); var group = new InputGroup { Inputs = { input } }; var copy = group.Copy(true); // assign new ID as done when user taps Copy on the InputGroup. Assert.AreEqual(1, copy.Inputs.Count()); Assert.AreNotEqual(input.Id, copy.Inputs.Single().Id); // copied inputs should have different IDs Assert.AreNotSame(input, copy.Inputs.Single()); Assert.AreNotEqual(group.Id, copy.Id); Assert.AreEqual(copy.Id, copy.Inputs.Single().GroupId); }
public void DisplayConditionInputCopyTest1() { var input = new SliderInput(); input.DisplayConditions.Add(new InputDisplayCondition(input, InputValueCondition.Equals, "a", false)); var group = new InputGroup { Inputs = { input } }; var copy = group.Copy(false); Assert.AreSame(input, input.DisplayConditions.Single().Input); Assert.AreSame(input, group.Inputs.Single()); Assert.AreNotSame(group.Inputs.Single(), copy.Inputs.Single()); Assert.AreSame(copy.Inputs.Single(), copy.Inputs.Single().DisplayConditions.Single().Input); }
public void BasicPropertyCopyTest() { var group = new InputGroup { Geotag = true, Name = "Name" }; var copy = group.Copy(false); Assert.AreEqual(group.Id, copy.Id); Assert.AreEqual(group.Valid, copy.Valid); Assert.AreEqual(group.Geotag, copy.Geotag); Assert.True(copy.Inputs.Count == 0); Assert.AreEqual(group.Name, copy.Name); }
public void DisplayConditionInputCopyTest5() { var input1 = new SliderInput(); var input2 = new SliderInput(); input1.DisplayConditions.Add(new InputDisplayCondition(input2, InputValueCondition.Equals, "a", false)); var group = new InputGroup { Inputs = { input1 } }; var copy = group.Copy(false); Assert.Same(input2, input1.DisplayConditions.Single().Input); Assert.Same(input1, group.Inputs.Single()); Assert.NotSame(group.Inputs.Single(), copy.Inputs.Single()); Assert.NotSame(input2, copy.Inputs.Single().DisplayConditions.Single().Input); Assert.Equal(input2.Id, copy.Inputs.Single().DisplayConditions.Single().Input.Id); }
public void DisplayConditionInputCopyTest4() { var input1 = new SliderInput(); var input2 = new SliderInput(); input1.DisplayConditions.Add(new InputDisplayCondition(input2, InputValueCondition.Equals, "a", false)); var group = new InputGroup { Inputs = { input1, input2 } }; var copy = group.Copy(false); Assert.AreSame(input2, input1.DisplayConditions.Single().Input); Assert.AreSame(input1, group.Inputs.Skip(0).Take(1).Single()); Assert.AreSame(input2, group.Inputs.Skip(1).Take(1).Single()); Assert.AreNotSame(input1, copy.Inputs.Skip(0).Take(1).Single()); Assert.AreNotSame(input2, copy.Inputs.Skip(1).Take(1).Single()); Assert.AreSame(copy.Inputs.Skip(1).Take(1).Single(), copy.Inputs.Skip(0).Take(1).Single().DisplayConditions.Single().Input); }
public ScriptInputGroupsPage(Script script) { Title = "Input Groups"; ListView groupsList = new ListView(ListViewCachingStrategy.RecycleElement); groupsList.ItemTemplate = new DataTemplate(typeof(TextCell)); groupsList.ItemTemplate.SetBinding(TextCell.TextProperty, nameof(InputGroup.Name)); groupsList.ItemsSource = script.InputGroups; groupsList.ItemTapped += async(o, e) => { if (groupsList.SelectedItem == null) { return; } InputGroup selectedInputGroup = groupsList.SelectedItem as InputGroup; int selectedIndex = script.InputGroups.IndexOf(selectedInputGroup); List <string> actions = new string[] { "Edit", "Copy", "Delete" }.ToList(); if (selectedIndex < script.InputGroups.Count - 1) { actions.Insert(0, "Move Down"); } if (selectedIndex > 0) { actions.Insert(0, "Move Up"); } string selectedAction = await DisplayActionSheet(selectedInputGroup.Name, "Cancel", null, actions.ToArray()); if (selectedAction == "Move Up") { script.InputGroups.Move(selectedIndex, selectedIndex - 1); } else if (selectedAction == "Move Down") { script.InputGroups.Move(selectedIndex, selectedIndex + 1); } else if (selectedAction == "Edit") { List <InputGroup> previousInputGroups = script.InputGroups.Where((inputGroup, index) => index < selectedIndex).ToList(); ScriptInputGroupPage inputGroupPage = new ScriptInputGroupPage(selectedInputGroup, previousInputGroups); await Navigation.PushAsync(inputGroupPage); groupsList.SelectedItem = null; } else if (selectedAction == "Copy") { script.InputGroups.Add(selectedInputGroup.Copy(true)); } else if (selectedAction == "Delete") { if (await DisplayAlert("Delete " + selectedInputGroup.Name + "?", "This action cannot be undone.", "Delete", "Cancel")) { script.InputGroups.Remove(selectedInputGroup); groupsList.SelectedItem = null; } } }; ToolbarItems.Add(new ToolbarItem(null, "plus.png", () => { script.InputGroups.Add(new InputGroup { Name = "New Input Group" }); })); Content = groupsList; }