Exemplo n.º 1
0
        public void TableInsert()
        {
            var result = "";

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor  = new NoteEditor();
                var form    = CreateForm();
                form.Shown += (sender, args) =>
                {
                    editor.HTML = null;
                    var sut     = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                result = editor.HTML;
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.IsTrue(result.ToLower().Contains("</table>"));
        }
Exemplo n.º 2
0
        public void GetSelectedTable_NoSelection()
        {
            bool result = false;

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor  = new NoteEditor();
                var form    = CreateForm();
                var sut     = new HtmlTableHelper(editor);
                form.Shown += (sender, args) =>
                {
                    editor.HTML     = "Some Text";
                    var body        = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r = body.createTextRange() as IHTMLTxtRange;
                    r.findText("Text");
                    r.select();
                    sut.TableInsert(new HtmlTableProperty(true));
                    result = sut.GetSelectedTable() == null;
                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.IsTrue(result);
        }
Exemplo n.º 3
0
        public void TableOperation()
        {
            string fileName = Environment.CurrentDirectory.ToString() + "\\Data\\Login.xlsx";

            ExcelHelpers.PopulateInCollection(fileName);

            LogHelpers.CreateLogFile();

            OpenBrowser(BrowserType.Chrome);
            LogHelpers.Write("Opened the browser !!!");

            DriverContext.Browser.GoToUrl(url);
            LogHelpers.Write("Navigated to the page !!!");

            CurrentPage = GetInstance <LoginPage>();
            CurrentPage.As <LoginPage>().ClickLoginLink();
            CurrentPage.As <LoginPage>().Login(ExcelHelpers.ReadData(1, "UserName"), ExcelHelpers.ReadData(1, "Password"));
            //EmployeePage
            CurrentPage = CurrentPage.As <LoginPage>().ClickEmployeeList();

            var table = CurrentPage.As <EmployeePage>().GetEmployeeList();

            HtmlTableHelper.ReadTable(table);
            HtmlTableHelper.PerformActionOnCell("5", "Name", "Ramesh", "Benefits");
        }
        public void ThenAddLocation()
        {
            this.CurrentPage = this.CurrentPage.As <NewQuickRequestPage>().SelectLocation();
            this.CurrentPage.As <SearchLocations>().IsPageLoaded();

            var table = this.CurrentPage.As <SearchLocations>().GetEmployeeList();

            HtmlTableHelper.ReadTable(table);
            HtmlTableHelper.PerformActionOnCell("2", "Localização", "Copa");
        }
Exemplo n.º 5
0
        public void DeleteColumn()
        {
            var rowCount = 0;
            var colCount = 0;
            var tabCols  = 0;

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor  = new NoteEditor();
                var form    = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    editor.HTML     = "Some Text There";
                    var body        = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r = body.createTextRange() as IHTMLTxtRange;
                    r.findText("Text");
                    r.select();
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //move inside table
                    IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange;
                    r2.findText("Text");
                    r2.select();
                    //modify table
                    sut.DeleteColumn();

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                rowCount = GetTable(editor).rows.length;
                colCount = (GetTable(editor).rows.item(0) as IHTMLTableRow).cells.length;
                tabCols  = GetTable(editor).cols;
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.AreEqual(3, rowCount);
            Assert.AreEqual(2, colCount);
            Assert.AreEqual(2, tabCols);
        }
Exemplo n.º 6
0
        public void TableModify_ContainingTable()
        {
            var result     = "";
            var tableCount = 0;

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor  = new NoteEditor();
                var form    = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    editor.HTML     = "Some Text There";
                    var body        = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r = body.createTextRange() as IHTMLTxtRange;
                    r.findText("Text");
                    r.select();
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //move inside table
                    IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange;
                    r2.findText("Text");
                    r2.select();
                    //modify table
                    var prop         = new HtmlTableProperty(true);
                    prop.CaptionText = "Table modified";
                    sut.TableModify(prop);

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                result     = editor.HTML;
                tableCount = editor.Document.GetElementsByTagName("table").Count;
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.IsTrue(result.Contains("Table modified"));
            Assert.AreEqual(1, tableCount);
        }
Exemplo n.º 7
0
        /// <summary>
        /// This is called when the initial html/body framework is set up, 
        /// or when document.DocumentText is set.  At this point, the 
        /// document is editable.
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">navigation args</param>
        private void this_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            TableEditor = new HtmlTableHelper(this);

            SetBackgroundColor(BackColor);

            IHTMLStyleSheet style = htmlDoc.createStyleSheet("", 0);
            style.cssText = @"table, th, td { border-collapse: collapse; border-color: black } "; //table, th, td { border: 1px solid black; }

            Ready(sender);

            // register for change notification
            IMarkupContainer2 cont2 = (IMarkupContainer2)htmlDoc;
            uint m_cookie;
            cont2.RegisterForDirtyRange(this, out m_cookie);

            // register for key/mouse events
            SetEditDesigner();
        }
Exemplo n.º 8
0
        public void ColumnMoveLeft_FirstColumn_NoChange()
        {
            string cellValue = "empty";
            string cellValue2 = "empty";

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor = new NoteEditor();
                var form = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //fill table
                    FillTable((editor.Document.GetElementsByTagName("table")[0].DomElement) as IHTMLTable);
                    //move inside table
                    var body = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange;
                    r2.findText("r0c0");
                    r2.select();
                    //modify table
                    sut.ColumnMoveLeft();

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                cellValue = GetCellValue(GetTable(editor), 1, 0);
                cellValue2 = GetCellValue(GetTable(editor), 1, 1);
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.AreEqual("r1c0", cellValue);
            Assert.AreEqual("r1c1", cellValue2);
        }
Exemplo n.º 9
0
        public void ColumnMoveLeft()
        {
            string cellValue  = "empty";
            string cellValue2 = "empty";

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor  = new NoteEditor();
                var form    = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //fill table
                    FillTable((editor.Document.GetElementsByTagName("table")[0].DomElement) as IHTMLTable);
                    //move inside table
                    var body         = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange;
                    r2.findText("r0c1");
                    r2.select();
                    //modify table
                    sut.ColumnMoveLeft();

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                cellValue  = GetCellValue(GetTable(editor), 1, 0);
                cellValue2 = GetCellValue(GetTable(editor), 1, 1);
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.AreEqual("r1c1", cellValue);
            Assert.AreEqual("r1c0", cellValue2);
        }
Exemplo n.º 10
0
        /// <summary>
        /// This is called when the initial html/body framework is set up,
        /// or when document.DocumentText is set.  At this point, the
        /// document is editable.
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">navigation args</param>
        private void this_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            TableEditor = new HtmlTableHelper(this);

            SetBackgroundColor(BackColor);

            IHTMLStyleSheet style = htmlDoc.createStyleSheet("", 0);

            style.cssText = @"table, th, td { border-collapse: collapse; border-color: black } "; //table, th, td { border: 1px solid black; }

            Ready(sender);

            // register for change notification
            IMarkupContainer2 cont2 = (IMarkupContainer2)htmlDoc;
            uint m_cookie;

            cont2.RegisterForDirtyRange(this, out m_cookie);

            // register for key/mouse events
            SetEditDesigner();
        }
