public void HTMLDisplay() { Extensions.RunSTAThread(() => { using (var tm = new TimedMessage()) { var stringBuilder = HTMLStyle.StartHTMLDoc(SystemColors.Control, ""); stringBuilder.Append(string.Format(UnitTestInitializeWin.HTMLStyle.H2, HTMLStyle.TextToHtmlEncode("Sample"))); stringBuilder.Append(string.Format(UnitTestInitializeWin.HTMLStyle.H2, HTMLStyle.TextToHtmlEncode("Sample2"))); stringBuilder.AppendLine(UnitTestInitializeWin.HTMLStyle.TableOpen); stringBuilder.AppendLine(UnitTestInitializeWin.HTMLStyle.TROpen); for (var index = 1; index <= 10; index++) { stringBuilder.AppendLine(string.Format(UnitTestInitializeWin.HTMLStyle.TD, HTMLStyle.TextToHtmlEncode("Test " + index.ToString()))); if (index % 4 == 0) { stringBuilder.AppendLine(UnitTestInitializeWin.HTMLStyle.TRClose); } } stringBuilder.AppendLine(UnitTestInitializeWin.HTMLStyle.TRClose); stringBuilder.AppendLine(UnitTestInitializeWin.HTMLStyle.TableClose); stringBuilder.AppendLine(UnitTestInitializeWin.HTMLStyle.TableClose); stringBuilder.AppendLine(UnitTestInitializeWin.HTMLStyle.TRClose); stringBuilder.AppendLine(UnitTestInitializeWin.HTMLStyle.TableClose); tm.Html = stringBuilder.ToString(); tm.Size = new Size(600, 450); UnitTestWinFormHelper.ShowFormAndClose(tm, 2); } }); }
public void MultiselectTreeViewRegular() { using (var treeView = new MultiselectTreeView()) { treeView.HTMLStyle = UnitTestInitializeWin.HTMLStyle; Assert.AreEqual(0, treeView.SelectedTreeNode.Count); var treeNode = new TreeNode("Test") { Tag = "test" }; treeView.Nodes.Add(treeNode); var treeNode2 = new TreeNode("Test2") { Tag = "test2" }; treeNode.Nodes.Add(treeNode2); var treeNode3 = new TreeNode("Test3") { Tag = "test3" }; treeNode.Nodes.Add(treeNode3); var treeNode3a = new TreeNode("Test3a") { Tag = "test3" }; treeNode3.Nodes.Add(treeNode3a); var treeNode3b = new TreeNode("Test3b") { Tag = "test3" }; treeNode3.Nodes.Add(treeNode3b); var firedAfter = false; var firedBefore = false; treeView.AfterSelect += (s, args) => { firedAfter = true; }; treeView.BeforeSelect += (s, args) => { firedBefore = true; }; UnitTestWinFormHelper.ShowControl(treeView, .2, (control, form) => { if (!(control is MultiselectTreeView text)) { return; } text.PressKey(Keys.Control | Keys.A); text.PressKey(Keys.Control | Keys.C); Application.DoEvents(); treeView.SelectedNode = treeNode2; treeView.SelectAll(); Application.DoEvents(); var result = treeView.SelectedToClipboard(); Assert.IsTrue(result.Contains(treeNode.Text)); Assert.IsTrue(result.Contains(treeNode2.Text)); Assert.IsTrue(result.Contains(treeNode3.Text)); });
public void QuotingControl() { using (var ctrl = new QuotingControl()) { ctrl.CsvFile = new CsvFile(); UnitTestWinFormHelper.ShowControl(ctrl); } }
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); } }
public void CsvTextDisplayShow() { using (var frm = new FormCsvTextDisplay(UnitTestInitializeCsv.GetTestPath("BasicCSV.txt"))) { UnitTestWinFormHelper.ShowFormAndClose(frm, .2, (f) => f.OpenFile(false, "\"", "\t", "", 1200, 1, "##")); } }
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 FormProcessDisplay() { // Log using (var frm = new FormProcessDisplay("Test Logger", true, UnitTestInitializeCsv.Token)) { frm.ShowInTaskbar = false; frm.Show(); frm.Maximum = 100; var sentTime = new TimeSpan(0); frm.ProgressTime += (sender, time) => { sentTime = time.EstimatedTimeRemaining; }; var end = 50; var step = 5; var wait = .1; for (var c = 0; c < end && !frm.CancellationToken.IsCancellationRequested; c += step) { frm.SetProcess($"This is a text\nLine {c}", c, true); UnitTestWinFormHelper.WaitSomeTime(wait, UnitTestInitializeCsv.Token); } // Left should be roughly .1 * 50 = 5 seconds Assert.IsTrue( (wait * (end / step)) - .5 < sentTime.TotalSeconds && sentTime.TotalSeconds < (wait * (end / step)) + .5, $"Estimated time should be roughly {wait * (end / step)}s but is {sentTime.TotalSeconds}"); frm.Close(); } // marquee using (var frm = new FormProcessDisplay("Test Marquee", false, UnitTestInitializeCsv.Token)) { frm.ShowInTaskbar = false; frm.Show(); frm.Maximum = 0; for (var c = 0; c < 100 && !frm.CancellationToken.IsCancellationRequested; c += 5) { frm.SetProcess($"This is a text\nLine {c}", c, true); UnitTestWinFormHelper.WaitSomeTime(.1, frm.CancellationToken); } frm.Close(); } // NoLog using (var frm = new FormProcessDisplay("Test", false, UnitTestInitializeCsv.Token)) { frm.ShowInTaskbar = false; frm.Show(); frm.Maximum = 100; for (var c = 0; c < 102 && !frm.CancellationToken.IsCancellationRequested; c += 4) { frm.SetProcess($"This is a text\nLine {c}", c, true); UnitTestWinFormHelper.WaitSomeTime(.1, frm.CancellationToken); } frm.Close(); } }
public void FormProcessCancel() { using (var frm = new FormProcessDisplay("Test Logger", true, UnitTestInitializeCsv.Token)) { frm.ShowInTaskbar = true; frm.Show(); UnitTestWinFormHelper.WaitSomeTime(.2, UnitTestInitializeCsv.Token); frm.Close(); } }
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 ResizeForm() { using (var frm = new ResizeForm()) { UnitTestWinFormHelper.ShowFormAndClose(frm, .2, (from) => { CsvTools.ResizeForm.SetFonts(from, SystemFonts.DialogFont); }); } }
public void FormEditSettings() { Extensions.RunSTAThread(() => { using (var frm = new FormEditSettings(new ViewSettings())) { UnitTestWinFormHelper.ShowFormAndClose(frm); } }); }
public async Task FormColumnUI_Guess() { var csvFile = new CsvFile(UnitTestInitializeCsv.GetTestPath("BasicCSV.txt")); var col = new Column("ExamDate", DataType.DateTime); csvFile.ColumnCollection.AddIfNew(col); using (var form = new FormColumnUI(col, false, csvFile, new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle)) { await UnitTestWinFormHelper.ShowFormAndCloseAsync(form, .2, frm => frm.Guess()); } }
public async System.Threading.Tasks.Task FormMain_BasicCSVAsync() { using (var frm = new FormMain(new ViewSettings())) { frm.Size = new Size(800, 600); await UnitTestWinFormHelper.ShowFormAndCloseAsync(frm, .2, frm.LoadCsvFile(Path.Combine(UnitTestInitializeCsv.GetTestPath("BasicCSV.txt.gz")))); Assert.IsNotNull(frm.DataTable); Assert.AreEqual(7, frm.DataTable.Rows.Count); } }
//[Timeout(20000)] public async System.Threading.Tasks.Task FormMain_AllFormatsPipeAsync() { using (var frm = new FormMain(new ViewSettings())) { await UnitTestWinFormHelper.ShowFormAndCloseAsync(frm, .1, frm.LoadCsvFile(UnitTestInitializeCsv.GetTestPath("AllFormatsPipe.txt"))); Assert.IsNotNull(frm.DataTable); // 45 records, one of the lines has a linefeed Assert.IsTrue(frm.DataTable.Rows.Count >= 46); } }
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); } }
public void FormColumnUI_Boolean() { var col = new Column("MyTest", DataType.Boolean) { True = "YO", False = "NOPE" }; using (var frm = new FormColumnUI(col, false, new CsvFile(), new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle)) { UnitTestWinFormHelper.ShowFormAndClose(frm); } }
public void FormColumnUI_TextPart() { var col = new Column("MyTest", DataType.TextPart) { PartSplitter = ":", Part = 2, PartToEnd = true }; using (var frm = new FormColumnUI(col, false, new CsvFile(), new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle)) { UnitTestWinFormHelper.ShowFormAndClose(frm, .1, f => f.SetPartLabels(":", "2", true)); } }
public void FormColumnUI_Numeric() { var col = new Column("MyTest", DataType.Numeric) { DecimalSeparator = ".", GroupSeparator = ",", NumberFormat = "0.00" }; using (var frm = new FormColumnUI(col, false, new CsvFile(), new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle)) { UnitTestWinFormHelper.ShowFormAndClose(frm, .1, f => f.UpdateNumericLabel(".", "00000", "")); } }
public void FormColumnUI() { var csvFile = new CsvFile(UnitTestInitializeCsv.GetTestPath("BasicCSV.txt")); var col = new Column("ExamDate", DataType.DateTime); csvFile.ColumnCollection.AddIfNew(col); using (var frm = new FormColumnUI(col, false, csvFile, new FillGuessSettings(), false, UnitTestInitializeWin.HTMLStyle)) { UnitTestWinFormHelper.ShowFormAndClose(frm); } }
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)); } }
public void FormColumnUIGetColumnHeader2() { var csvFile = new CsvFile { ID = "Csv", FileName = UnitTestInitializeCsv.GetTestPath("BasicCSV.txt") }; var col = new Column("Score", DataType.Double); csvFile.ColumnCollection.AddIfNew(col); using (var form = new FormColumnUI(col, false, csvFile, new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle)) { UnitTestWinFormHelper.ShowFormAndClose(form); } }
public void TextDisplay() { Extensions.RunSTAThread(() => { using (var tm = new TimedMessage()) { tm.Message = "Found values\rLine2\nDMS_Test_RN_Mat\tDMS_Test_RN_Mat\tDMS_Test_RN_Mat\tDMS_Test_RN_Mat\n" + "DMS_Test_RN_Mat\tDMS_Test_RN_Mat\tDMS_Test_RN_Mat\tDMS_Test_RN_Mat\n\nNote: Text has been cut off after 15 characters"; tm.Size = new Size(600, 450); UnitTestWinFormHelper.ShowFormAndClose(tm, 2); } }); }
public void FormColumnUIGetColumnHeaderAsync() { var csvFile = new CsvFile(UnitTestInitializeCsv.GetTestPath("BasicCSV.txt")) { ID = "Csv" }; csvFile.ColumnCollection.AddIfNew(new Column("ID", DataType.Integer)); csvFile.ColumnCollection.AddIfNew(new Column("ExamDate", DataType.DateTime)); csvFile.ColumnCollection.AddIfNew(new Column("Score", DataType.Double)); using (var form = new FormColumnUI(csvFile.ColumnCollection.Get("ExamDate"), false, csvFile, new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle)) { UnitTestWinFormHelper.ShowFormAndClose(form); } }
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); } });
public void WindowsAPICodePackWrapperFolder() { try { // Used to cancel after .2 seconds UnitTestWinFormHelper.RunTaskTimeout( token => Task.Run( () => { WindowsAPICodePackWrapper.Folder(FileSystemUtils.ExecutableDirectoryName(), "Test"); }, token)); } catch (COMException) { } catch (TimeoutException) { } catch (Exception ex) { Assert.Fail( $"Wrong exception got {ex.GetType().Name} expected OperationCanceledException : {ex.ExceptionMessages()}"); } }
public void FormColumnUI_DateTime() { var col = new Column("MyTest", DataType.DateTime) { DateFormat = "dd/MM/yyyy", DateSeparator = ".", TimeSeparator = ":" }; var df = new ValueFormatMutable() { DataType = DataType.DateTime, DateFormat = "dd/MMM/yyy", DateSeparator = "-", TimeSeparator = "#" }; using (var frm = new FormColumnUI(col, false, new CsvFile(), new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle)) UnitTestWinFormHelper.ShowFormAndClose(frm, .1, f => f.UpdateDateLabel(df, true, "HH:mm", "[UTC]")); using (var frm = new FormColumnUI(col, false, new CsvFile(), new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle)) UnitTestWinFormHelper.ShowFormAndClose(frm, .1, f => f.UpdateDateLabel(df, false, "HH:mm:ss", "OtherColumn")); using (var frm = new FormColumnUI(col, false, new CsvFile(), new FillGuessSettings(), true, UnitTestInitializeWin.HTMLStyle)) UnitTestWinFormHelper.ShowFormAndClose(frm, .1, f => f.AddDateFormat("dd MMM yy HH:mm tt")); }
public void APICodePackWrapperSave() { try { UnitTestWinFormHelper.RunTaskTimeout(token => Task.Run(() => WindowsAPICodePackWrapper.Save(FileSystemUtils.ExecutableDirectoryName(), "Test", null, null), token)); } catch (COMException) { } catch (TimeoutException) { } catch (OperationCanceledException) { } catch (Exception ex) { Assert.Fail( $"Wrong exception got {ex.GetType().Name} expected OperationCanceledException : {ex.ExceptionMessages()}"); } }
public void SyntaxHighlighterDelimitedTextTest() { using (var textBox = new FastColoredTextBox()) { var highlighter = new SyntaxHighlighterDelimitedText(textBox, "\"", ",", "\\", "##"); textBox.TextChangedDelayed += (sender, e) => { if (!(sender is FastColoredTextBox text)) { return; } highlighter.Highlight(text.Range); }; UnitTestWinFormHelper.ShowControl(textBox, .2, (tb, frm) => { if (!(tb is FastColoredTextBox text)) { return; } text.Text = "skipped line\r## CommentLine\r\"Header\t1\",Header 2\r\nLine\t1 Column1,Line 1 Column 2\rLine\t2 Column1,Line 2 \\\"Column 2"; highlighter.Comment(new Range(text, 0, 0, 0, 1)); }, 2);
public void FillGuessSettingEditShow() => UnitTestWinFormHelper.ShowControl(new FillGuessSettingEdit());
public void SearchShow() => UnitTestWinFormHelper.ShowControl(new Search());