public async Task GetSampleValuesAsyncTest()
        {
            using (var dt = UnitTestStatic.GetDataTable(1000))
            {
                using (var dummy = new CustomProcessDisplay(UnitTestInitializeCsv.Token))
                {
                    var reader = new DataTableWrapper(dt);
                    foreach (DataColumn col in dt.Columns)
                    {
                        var res = await DetermineColumnFormat.GetSampleValuesAsync(reader, 10,
                                                                                   new[] { col.Ordinal }, 10, "null",
                                                                                   dummy.CancellationToken);

                        if (col.ColumnName != "AllEmpty")
                        {
                            Assert.AreNotEqual(0, res[col.Ordinal].Values.Count, col.ColumnName);
                        }
                        else
                        {
                            Assert.AreEqual(0, res[col.Ordinal].Values.Count, col.ColumnName);
                        }
                    }
                }
            }
        }
        public void ApplyFiltersFilteredDataGridViewTest()
        {
            using (var fdgv = new FilteredDataGridView())
            {
                fdgv.ApplyFilters();
            }

            using (var fdgv = new FilteredDataGridView())
            {
                using (var comboBoxColumn = new DataGridViewComboBoxColumn())
                {
                    comboBoxColumn.Items.AddRange(Color.Red, Color.Yellow, Color.Green);
                    comboBoxColumn.ValueType = typeof(Color);
                }

                var boolColumn = new DataGridViewCheckBoxColumn();
                fdgv.Columns.Add(boolColumn);

                fdgv.ApplyFilters();
            }

            using (var dt = UnitTestStatic.GetDataTable())
                using (var filteredDataGridView = new FilteredDataGridView())
                {
                    filteredDataGridView.DataSource = dt;
                    using (var frm = new Form())
                    {
                        frm.Controls.Add(filteredDataGridView);
                        frm.Show();
                        filteredDataGridView.ApplyFilters();
                    }
                }
        }
Пример #3
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);
                     }
                 }
             }
         }
     });
 }
        public async Task GetSourceColumnInformationTestAsync2()
        {
            using (var dt = UnitTestStatic.GetDataTable())
            {
                using (var reader = new DataTableWrapper(dt))
                {
                    var fillGuessSettings = new FillGuessSettings
                    {
                        DetectNumbers    = true,
                        DetectDateTime   = true,
                        DetectPercentage = true,
                        DetectBoolean    = true,
                        DetectGUID       = true,
                        IgnoreIdColumns  = true
                    };

                    //await reader.OpenAsync(processDisplay.CancellationToken);
                    var(information, columns) = await reader.FillGuessColumnFormatReaderAsyncReader(fillGuessSettings,
                                                                                                    new ColumnCollection(), false, true, "<NULL>", UnitTestInitializeCsv.Token);

                    Assert.AreEqual(7, columns.Count(), "Recognized columns");
                    Assert.AreEqual(8, information.Count, "Information Lines");

                    var(information2, columns2) = await reader.FillGuessColumnFormatReaderAsyncReader(fillGuessSettings,
                                                                                                      new ColumnCollection(), true, true, "<NULL>", UnitTestInitializeCsv.Token);

                    Assert.AreEqual(11, columns2.Count());
                    // Added 4 text columns,
                    Assert.AreEqual(11, information2.Count);
                }
            }
        }
