Esempio n. 1
0
        public void ThrowsOnPastTimes()
        {
            var target = new TestIndicator();

            var time = DateTime.UtcNow;

            target.Update(new IndicatorDataPoint(time, 1m));
            target.Update(new IndicatorDataPoint(time.AddMilliseconds(-1), 2m));
        }
Esempio n. 2
0
        public void ThrowsOnPastTimes()
        {
            var target = new TestIndicator();

            var time = DateTime.UtcNow;

            target.Update(new IndicatorDataPoint(time, 1m));
            target.Update(new IndicatorDataPoint(time.AddMilliseconds(-1), 2m));
        }
Esempio n. 3
0
        public void ThrowsOnPastTimes()
        {
            var target = new TestIndicator();

            var time = DateTime.UtcNow;

            target.Update(new IndicatorDataPoint(time, TimeZone.Utc, 1m));

            Action act = () => target.Update(new IndicatorDataPoint(time.AddMilliseconds(-1), TimeZone.Utc, 2m));

            act.ShouldThrow <ArgumentException>()
            .Where(x => x.Message.StartsWith("This is a forward only indicator:"));
        }
Esempio n. 4
0
        public void PassesOnDuplicateTimes()
        {
            var target = new TestIndicator();

            var time = DateTime.UtcNow;

            const decimal value1 = 1m;
            var data = new IndicatorDataPoint(time, value1);
            target.Update(data);
            Assert.AreEqual(value1, target.Current.Value);

            // this won't update because we told it to ignore duplicate
            // data based on time
            target.Update(data);
            Assert.AreEqual(value1, target.Current.Value);
        }
Esempio n. 5
0
        public void PassesOnDuplicateTimes()
        {
            var target = new TestIndicator();

            var time = DateTime.UtcNow;

            const decimal value1 = 1m;
            var           data   = new IndicatorDataPoint(time, value1);

            target.Update(data);
            Assert.AreEqual(value1, target.Current.Value);

            // this won't update because we told it to ignore duplicate
            // data based on time
            target.Update(data);
            Assert.AreEqual(value1, target.Current.Value);
        }
Esempio n. 6
0
        public void ThrowsOnDifferentDataType()
        {
            var target = new TestIndicator();

            Assert.Throws <ArgumentException>(() =>
            {
                target.Update(new Tick());
            }, "expected to be of type");
        }
Esempio n. 7
0
        public void UpdatesProperly()
        {
            // we want to make sure the initialized value is the default value
            // for a datapoint, and also verify the our indicator updates as we
            // expect it to, in this case, it should return identity
            var target = new TestIndicator();

            Assert.AreEqual(DateTime.MinValue, target.Current.Time);
            Assert.AreEqual(0m, target.Current.Value);

            var time = DateTime.UtcNow;
            var data = new IndicatorDataPoint(time, 1m);

            target.Update(data);
            Assert.AreEqual(1m, target.Current.Value);

            target.Update(new IndicatorDataPoint(time.AddMilliseconds(1), 2m));
            Assert.AreEqual(2m, target.Current.Value);
        }
Esempio n. 8
0
        public void UpdatesProperly()
        {
            // we want to make sure the initialized value is the default value
            // for a datapoint, and also verify the our indicator updates as we
            // expect it to, in this case, it should return identity
            var target = new TestIndicator();

            Assert.AreEqual(DateTime.MinValue, target.Current.Time);
            Assert.AreEqual(0m, target.Current.Value);

            var time = DateTime.UtcNow;
            var data = new IndicatorDataPoint(time, 1m);

            target.Update(data);
            Assert.AreEqual(1m, target.Current.Value);

            target.Update(new IndicatorDataPoint(time.AddMilliseconds(1), 2m));
            Assert.AreEqual(2m, target.Current.Value);
        }
Esempio n. 9
0
        public void ThrowsOnDifferentDataType()
        {
            var target = new TestIndicator();

            target.Update(new Tick());
        }