Esempio n. 1
0
        public void OffsetAfterDeletion()
        {
            string     fn = TestData.DataPath + "\\el68d_export.csv";
            TextSeries s  = new TextSeries(fn);

            s.Read();
            int count = s.Count;

            Assert.AreEqual(s.Count, 1145, "Test Data has been modified....expected 1145 records. found " + s.Count);
            // delete middle half of data first.
            int idx = s.Count / 4;

            Selection sel = new Selection(s[idx].DateTime, s[s.Count - idx - 1].DateTime, -1000, 1000);

            Console.WriteLine("about to delete selection : " + sel.ToString());
            s.Delete(sel);

            Assert.IsTrue(count > s.Count, "some data should be missing ");

            double[] values = new double[s.Count];
            for (int i = 0; i < values.Length; i++)
            {
                values[i] = s[i].Value; // copy data before offset.
            }
            // select all data
            sel = new Selection(s[0].DateTime, s[s.Count - 1].DateTime, -1000, 1000);
            Reclamation.TimeSeries.Math.Offset(s, sel, System.Math.PI);
            for (int i = 0; i < values.Length; i++)
            {
                Assert.AreEqual(values[i] + System.Math.PI, s[i].Value, 0.000001, "offset failed");
            }
        }
Esempio n. 2
0
        public void DeleteSelectionInEL68D()
        {
            //2005-02-02 06:53:52.331,98.4335632324219
            //2005-02-04 09:24:53.233,98.4335632324219

            string     fn = Path.Combine(TestData.DataPath, "el68d_export.csv");
            TextSeries s  = new TextSeries(fn);

            s.Read();
            Assert.AreEqual(s.Count, 1145, "Test Data has been modified....expected 1145 records. found " + s.Count);
            DateTime delete1 = Convert.ToDateTime("2005-02-02 06:53:52.331");
            DateTime delete2 = Convert.ToDateTime("2005-02-04 09:24:53.233");

            Assert.AreEqual(186, s.IndexOf(delete1), "test data has been modified could not find " + delete1.ToShortDateString() + " " + delete1.ToLongTimeString());
            Assert.AreEqual(490, s.IndexOf(delete2), "test data has been modified could not find " + delete2.ToShortDateString() + " " + delete2.ToLongTimeString());
            DateTime  t1  = new DateTime(2005, 2, 2);
            DateTime  t2  = new DateTime(2005, 2, 4, 10, 30, 0, 0);
            Selection sel = new Selection(t1, t2, 30, 200);

            s.Delete(sel);// should delete two records in selection.
            Assert.AreEqual(s.Count, 1143, "expected 1143 records. found " + s.Count);


            Assert.AreEqual(-1, s.IndexOf(delete1), "delete1 point was not deleted ");
            Assert.AreEqual(-1, s.IndexOf(delete2), "delete2 point was not deleted ");
        }