private void ValidateTimeRange(GraphChromatogram graphChromatogram, double[] msMsRTs, double range, double gradientLength) { var statMsMsRTs = new Statistics(msMsRTs); double minRT = double.MaxValue, maxRT = double.MinValue; foreach (var curve in graphChromatogram.CurveList) { minRT = Math.Min(minRT, curve.Points[0].X); maxRT = Math.Max(maxRT, curve.Points[curve.NPts - 1].X); } if (statMsMsRTs.Min() < range / 2) { Assert.AreEqual(minRT, 0.0, 1); minRT = statMsMsRTs.Min() - range / 2; } if (statMsMsRTs.Max() > gradientLength - range / 2) { Assert.AreEqual(maxRT, gradientLength, 1); maxRT = statMsMsRTs.Max() + range / 2; } double msMsRtsRange = statMsMsRTs.Range(); double rangeActual = maxRT - minRT - msMsRtsRange; if (Math.Abs(range - rangeActual) > 0.2) { // Some cases with very wide range of scans may not have enough gradient // to accomodate the desired range. string message = string.Format("Expected: {0}, Actual: {1}, RangeIds: {2}, Min: {3}, Max: {4}, MinIds: {5}, MaxIds: {6}", range, rangeActual, msMsRtsRange, minRT, maxRT, statMsMsRTs.Min(), statMsMsRTs.Max()); Assert.IsTrue(msMsRtsRange > 10, message); Assert.IsTrue(rangeActual > range - 1, message); } }
protected override void DoTest() { //import some data RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("SplitGraphUnitTest.sky"))); WaitForDocumentLoaded(); //make sure the check box can be turned on Settings.Default.UsePowerOfTen = false; ToolOptionsDlg = ShowDialog <ToolOptionsUI>(() => SkylineWindow.ShowToolOptionsUI()); RunUI(() => { Assert.IsFalse(ToolOptionsDlg.PowerOfTenCheckBox); ToolOptionsDlg.PowerOfTenCheckBox = true; }); OkDialog(ToolOptionsDlg, ToolOptionsDlg.OkDialog); Assert.IsTrue(Settings.Default.UsePowerOfTen); //import some data RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("SplitGraphUnitTest.sky"))); WaitForDocumentLoaded(); //make sure the graph is in scientific notation GraphChromatogram graph = FindOpenForm <GraphChromatogram>(); AssertScientificNotation(graph.GraphItem); //make sure the check box can be turned off ToolOptionsDlg2 = ShowDialog <ToolOptionsUI>(() => SkylineWindow.ShowToolOptionsUI()); RunUI(() => { Assert.IsTrue(ToolOptionsDlg2.PowerOfTenCheckBox); ToolOptionsDlg2.PowerOfTenCheckBox = false; }); OkDialog(ToolOptionsDlg2, ToolOptionsDlg2.OkDialog); Assert.IsFalse(Settings.Default.UsePowerOfTen); }
private static GraphObj GetChromRect(GraphChromatogram graphChrom) { return(graphChrom.GraphItem.GraphObjList.FirstOrDefault(obj => { var objTag = obj.Tag as ChromGraphItem.GraphObjTag; return objTag != null && objTag.GraphObjType == ChromGraphItem.GraphObjType.original_peak_shading; })); }
private static Point GetTopLeft(GraphChromatogram graph) { return(GetTopLeft(graph.Parent)); }
/// <summary> /// Allows point keys to be off a little (2 pixels), which currently seems to happen /// intermittently during nightly test runs, and if you run this test off-screen for /// many runs. /// </summary> private bool ContainsKeyTolerant <TValue>(IDictionary <Point, TValue> dictGraphPositions, GraphChromatogram graphChromatogram) { if (!graphChromatogram.Visible) { return(true); } var ptTopLeft = GetTopLeft(graphChromatogram); if (dictGraphPositions.ContainsKey(ptTopLeft)) { return(true); } const int tolerance = 2; foreach (var ptKey in dictGraphPositions.Keys) { if (ptKey.EqualsTolerant(ptTopLeft, tolerance)) { dictGraphPositions.Add(ptTopLeft, dictGraphPositions[ptKey]); return(true); } } return(false); }