Ejemplo n.º 1
0
        public void SpyHelper_DeleteSelectedProperties()
        {
            //TODO: need to update the unit test

            UIATestObject testObject = new UIATestObject(
                ObjectDescriptor.FromJson(@"{
              ""identifyProperties"": {
                ""title"": ""LAP (Running) - Microsoft Visual Studio"",
                ""helptext"": ""this is help text"",
                ""url"": ""this is url"",
                ""type"": ""Window""}
              }"));

            Assert.AreEqual(4, testObject.Properties.Count);

            DataGridView propertyGrid = GetAnEmptyPropertyGrid();

            SpyWindowHelper.FillPropertyGrid(propertyGrid, testObject);

            Assert.AreEqual(5, propertyGrid.Rows.Count, "Should have 5 properties before deletion");

            SpyWindowHelper.DeleteSelectedProperties(ControlKeys.Title, testObject);

            SpyWindowHelper.FillPropertyGrid(propertyGrid, testObject);

            string data = DumpPropertyGridRows(propertyGrid);

            Debug.Write(data);
            Assert.AreEqual(4, propertyGrid.Rows.Count, data);
        }
Ejemplo n.º 2
0
        public void SpyHelper_AddSelectedProperty()
        {
            UIATestObject testObject = new UIATestObject(
                ObjectDescriptor.FromJson(@"{
              ""identifyProperties"": {
                ""title"": ""LAP (Running) - Microsoft Visual Studio"",
                ""helptext"": ""this is help text"",
                ""url"": ""this is url"",
                ""type"": ""Window""}
              }"));

            Assert.AreEqual(4, testObject.Properties.Count);

            DataGridView propertyGrid = GetAnEmptyPropertyGrid();

            SpyWindowHelper.FillPropertyGrid(propertyGrid, testObject);

            Assert.AreEqual(5, propertyGrid.Rows.Count, "Should have 4 properties before selection");

            propertyGrid.Rows[1].Selected = true;
            propertyGrid.Rows[2].Selected = true;

            UIATestObject newTestObject = new UIATestObject();

            Assert.AreEqual(0, newTestObject.Properties.Count);

            SpyWindowHelper.AddSelectedProperty(propertyGrid, newTestObject);

            Assert.AreEqual(2, newTestObject.Properties.Count);
        }
        private void treeObjects_OnDropItemIntoTree(object sender, DragEventArgs e)
        {
            TreeNode myNode = null;

            if (e.Data.GetDataPresent(typeof(TreeNode)))
            {
                myNode = (TreeNode)(e.Data.GetData(typeof(TreeNode)));
            }
            else
            {
                return;
            }

            Point position = new Point(e.X, e.Y);

            position = this.treeObjects.PointToClient(position);

            TreeNode dropNode = this.treeObjects.GetNodeAt(position);

            TreeNode dragNode = null;

            bool needUpdate = false;

            if ((dropNode != null && dropNode.Parent != myNode && dropNode != myNode) || (dropNode == null))
            {
                dragNode = myNode;
                myNode.Remove();
                needUpdate = true;
            }

            if (dragNode != null && needUpdate)
            {
                TestObjectNurse dragNurse = TestObjectNurse.FromTreeNode(dragNode);
                string          newName   = "";
                if (dropNode == null)
                {
                    newName = SpyWindowHelper.DeriveControlName(RootNurseObject, dragNurse.NodeName);
                    treeObjects.Nodes.Add(dragNode);
                }
                else
                {
                    newName = SpyWindowHelper.DeriveControlName(RootNurseObject, dragNurse.NodeName);
                    dropNode.Nodes.Add(dragNode);
                }

                if (newName != dragNurse.NodeName)
                {
                    dragNurse.NodeName = newName;

                    SelectedNodesChanged(dragNode);

                    MessageBox.Show(string.Format(StringResources.LPSpy_SpyMainWindow_ObjNameSameMsg, newName));
                }
                treeObjects.SelectedNode = dragNode;
                AppEnvironment.SetModelChanged(true);
            }
        }
        private void treeObjects_OnObjectNameChanged(object sender, NodeLabelEditEventArgs e)
        {
            if (e.CancelEdit)
            {
                return;
            }
            if (e.Label == null)
            {
                return;
            }
            TestObjectNurse nurse = TestObjectNurse.FromTreeNode(e.Node);

            if (e.Label == nurse.NodeName)
            {
                return;
            }

            string newName = e.Label;

            if (e.Label.StartsWith(nurse.ControlTypeString + ":"))
            {
                newName = newName.Substring((nurse.ControlTypeString + ":").Length);
                newName = newName.Trim();
            }
            string nameChecker = SpyWindowHelper.DeriveControlName(nurse.ParentNurse, newName);

            if (nameChecker == newName)
            {
                nurse.NodeName = newName;

                if (NodeNameChanged != null)
                {
                    NodeNameChanged(sender, e);
                }

                _presenterModel.SetSelectNodeName(newName);

                AppEnvironment.SetModelChanged(true);

                return;
            }
            else
            {
                MessageBox.Show(string.Format(StringResources.LPSpy_SpyMainWindow_SelectobjMsg, newName));
                e.CancelEdit = true;
                e.Node.Text  = TestObjectNurse.FromTreeNode(e.Node).NodeName;
            }
        }
Ejemplo n.º 5
0
        public void SpyHelper_FillPropertyGrid()
        {
            UIATestObject testObject = new UIATestObject(
                ObjectDescriptor.FromJson(@"{
              ""identifyProperties"": {
                ""title"": ""LAP (Running) - Microsoft Visual Studio"",
                ""type"": ""Window""}
              }"));

            DataGridView propertyGrid = GetAnEmptyPropertyGrid();

            int count = SpyWindowHelper.FillPropertyGrid(propertyGrid, testObject);

            Assert.AreEqual(2, count);

            testObject.AddProperty("property3", "value3");

            count = SpyWindowHelper.FillPropertyGrid(propertyGrid, testObject);

            Assert.AreEqual(3, count);
        }