예제 #1
0
        public void PasteTextIntoFunctionBindingList()
        {
            IFunction function = new Function();
            var argument = new Variable<string>("A");
            function.Arguments.Add(argument);
            var component = new Variable<string>("B");
            function.Components.Add(component);

            var view = new TableView();
            IBindingList bindingList = new FunctionBindingList(function) { SynchronizeInvoke = view };
            view.Data = bindingList;

            const string argumentvalue1 = "argumentvalue1";
            const string componentvalue1 = "componentvalue1";
            const string argumentvalue2 = "argumentvalue2";
            string componentvalue2 = "componentvalue2" + (char)0x03A9;


            Clipboard.SetText(string.Format("{0}\t{1}" + Environment.NewLine +
                                            "{2}\t{3}", argumentvalue1, componentvalue1, argumentvalue2,
                                            componentvalue2));

            //action! pasting the text should fill out the function
            view.PasteClipboardContents();

            Thread.Sleep(2000);

            Assert.AreEqual(argumentvalue1, argument.Values[0]);
            Assert.AreEqual(componentvalue1, component.Values[0]);
            Assert.AreEqual(argumentvalue2, argument.Values[1]);
            Assert.AreEqual(componentvalue2, component.Values[1]);

        }
        public void PasteIntoGridBoundToDataTable()
        {
            var tableWithTwoStrings = new DataTable();
            tableWithTwoStrings.Columns.Add("A", typeof(string));
            tableWithTwoStrings.Columns.Add("B", typeof(string));
            tableWithTwoStrings.Rows.Add("a", "b");

            var tableView = new TableView { Data = tableWithTwoStrings };

            Clipboard.SetText(string.Format("{0}\t{1}" + Environment.NewLine + "{0}\t{1}", "oe", "oe1"));

            tableView.PasteClipboardContents();

            //WindowsFormsTestHelper.ShowModal(tableView);

            //should overwrite existing row and add another one
            Assert.AreEqual(2, tableWithTwoStrings.Rows.Count);
            Assert.AreEqual("oe", tableWithTwoStrings.Rows[0][0]);
            Assert.AreEqual("oe1", tableWithTwoStrings.Rows[0][1]);
            Assert.AreEqual("oe", tableWithTwoStrings.Rows[1][0]);
            Assert.AreEqual("oe1", tableWithTwoStrings.Rows[1][1]);
        }
예제 #3
0
        public void PasteIntoEmptyTableView()
        {
            var persons = new List<Person>();
            //set two persons in clipboard
            const string clipBoardContents = "cees anton\t34\r\nsaifon\t66\r\nmartijn\t31\r\n";
            Clipboard.SetText(clipBoardContents);
            //setup a tableview
            var tableView = new TableView { Data = persons };

            //action!
            tableView.PasteClipboardContents();

            Assert.AreEqual("martijn", persons[2].Name);
            Assert.AreEqual(31, persons[2].Age);
            Assert.AreEqual(3, persons.Count);

            //WindowsFormsTestHelper.ShowModal(tableView);
        }
예제 #4
0
        public void PasteClipboardContentsOverwritesExistingRows()
        {
            var person = new List<Person> { new Person { Age = 12, Name = "Hoi" }, new Person { Age = 11, Name = "keers" } };
            //set two persons in clipboard
            const string clipBoardContents = "cees anton\t34\r\nsaifon\t66\r\n";
            Clipboard.SetText(clipBoardContents);
            //setup a tableview
            var tableView = new TableView { Data = person };

            tableView.PasteClipboardContents();

            Assert.AreEqual("cees anton", person[0].Name);
            Assert.AreEqual(34, person[0].Age);
            Assert.AreEqual("saifon", person[1].Name);
            Assert.AreEqual(66, person[1].Age);
        }
예제 #5
0
        public void PasteClipboardContentsCanAddRows()
        {
            var person = new List<Person> { new Person { Age = 12, Name = "Hoi" }, new Person { Age = 11, Name = "keers" } };
            //set two persons in clipboard
            const string clipBoardContents = "cees anton\t34\r\nsaifon\t66\r\nmartijn\t31\r\n";
            Clipboard.SetText(clipBoardContents);
            //setup a tableview
            var tableView = new TableView { Data = person };

            tableView.PasteClipboardContents();

            Assert.AreEqual("martijn", person[2].Name);
            Assert.AreEqual(31, person[2].Age);
        }