Пример #5
0
        public async System.Threading.Tasks.Task ReStoreViewSettingDetailControlAsync()
        {
            using (var dt = UnitTestStatic.GetDataTable())
            {
                using (var dc = new DetailControl())
                {
                    dc.HTMLStyle = UnitTestInitializeWin.HTMLStyle;
                    dc.DataTable = dt;
                    await dc.RefreshDisplayAsync(FilterType.All, UnitTestInitializeCsv.Token);

                    var columnFilters = new List <ToolStripDataGridViewColumnFilter>
                    {
                        new ToolStripDataGridViewColumnFilter(dc.FilteredDataGridView.Columns[0])
                    };

                    columnFilters[0].ColumnFilterLogic.Operator  = "=";
                    columnFilters[0].ColumnFilterLogic.ValueText = "Halloween";
                    columnFilters[0].ColumnFilterLogic.Active    = true;

                    var text = ViewSetting.StoreViewSetting(dc.FilteredDataGridView, columnFilters);

                    var fn = System.IO.Path.Combine(FileSystemUtils.ExecutableDirectoryName(), "test.delete");
                    FileSystemUtils.FileDelete(fn);
                    FileSystemUtils.WriteAllText(fn, text);
                    dc.ReStoreViewSetting(fn);
                    FileSystemUtils.FileDelete(fn);
                }
            }
        }
        public void HideEmptyColumnsTest()
        {
            using (var filteredDataGridView = new FilteredDataGridView())
            {
                var dt = UnitTestStatic.GetDataTable(100);
                filteredDataGridView.DataSource = dt;
                using (var frm = new Form())
                {
                    frm.Controls.Add(filteredDataGridView);
                    frm.Show();
                    var numCol = 0;
                    foreach (DataGridViewColumn col in filteredDataGridView.Columns)
                    {
                        if (col.Visible)
                        {
                            numCol++;
                        }
                    }
                    Assert.AreEqual(numCol, dt.Columns.Count);
                    filteredDataGridView.HideEmptyColumns();

                    numCol = 0;
                    foreach (DataGridViewColumn col in filteredDataGridView.Columns)
                    {
                        if (col.Visible)
                        {
                            numCol++;
                        }
                    }

                    Assert.AreEqual(numCol + 1, dt.Columns.Count);
                }
            }
        }
Пример #7
0
 public void FormShowMaxLength()
 {
     using (var dataTable = UnitTestStatic.GetDataTable(60))
         using (var form = new FormShowMaxLength(dataTable, dataTable.Select(), new List <string>(), UnitTestInitializeWin.HTMLStyle))
         {
             UnitTestWinFormHelper.ShowFormAndClose(form);
         }
 }
Пример #8
0
 public void FormUniqueDisplay()
 {
     using (var dataTable = UnitTestStatic.GetDataTable(60))
         using (var form = new FormUniqueDisplay(dataTable, dataTable.Select(), dataTable.Columns[0].ColumnName, UnitTestInitializeWin.HTMLStyle))
         {
             UnitTestWinFormHelper.ShowFormAndClose(form);
         }
 }
 public void FrozenColumns()
 {
     using (var dt = UnitTestStatic.GetDataTable())
         using (var filteredDataGridView = new FilteredDataGridView())
         {
             filteredDataGridView.DataSource    = dt;
             filteredDataGridView.FrozenColumns = 2;
             UnitTestWinFormHelper.WaitSomeTime(.2, UnitTestInitializeCsv.Token);
         }
 }
 public void HighlightText()
 {
     using (var dt = UnitTestStatic.GetDataTable())
         using (var filteredDataGridView = new FilteredDataGridView())
         {
             filteredDataGridView.DataSource    = dt;
             filteredDataGridView.HighlightText = "ag";
             UnitTestWinFormHelper.WaitSomeTime(.2, UnitTestInitializeCsv.Token);
             Assert.AreEqual("", filteredDataGridView.CurrentFilter);
         }
 }
Пример #11
0
 public void DynamicStorageSize()
 {
     Assert.AreEqual("500 Bytes",
                     UnitTestStatic.ExecuteWithCulture(() => StringConversion.DynamicStorageSize(500), "de-DE"));
     Assert.AreEqual("1.95 kB",
                     UnitTestStatic.ExecuteWithCulture(() => StringConversion.DynamicStorageSize(2000), "en-US"));
     Assert.AreEqual("9,77 kB",
                     UnitTestStatic.ExecuteWithCulture(() => StringConversion.DynamicStorageSize(10000), "de-DE"));
     Assert.AreEqual("195,31 kB",
                     UnitTestStatic.ExecuteWithCulture(() => StringConversion.DynamicStorageSize(200000), "de-DE"));
     Assert.AreEqual("1,91 MB",
                     UnitTestStatic.ExecuteWithCulture(() => StringConversion.DynamicStorageSize(2000000), "de-DE"));
 }
 public void SetRowHeightTest()
 {
     using (var filteredDataGridView = new FilteredDataGridView())
     {
         filteredDataGridView.DataSource = UnitTestStatic.GetDataTable(100);
         using (var frm = new Form())
         {
             frm.Controls.Add(filteredDataGridView);
             frm.Show();
             filteredDataGridView.SetRowHeight();
         }
     }
 }
