public void GetObjectInMethodCall()
        {
            string pythonCode = "self._menuStrip1.Items.AddRange(System.Array[System.Windows.Forms.ToolStripItem](\r\n" +
                                "    [self._fileToolStripMenuItem,\r\n" +
                                "    self._editToolStripMenuItem]))";

            CallExpression callExpression      = PythonParserHelper.GetCallExpression(pythonCode);
            PythonControlFieldExpression field = PythonControlFieldExpression.Create(callExpression);

            using (MenuStrip menuStrip = new MenuStrip()) {
                MockComponentCreator creator = new MockComponentCreator();
                creator.Add(menuStrip, "menuStrip1");
                Assert.AreSame(menuStrip.Items, field.GetMember(creator));
            }
        }
        public void GetInstanceObjectInMethodCall()
        {
            string pythonCode = "treeNode1.Nodes.AddRange(System.Array[System.Windows.Forms.TreeNode](\r\n" +
                                "    [treeNode2]))";

            CallExpression callExpression      = PythonParserHelper.GetCallExpression(pythonCode);
            PythonControlFieldExpression field = PythonControlFieldExpression.Create(callExpression);

            TreeNode             treeNode1 = new TreeNode();
            TreeNode             treeNode2 = new TreeNode();
            MockComponentCreator creator   = new MockComponentCreator();

            creator.AddInstance(treeNode1, "treeNode1");
            creator.AddInstance(treeNode2, "treeNode2");
            object member = field.GetMember(creator);

            Assert.AreSame(treeNode1.Nodes, member);
        }
 public void NullMemberExpression()
 {
     Assert.AreEqual(String.Empty, PythonControlFieldExpression.GetMemberName(null));
 }
        public void FullMemberExpression()
        {
            CallExpression call = PythonParserHelper.GetCallExpression("self._a.b.Add()");

            Assert.AreEqual("self._a.b.Add", PythonControlFieldExpression.GetMemberName(call.Target as MemberExpression));
        }
 public void VariableNameIsEmpty()
 {
     Assert.AreEqual(String.Empty, PythonControlFieldExpression.GetVariableName(String.Empty));
 }
 public void VariableNameHasOnlyUnderscore()
 {
     Assert.AreEqual(String.Empty, PythonControlFieldExpression.GetVariableName("_"));
 }
 public void GetVariableName()
 {
     Assert.AreEqual("abc", PythonControlFieldExpression.GetVariableName("_abc"));
 }
 public void NoDotHasPrefixTest()
 {
     Assert.AreEqual("a", PythonControlFieldExpression.GetPrefix("a"));
 }
 public void GetInheritedObjectPassedNull()
 {
     Assert.IsNull(PythonControlFieldExpression.GetInheritedObject("panel1", null));
 }
 public void GetProtectedPanelObjectIncorrectCase()
 {
     Assert.AreEqual(DerivedForm.GetPanel(), PythonControlFieldExpression.GetInheritedObject("PANEL1", DerivedForm));
 }
Example #11
0
 public void GetPublicPanelObject()
 {
     Assert.AreEqual(DerivedForm.panel1, PythonControlFieldExpression.GetInheritedObject("panel1", DerivedForm));
 }