Exemplo n.º 11
0
        public void DeleteTable()
        {
            var result = "";

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor  = new NoteEditor();
                var form    = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    editor.HTML     = "Some Text There";
                    var body        = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r = body.createTextRange() as IHTMLTxtRange;
                    r.findText("Text");
                    r.select();
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //move inside table
                    IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange;
                    r2.findText("Text");
                    r2.select();
                    //modify table
                    sut.DeleteTable();

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                result = editor.HTML;
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.IsFalse(result.ToLower().Contains("table"));
        }
Exemplo n.º 12
0
        public void Execute()
        {
            // Prepare sample data
            StatisticsDataService       statisticsDataService = new StatisticsDataService();
            List <SimpleStatisticsData> statisticsDatas       = statisticsDataService.GetSimpleStatisticsDatas();

            // Convert list to the td matrix
            Td[][] array = HtmlTableHelper.GetTdMatrix(statisticsDatas,
                                                       t => new Td[] {
                new Td {
                    Text = t.Dimension1
                },
                new Td {
                    Text = t.Dimension2
                },
            }, t => new Td[] {
                new Td {
                    Text = t.Denominator.ToString()
                },
                new Td {
                    Text = t.Numerator.ToString()
                },
                new Td {
                    Text = t.Quotient.ToString()
                },
            });

            // Read template content from template file
            string path     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Templates", TEMPLATE_FILE);
            string template = File.ReadAllText(path);

            // Construct the razor template engine
            ITemplateEngine templateEngine = new RazorTemplateEngine(new StreamWriter(new FileStream(DEBUG_FILE, FileMode.OpenOrCreate)));

            // Render by template and data
            string result = templateEngine.Render(template, array);

            Console.WriteLine(result);
            File.WriteAllText(GENERATED_FILE, result);
        }
Exemplo n.º 13
0
        public void TableModify_GivenTable()
        {
            var result     = "";
            var tableCount = 0;

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor  = new NoteEditor();
                var form    = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    editor.HTML = null;
                    var sut     = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //find table
                    IHTMLTable table = editor.Document.GetElementsByTagName("table")[0].DomElement as IHTMLTable;
                    //modify table
                    var prop         = new HtmlTableProperty(true);
                    prop.CaptionText = "Table modified";
                    sut.TableModify(table, prop);

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                result     = editor.HTML;
                tableCount = editor.Document.GetElementsByTagName("table").Count;
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.IsTrue(result.Contains("Table modified"));
            Assert.AreEqual(1, tableCount);
        }