Пример #13
0
        public void DataGridViewColumnFilterControl()
        {
            using (var dataTable = UnitTestStatic.GetDataTable(60))
            {
                var col = new DataGridViewTextBoxColumn
                {
                    ValueType        = dataTable.Columns[0].DataType,
                    Name             = dataTable.Columns[0].ColumnName,
                    DataPropertyName = dataTable.Columns[0].ColumnName
                };

                UnitTestWinFormHelper.ShowControl(new DataGridViewColumnFilterControl(col));
            }
        }
Пример #14
0
        public void ToolStripDataGridViewColumnFilterTest()
        {
            var data     = UnitTestStatic.GetDataTable(200);
            var dataview = new DataView(data, null, null, DataViewRowState.CurrentRows);
            var col      = new DataGridViewTextBoxColumn()
            {
                ValueType        = typeof(int),
                Name             = "int",
                DataPropertyName = "int"
            };
            var test = new ToolStripDataGridViewColumnFilter(typeof(int), col);

            Assert.AreEqual(true, test.ColumnFilterLogic.Active);
        }
Пример #15
0
        public void SelectedDataIntoClipboardTest()
        {
            using (var dgv = new DataGridView())
            {
                dgv.AutoGenerateColumns = true;
                dgv.DataSource          = UnitTestStatic.GetDataTable(100);
                using (var frm = new Form())
                {
                    frm.Controls.Add(dgv);
                    frm.Show();

                    dgv.SelectedDataIntoClipboard(true, false, CancellationToken.None);
                }
            }
        }
        public void GetActiveValueClusterTest()
        {
            var data     = UnitTestStatic.GetDataTable(200);
            var dataview = new DataView(data, null, null, DataViewRowState.CurrentRows);

            var test0a = new ValueClusterCollection();

            Assert.AreEqual(BuildValueClustersResult.ListFilled, test0a.BuildValueClusters(dataview, typeof(string), 0, 200));
            Assert.AreEqual(0, test0a.GetActiveValueCluster().Count());
            foreach (var iten in test0a.ValueClusters)
            {
                iten.Active = true;
            }
            Assert.AreEqual(test0a.ValueClusters.Count(), test0a.GetActiveValueCluster().Count());
        }
        public async Task GetSampleValuesAsync()
        {
            using (var dataTable = UnitTestStatic.GetDataTable(150, false))
            {
                using (var processDisplay = new CustomProcessDisplay(UnitTestInitializeCsv.Token))
                {
                    using (var reader = new DataTableWrapper(dataTable))
                    {
                        var res = await DetermineColumnFormat
                                  .GetSampleValuesAsync(reader, 100, new[] { 0, 1 }, 20, null, processDisplay.CancellationToken)
                                  .ConfigureAwait(false);

                        Assert.AreEqual(20, res[0].Values.Count);
                    }
                }
            }
        }
