public void NullValuesAreNotStored1() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var initialValues = new Dictionary <string, object>() { ["id"] = 12, ["name"] = "A", ["age"] = null, }; var row = new TrackedRow(context.CreateRow(null, initialValues)); Assert.AreEqual(2, row.ColumnCount); Assert.IsTrue(row.Values.All(kvp => kvp.Value != null)); row["age"] = 7; Assert.AreEqual(3, row.ColumnCount); Assert.IsTrue(row.Values.All(kvp => kvp.Value != null)); row["name"] = null; Assert.AreEqual(2, row.ColumnCount); Assert.IsTrue(row.Values.All(kvp => kvp.Value != null)); }
public void MergeTestWithValues() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var row = new TrackedRow(context.CreateRow(null)); row["a"] = 1; row["b"] = "dog"; row["c"] = 7.1d; var newValues = new Dictionary <string, object>() { ["b"] = "cat", ["c"] = null, ["d"] = 8m, }; row.MergeWith(newValues); Assert.AreEqual(3, row.ColumnCount); Assert.AreEqual(1, row["a"]); Assert.AreEqual("cat", row["b"]); Assert.IsFalse(row.HasValue("c")); Assert.AreEqual(8m, row["d"]); }
public void MergeTestWithRow() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var row = new TrackedRow(context.CreateRow(null)); row["a"] = 1; row["b"] = "dog"; row["c"] = 7.1d; var newRow = new SlimRow() { ["b"] = "cat", ["c"] = 7.1d, ["d"] = 8m, }; row.MergeWith(newRow.Values); Assert.AreEqual(4, row.ColumnCount); Assert.AreEqual(1, row["a"]); Assert.AreEqual("cat", row["b"]); Assert.AreEqual(7.1d, row["c"]); Assert.AreEqual(8m, row["d"]); }
public void IsNullOrEmptyTrue1() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var row = new TrackedRow(context.CreateRow(null)); Assert.AreEqual(true, row.IsNullOrEmpty()); }
public void IsNullOrEmptyFalse() { var context = TestExecuter.GetContext(); context.SetRowType <Row>(); var row = new TrackedRow(context.CreateRow(null)); row["a"] = 5; Assert.AreEqual(false, row.IsNullOrEmpty()); }
public void MultipleNullColumnsResultsNonNullKey() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var initialValues = new Dictionary <string, object>(); var row = new TrackedRow(context.CreateRow(null, initialValues)); var result = row.GenerateKey("id", "name"); Assert.IsNotNull(result); }
public void IsNullOrEmptyTrue3() { var context = TestExecuter.GetContext(); context.SetRowType <Row>(); var row = new TrackedRow(context.CreateRow(null)); row["a"] = ""; row["a"] = "x"; row["a"] = null; Assert.AreEqual(true, row.IsNullOrEmpty()); }
public void DateTimeOffsetKeyIsInvariantWithMilliseconds() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var initialValues = new Dictionary <string, object>() { ["dto"] = new DateTimeOffset(2020, 02, 20, 12, 12, 0, 666, new TimeSpan(2, 0, 0)), }; var row = new TrackedRow(context.CreateRow(null, initialValues)); var result = row.GenerateKey("dto"); Assert.AreEqual("2020.02.20 12:12:00.6660000 +02:00", result); }
public void KeyCaseIgnored() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var initialValues = new Dictionary <string, object>() { ["date"] = new DateTime(2020, 02, 20, 12, 12, 0, 666), }; var row = new TrackedRow(context.CreateRow(null, initialValues)); var result = row["DATE"]; Assert.AreEqual(new DateTime(2020, 02, 20, 12, 12, 0, 666), result); }
public void HasErrorFalse() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var initialValues = new Dictionary <string, object>() { ["id"] = 12, ["name"] = "A", }; var row = new TrackedRow(context.CreateRow(null, initialValues)); Assert.IsFalse(row.HasError()); }
public void TimeSpanKeyIsInvariantWithDaysAndMilliseconds() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var initialValues = new Dictionary <string, object>() { ["time"] = new TimeSpan(1, 1, 0), }; var row = new TrackedRow(context.CreateRow(null, initialValues)); var result = row.GenerateKey("time"); Assert.AreEqual("0:01:01:00.0000000", result); }
public void ToDebugStringStartsWithUid() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var initialValues = new Dictionary <string, object>() { ["id"] = 12, ["name"] = "x", }; var row = new TrackedRow(context.CreateRow(null, initialValues)); var result = row.ToDebugString(); Assert.IsTrue(result.StartsWith("uid", StringComparison.InvariantCultureIgnoreCase)); }
public void IntKeyIsInvariant() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var initialValues = new Dictionary <string, object>() { ["id"] = 1234567, ["date"] = new DateTime(2020, 02, 20, 12, 12, 0, 666), }; var row = new TrackedRow(context.CreateRow(null, initialValues)); var result = row.GenerateKey("id", "date"); Assert.IsTrue(result.Contains("1234567", StringComparison.Ordinal)); Assert.IsTrue(result.Contains("2020.02.20 12:12:00.6660000", StringComparison.Ordinal)); }
public void NullValuesAreNotStored2() { var context = TestExecuter.GetContext(); context.SetRowType <DictionaryRow>(); var initialValues = new Dictionary <string, object>() { ["id"] = 12, ["name"] = "A", }; var row = new TrackedRow(context.CreateRow(null, initialValues)); Assert.AreEqual(2, row.ColumnCount); row["id"] = null; Assert.AreEqual(1, row.ColumnCount); row["trash"] = null; Assert.AreEqual(1, row.ColumnCount); }
private void ListView_MouseDoubleClick(object sender, MouseEventArgs e) { var list = sender as ListView; var info = list.HitTest(e.X, e.Y); if (info.Item?.Tag is TrackedProcessInvocation process) { var relevantRowUids = Context.Index.GetProcessRowMap(process.InvocationUid); var finishedRows = new HashSet <int>(); var currentProcesses = new Dictionary <int, TrackedProcessInvocation>(); var rows = new Dictionary <int, TrackedRow>(); Context.Index.EnumerateThroughRowEvents(e => { if (relevantRowUids.Contains(e.RowUid) && !finishedRows.Contains(e.RowUid)) { if (e is RowCreatedEvent rce) { var creatorProc = Context.WholePlaybook.ProcessList[rce.ProcessInvocationUid]; var row = new TrackedRow() { Uid = rce.RowUid, CreatorProcess = creatorProc, PreviousProcess = null, }; if (creatorProc == process) { row.NewValues = new Dictionary <string, object>(rce.Values, StringComparer.OrdinalIgnoreCase); } else { row.PreviousValues = new Dictionary <string, object>(rce.Values, StringComparer.OrdinalIgnoreCase); } currentProcesses[row.Uid] = creatorProc; row.AllEvents.Add(rce); rows.Add(row.Uid, row); } else if (e is RowValueChangedEvent rvce) { var row = rows[rvce.RowUid]; row.AllEvents.Add(rvce); var values = currentProcesses[row.Uid] == process ? row.NewValues : row.PreviousValues; foreach (var kvp in rvce.Values) { if (kvp.Value == null) { values.Remove(kvp.Key); } else { values[kvp.Key] = kvp.Value; } } } else if (e is RowOwnerChangedEvent roce) { var newProc = roce.NewProcessInvocationUid != null ? Context.WholePlaybook.ProcessList[roce.NewProcessInvocationUid.Value] : null; var row = rows[roce.RowUid]; row.AllEvents.Add(roce); var currentProcess = currentProcesses[row.Uid]; if (newProc == process) { row.NewValues = new Dictionary <string, object>(row.PreviousValues, StringComparer.OrdinalIgnoreCase); row.PreviousProcess = currentProcess; } else if (currentProcess == process) { finishedRows.Add(row.Uid); row.NextProcess = newProc; } currentProcesses[row.Uid] = newProc; } return(finishedRows.Count < relevantRowUids.Count); } return(true); }, DiagnosticsEventKind.RowCreated, DiagnosticsEventKind.RowValueChanged, DiagnosticsEventKind.RowOwnerChanged); if (rows.Values.Count > 0) { using (var form = new Form()) { form.FormBorderStyle = FormBorderStyle.Sizable; form.WindowState = FormWindowState.Normal; form.StartPosition = FormStartPosition.Manual; form.Bounds = new Rectangle(Screen.PrimaryScreen.Bounds.Left + 100, Screen.PrimaryScreen.Bounds.Top + 100, Screen.PrimaryScreen.Bounds.Width - 200, Screen.PrimaryScreen.Bounds.Height - 200); form.KeyPreview = true; form.KeyPress += (s, e) => { if (e.KeyChar == (char)Keys.Escape) { form.Close(); } }; var control = new ProcessRowListControl(form, process, rows.Values.ToList()); control.Updater.RefreshStarted += (sender, args) => { form.Text = "LOADING..."; }; control.Updater.RefreshFinished += (sender, args) => { form.Text = "Process output: " + process.Name; }; ToolTipSingleton.Remove(ListView); form.ShowDialog(); } } } }