コード例 #1
0
        public void BarExistsTest()
        {
            IDataManager data = new OpenWealth.Data.Data();
            //data.Init(); сейчас всё делается в конструкторе, но в будущем может понадобится

            ISymbol symbol = data.GetSymbol("BarExistsTest");
            IScale  scale  = data.GetScale(ScaleEnum.tick, 1);
            Ticks   ticks  = new Ticks(symbol, scale);

            int index;

            Assert.AreEqual(ticks.BarExists(777, out index), false);
            Assert.AreEqual(0, index);

            ticks.Add(null, new Bar(DateTime.Now, 10, 1, 1, 1, 1, 1));

            Assert.AreEqual(ticks.BarExists(5, out index), false);
            Assert.AreEqual(0, index);
            Assert.AreEqual(ticks.BarExists(10, out index), true);
            Assert.AreEqual(0, index);
            Assert.AreEqual(ticks.BarExists(20, out index), false);
            Assert.AreEqual(1, index);

            ticks.Add(null, new Bar(DateTime.Now, 20, 1, 1, 1, 1, 1));

            Assert.AreEqual(ticks.BarExists(5, out index), false);
            Assert.AreEqual(0, index);
            Assert.AreEqual(ticks.BarExists(10, out index), true);
            Assert.AreEqual(0, index);
            Assert.AreEqual(ticks.BarExists(15, out index), false);
            Assert.AreEqual(1, index);
            Assert.AreEqual(ticks.BarExists(20, out index), true);
            Assert.AreEqual(1, index);
            Assert.AreEqual(ticks.BarExists(25, out index), false);
            Assert.AreEqual(2, index);
        }