예제 #1
0
 public void CopySelectedColumnsIntoClipboard()
 {
     Extensions.RunSTAThread(() =>
     {
         using (var dgv = new DataGridView())
         {
             dgv.AutoGenerateColumns = true;
             using (var dt = UnitTestStatic.GetDataTable())
             {
                 dgv.DataSource = dt;
                 using (var frm = new Form())
                 {
                     frm.Controls.Add(dgv);
                     frm.Show();
                     dgv.Columns[1].Selected = true;
                     dgv.Columns[2].Selected = true;
                     try
                     {
                         Clipboard.Clear();
                         var cp = new DataGridViewCopyPaste(UnitTestInitializeWin.HTMLStyle);
                         cp.SelectedDataIntoClipboard(dgv, true, false, UnitTestInitializeCsv.Token);
                         var dataObject = Clipboard.GetDataObject();
                         Assert.IsNotNull(dataObject);
                         Assert.IsNotNull(dataObject.GetData(DataFormats.Text));
                     }
                     catch (ExternalException e)
                     {
                         Console.WriteLine(e);
                         Assert.Inconclusive(e.Message);
                     }
                 }
             }
         }
     });
 }
예제 #2
0
 public void SelectedDataIntoClipboardAllTest()
 {
     Extensions.RunSTAThread(() =>
     {
         using (var dgv = new DataGridView())
         {
             dgv.AutoGenerateColumns = true;
             using (var dt = UnitTestStatic.GetDataTable())
             {
                 dgv.DataSource = dt;
                 using (var frm = new Form())
                 {
                     frm.Controls.Add(dgv);
                     frm.Show();
                     dgv.SelectAll();
                     var cp = new DataGridViewCopyPaste(UnitTestInitializeWin.HTMLStyle);
                     cp.SelectedDataIntoClipboard(dgv, true, false, UnitTestInitializeCsv.Token);
                 }
             }
         }
     });
 }
예제 #3
0
 public void SelectedDataIntoClipboardTest()
 {
     Extensions.RunSTAThread(() =>
     {
         using (var dgv = new DataGridView())
         {
             dgv.AutoGenerateColumns = true;
             using (var dt = UnitTestStatic.GetDataTable())
             {
                 dgv.DataSource = dt;
                 using (var frm = new Form())
                 {
                     frm.Controls.Add(dgv);
                     frm.Show();
                     try
                     {
                         Clipboard.Clear();
                         var cp = new DataGridViewCopyPaste(UnitTestInitializeWin.HTMLStyle);
                         cp.SelectedDataIntoClipboard(dgv, true, false, UnitTestInitializeCsv.Token);
                         var dataObject = Clipboard.GetDataObject();
                         Assert.IsNotNull(dataObject);
                         Assert.IsNotNull(dataObject.GetData(DataFormats.Text));
                     }
                     catch (ExternalException)
                     {
                         Assert.Inconclusive("Exception thrown but this can happen");
                     }
                     catch (Exception ex)
                     {
                         Assert.Fail($"Wrong exception {ex.Message}");
                     }
                 }
             }
         }
     });
 }