public void TestExtract_LongLong() { _quoteCapture.Add(100, 10, 21); _quoteCapture.Add(200, 20, 22); _quoteCapture.Add(300, 30, 23); _quoteCapture.Add(400, 40, 24); _quoteCapture.Add(500, 50, 26); IQuoteCapture qc = _quoteCapture.Extract(150L, 350L); Assert.AreEqual(2, qc.Count); Assert.AreEqual(200, qc.Time[0]); Assert.AreEqual(300, qc.Time[1]); Assert.AreEqual(20, qc.Price[0]); Assert.AreEqual(30, qc.Price[1]); Assert.AreEqual(30, qc.Price[1]); Assert.AreEqual(22, qc.Volume[0]); Assert.AreEqual(23, qc.Volume[1]); qc = _quoteCapture.Extract(10L, 110L); Assert.AreEqual(1, qc.Count); Assert.AreEqual(100, qc.Time[0]); qc = _quoteCapture.Extract(10L, 20L); Assert.AreEqual(0, qc.Count); qc = _quoteCapture.Extract(600L, 900L); Assert.AreEqual(0, qc.Count); qc = _quoteCapture.Extract(0L, 900L); Assert.AreEqual(5, qc.Count); _quoteCapture.Clear(); _quoteCapture.Add(100, 10); qc = _quoteCapture.Extract(80L, 110L); Assert.AreEqual(1, qc.Count); }
public void TestExtract_IntInt() { IQuoteCapture qc = null; // 测试sindex > eindex TestHelper.AssertException(() => _quoteCapture.Extract(1, 0), typeof(ArgumentException)); // 测试sindex < 0 TestHelper.AssertException(() => _quoteCapture.Extract(-1, 0), typeof(ArgumentException)); // 测试eindex < 0 TestHelper.AssertException(() => _quoteCapture.Extract(0, -1), typeof(ArgumentException)); // 测试eindex > _quoteCapture.Count - 1; _quoteCapture.Add(10, 12); TestHelper.AssertException(() => _quoteCapture.Extract(0, 5), typeof(ArgumentException)); _quoteCapture = new QuoteCapture("xyz"); _quoteCapture.Add(100, 10, 23); _quoteCapture.Add(200, 20, 24); _quoteCapture.Add(300, 30, 26); _quoteCapture.Add(400, 40, 27); _quoteCapture.Add(500, 50, 28); qc = _quoteCapture.Extract(1, 3); Assert.AreEqual(3, qc.Count); Assert.AreEqual(200, qc.Time[0]); Assert.AreEqual(300, qc.Time[1]); Assert.AreEqual(400, qc.Time[2]); Assert.AreEqual(20, qc.Price[0]); Assert.AreEqual(30, qc.Price[1]); Assert.AreEqual(40, qc.Price[2]); Assert.AreEqual(24, qc.Volume[0]); Assert.AreEqual(26, qc.Volume[1]); Assert.AreEqual(27, qc.Volume[2]); }