Пример #18
0
    public void ToolStripDataGridViewColumnFilterTest()
    {
      using (var data = UnitTestStatic.GetDataTable(200))
      using (new DataView(data, null, null, DataViewRowState.CurrentRows))
      {
        var col = new DataGridViewTextBoxColumn { ValueType = typeof(int), Name = "int", DataPropertyName = "int" };
        var test = new ToolStripDataGridViewColumnFilter(col);
        Assert.AreEqual(false, test.ColumnFilterLogic.Active);
        test.ColumnFilterLogic.Active = true;
        Assert.AreEqual(false, test.ColumnFilterLogic.Active);
        test.ColumnFilterLogic.Operator = "=";
        test.ColumnFilterLogic.ValueText = "2";
        test.ColumnFilterLogic.Active = true;
        Assert.AreEqual(true, test.ColumnFilterLogic.Active);

        Assert.IsNotNull(test.ValueClusterCollection);
      }
    }
        public void HideEmptyColumnsTest()
        {
            using (var filteredDataGridView = new FilteredDataGridView())
            {
                var dt = UnitTestStatic.GetDataTable();
                filteredDataGridView.DataSource = dt;
                using (var frm = new Form())
                {
                    frm.Controls.Add(filteredDataGridView);
                    frm.Show();
                    var numCol = filteredDataGridView.Columns.Cast <DataGridViewColumn>().Count(col => col.Visible);
                    Assert.AreEqual(numCol, dt.Columns.Count);
                    filteredDataGridView.HideEmptyColumns();

                    numCol = filteredDataGridView.Columns.Cast <DataGridViewColumn>().Count(col => col.Visible);

                    Assert.AreEqual(numCol + 1, dt.Columns.Count);
                }
            }
        }
        public void FilteredDataGridViewVarious_SetFilterMenu()
        {
            using (var data = UnitTestStatic.GetDataTable(200))
                using (var ctrl = new FilteredDataGridView())
                {
                    UnitTestWinFormHelper.ShowControl(new FilteredDataGridView(), 0.5d,
                                                      (control, form) =>
                    {
                        if (!(control is FilteredDataGridView ctrl2))
                        {
                            return;
                        }
                        ctrl2.DataSource = data;

                        // Refresh all columns filters
                        for (int col = 0; col < data.Columns.Count; col++)
                        {
                            ctrl2.SetFilterMenu(col);
                        }
                    });
Пример #21
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);
                 }
             }
         }
     });
 }
        public void BuildValueClustersTest()
        {
            var data     = UnitTestStatic.GetDataTable(200);
            var dataview = new DataView(data, null, null, DataViewRowState.CurrentRows);

            var test0a = new ValueClusterCollection();

            Assert.AreEqual(BuildValueClustersResult.ListFilled, test0a.BuildValueClusters(dataview, typeof(string), 0, 200));
            Assert.IsNotNull(test0a.ValueClusters);

            var test0b = new ValueClusterCollection();

            Assert.AreEqual(BuildValueClustersResult.TooManyValues, test0b.BuildValueClusters(dataview, typeof(string), 0, 1));
            Assert.AreEqual(0, test0b.ValueClusters.Count());

            var test1 = new ValueClusterCollection();

            Assert.AreEqual(BuildValueClustersResult.ListFilled, test1.BuildValueClusters(dataview, typeof(int), 1, 200));

            var test2 = new ValueClusterCollection();

            Assert.AreEqual(BuildValueClustersResult.ListFilled, test2.BuildValueClusters(dataview, typeof(DateTime), 2, 200));

            var test3 = new ValueClusterCollection();

            Assert.AreEqual(BuildValueClustersResult.ListFilled, test3.BuildValueClusters(dataview, typeof(bool), 3, 2));

            var test4 = new ValueClusterCollection();

            Assert.AreEqual(BuildValueClustersResult.ListFilled, test4.BuildValueClusters(dataview, typeof(double), 4, 200));

            var test5 = new ValueClusterCollection();

            Assert.AreEqual(BuildValueClustersResult.ListFilled, test5.BuildValueClusters(dataview, typeof(decimal), 5, 200));

            var test7 = new ValueClusterCollection();

            Assert.AreEqual(BuildValueClustersResult.ListFilled, test7.BuildValueClusters(dataview, typeof(string), 7, 200));
        }
        public void ValueClusterCollection()
        {
            var columnFilterLogic = new ColumnFilterLogic(typeof(int), "intCol");

            using (var data = UnitTestStatic.GetDataTable(200))
            {
                using (var dataView = new DataView(data, null, null, DataViewRowState.CurrentRows))
                {
                    columnFilterLogic.ValueClusterCollection.BuildValueClusters(dataView, typeof(int), 1);
                    var i = 0;
                    foreach (var cluster in columnFilterLogic.ValueClusterCollection.ValueClusters)
                    {
                        cluster.Active = true;
                        if (i++ > 2)
                        {
                            break;
                        }
                    }

                    columnFilterLogic.Active = true;
                    Assert.IsNotNull(columnFilterLogic.FilterExpression);
                }
            }
        }
Пример #24
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}");
                     }
                 }
             }
         }
     });
 }
Пример #25
0
 public static void ClassInitialize(TestContext context)
 {
     m_Data     = UnitTestStatic.GetDataTable(200);
     m_DataView = new DataView(m_Data, null, null, DataViewRowState.CurrentRows);
 }