Пример #1
0
        public void ShouldCorrectlyReportSize()
        {
            ICollection <MarketSnapshot> snapshots = new List <MarketSnapshot>();

            Buffer = CreateBuffer(2);
            Assert.AreEqual(0, Buffer.Size());
            Assert.True(Buffer.IsEmpty());
            Assert.False(Buffer.IsFull());

            Buffer.Offer(BpSnapshot);
            Assert.AreEqual(1, Buffer.Size());
            Assert.False(Buffer.IsEmpty());
            Assert.False(Buffer.IsFull());

            Buffer.Offer(VodSnapshot1.GetInstrumentId(), VodSnapshot1);
            Assert.AreEqual(2, Buffer.Size());
            Assert.False(Buffer.IsEmpty());
            Assert.True(Buffer.IsFull());

            Buffer.Poll(snapshots, 1);
            Assert.AreEqual(1, Buffer.Size());
            Assert.False(Buffer.IsEmpty());
            Assert.False(Buffer.IsFull());

            Buffer.Poll(snapshots, 1);
            Assert.AreEqual(0, Buffer.Size());
            Assert.True(Buffer.IsEmpty());
            Assert.False(Buffer.IsFull());
        }
 private static int IndexOf(MarketSnapshot snapshot)
 {
     return (int)snapshot.GetInstrumentId();
 }
Пример #3
0
 private void AddCollapsibleValue(MarketSnapshot snapshot)
 {
     Assert.True(Buffer.Offer(snapshot.GetInstrumentId(), snapshot));
 }
 private static int IndexOf(MarketSnapshot snapshot)
 {
     return((int)snapshot.GetInstrumentId());
 }
 private void AddCollapsibleValue(MarketSnapshot snapshot)
 {
     Assert.True(Buffer.Offer(snapshot.GetInstrumentId(), snapshot));
 }
Пример #6
0
        private void Put(long id, MarketSnapshot snapshot)
        {
            bool success = _buffer.Offer(id, snapshot);

            if (!success)
            {
                throw new Exception("failed to add instrument id " + snapshot.GetInstrumentId());
            }
        }