Beispiel #1
0
        public void Test_Remove()
        {
            var context      = new QuotationQueue();
            var providerTime = DateTimeOffset.Now.ToUnixTimeSeconds();
            var arrivedTime  = DateTime.Now;

            context.Add(new Quotation(_symbol, providerTime, arrivedTime.AddMilliseconds(-1001))
            {
                Bid = 1
            });
            context.Add(new Quotation(_symbol, providerTime, arrivedTime.AddMilliseconds(20))
            {
                Bid = 2
            });

            context.Add(new Quotation(_symbol, providerTime, arrivedTime.AddMilliseconds(990))
            {
                Bid = 3
            });
            context.Add(new Quotation(_symbol, providerTime, arrivedTime.AddMilliseconds(1020))
            {
                Bid = 4
            });

            context.Remove(1);

            Assert.Equal(3, context.Count());
        }
Beispiel #2
0
        public void Test_RealTimeQuotation()
        {
            var context      = new QuotationQueue();
            var providerTime = DateTimeOffset.Now.ToUnixTimeSeconds();
            var arrivedTime  = DateTime.Now;

            context.Add(new Quotation(_symbol, providerTime, arrivedTime)
            {
                Bid = 1
            });

            context.Add(new Quotation(_symbol, providerTime, arrivedTime.AddMilliseconds(1130))
            {
                Bid = 2
            });
            context.Add(new Quotation(_symbol, providerTime, arrivedTime.AddMilliseconds(2330))
            {
                Bid = 3
            });

            var actual = context.GetQuotation(arrivedTime.AddMilliseconds(1500));

            Assert.NotNull(actual);
            Assert.Equal(actual.Bid, 2m);

            actual = context.GetQuotation(arrivedTime);
            Assert.NotNull(actual);
            Assert.Equal(actual.Bid, 1m);
        }