Exemplo n.º 14
0
        public void GetTableProperties()
        {
            var tableProperties = new HtmlTableProperty(false);

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor  = new NoteEditor();
                var form    = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //fill table
                    FillTable((editor.Document.GetElementsByTagName("table")[0].DomElement) as IHTMLTable);
                    //move inside table
                    var body         = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange;
                    r2.findText("r2c2");
                    r2.select();
                    //modify table
                    sut.DeleteRow();
                    tableProperties = sut.GetTableProperties(GetTable(editor));

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.AreEqual(2, tableProperties.TableRows);
        }
Exemplo n.º 15
0
        public void DeleteTable()
        {
            var result = "";

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor = new NoteEditor();
                var form = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    editor.HTML = "Some Text There";
                    var body = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r = body.createTextRange() as IHTMLTxtRange;
                    r.findText("Text");
                    r.select();
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //move inside table
                    IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange;
                    r2.findText("Text");
                    r2.select();
                    //modify table
                    sut.DeleteTable();

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                result = editor.HTML;
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.IsFalse(result.ToLower().Contains("table"));
        }
Exemplo n.º 16
0
        public void TableModify_ContainingTable()
        {
            var result = "";
            var tableCount = 0;

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor = new NoteEditor();
                var form = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    editor.HTML = "Some Text There";
                    var body = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r = body.createTextRange() as IHTMLTxtRange;
                    r.findText("Text");
                    r.select();
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //move inside table
                    IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange;
                    r2.findText("Text");
                    r2.select();
                    //modify table
                    var prop = new HtmlTableProperty(true);
                    prop.CaptionText = "Table modified";
                    sut.TableModify(prop);

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                result = editor.HTML;
                tableCount = editor.Document.GetElementsByTagName("table").Count;
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.IsTrue(result.Contains("Table modified"));
            Assert.AreEqual(1, tableCount);
        }
Exemplo n.º 17
0
        public void GetSelectedTable_NoSelection()
        {
            bool result = false;

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor = new NoteEditor();
                var form = CreateForm();
                var sut = new HtmlTableHelper(editor);
                form.Shown += (sender, args) =>
                {
                    editor.HTML = "Some Text";
                    var body = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r = body.createTextRange() as IHTMLTxtRange;
                    r.findText("Text");
                    r.select();
                    sut.TableInsert(new HtmlTableProperty(true));
                    result = sut.GetSelectedTable() == null;
                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.IsTrue(result);
        }
Exemplo n.º 18
0
        public void GetTableProperties()
        {
            var tableProperties = new HtmlTableProperty(false);

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor = new NoteEditor();
                var form = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //fill table
                    FillTable((editor.Document.GetElementsByTagName("table")[0].DomElement) as IHTMLTable);
                    //move inside table
                    var body = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange;
                    r2.findText("r2c2");
                    r2.select();
                    //modify table
                    sut.DeleteRow();
                    tableProperties = sut.GetTableProperties(GetTable(editor));

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.AreEqual(2, tableProperties.TableRows);
        }
Exemplo n.º 19
0
        public void HtmlTableHelper()
        {
            var result = "";

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor = new NoteEditor();
                var form = CreateForm();
                form.Shown += (sender, args) =>
                {
                    editor.HTML = null;
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                result = editor.HTML;
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.IsTrue(result.ToLower().Contains("</table>"));
        }
Exemplo n.º 20
0
        public void InsertRowBelow_RowCountIncreased()
        {
            var rowCount = 0;

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor = new NoteEditor();
                var form = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    editor.HTML = "Some Text There";
                    var body = editor.Document.Body.DomElement as IHTMLBodyElement;
                    IHTMLTxtRange r = body.createTextRange() as IHTMLTxtRange;
                    r.findText("Text");
                    r.select();
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //move inside table
                    IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange;
                    r2.findText("Text");
                    r2.select();
                    //modify table
                    sut.InsertRowBelow();

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                rowCount = GetTable(editor).rows.length;
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.AreEqual(4, rowCount);
        }
Exemplo n.º 21
0
        public void TableModify_GivenTable()
        {
            var result = "";
            var tableCount = 0;

            System.Threading.Thread t = new System.Threading.Thread(() =>
            {
                var editor = new NoteEditor();
                var form = CreateForm();
                form.Shown += (sender, args) =>
                {
                    //insert table
                    editor.HTML = null;
                    var sut = new HtmlTableHelper(editor);
                    sut.TableInsert(new HtmlTableProperty(true));
                    //find table
                    IHTMLTable table = editor.Document.GetElementsByTagName("table")[0].DomElement as IHTMLTable;
                    //modify table
                    var prop = new HtmlTableProperty(true);
                    prop.CaptionText = "Table modified";
                    sut.TableModify(table, prop);

                    form.Close();
                };

                form.Controls.Add(editor);

                form.ShowDialog();

                result = editor.HTML;
                tableCount = editor.Document.GetElementsByTagName("table").Count;
            });
            t.SetApartmentState(System.Threading.ApartmentState.STA);
            t.Start();
            t.Join();

            Assert.IsTrue(result.Contains("Table modified"));
            Assert.AreEqual(1, tableCount);
        }