Exemple #1
0
        public void InsertBar_MultipleInsert()
        {
            string  sym   = "FTI";
            int     d     = 20070926;
            var     bint  = BarInterval.FiveMin;
            var     bsize = (int)bint;
            BarList org   = new BarListImpl(bint, sym);

            Assert.IsTrue(org.isValid, "your original barlist is not valid 1");
            int orgcount = org.Count;

            Assert.AreEqual(0, orgcount);

            int h = 7;
            int m = 55;

            for (int i = 0; i < 10; i++)
            {
                int t      = h * 10000 + m * 100;
                Bar insert = new BarImpl(30, 30, 30, 30, 10000, d, t, sym, bsize);
                Assert.IsTrue(insert.isValid, "your bar to insert is not valid #" + i);
                int insertpos = BarListImpl.GetBarIndexPreceeding(org, insert.Bardate, insert.Bartime);
                Assert.AreEqual(i - 1, insertpos, "insertion position#" + i);
                BarList inserted = BarListImpl.InsertBar(org, insert, insertpos);
                Assert.IsTrue(g.ta(i + 1 == inserted.Count, BarListImpl.Bars2String(org) + Environment.NewLine + BarListImpl.Bars2String(inserted)), "element count after insertion #" + i + " pos: " + insertpos);
                m += 5;
                if (m >= 60)
                {
                    h += m / 60;
                    m  = m % 60;
                }
                org = inserted;
            }
            Assert.AreEqual(orgcount + 10, org.Count, "total element count after insertion");
        }