public void CallsDelegateCorrectly() { var left = new Identity("left"); var right = new Identity("right"); var composite = new CompositeIndicator <IndicatorDataPoint>(left, right, (l, r) => { Assert.AreEqual(left, l); Assert.AreEqual(right, r); return(l + r); }); composite.Update(DateTime.Today, 1m); Assert.AreEqual(2m, composite.Current.Value); }
public void CallsDelegateCorrectly() { var left = new Identity("left"); var right = new Identity("right"); var composite = new CompositeIndicator<IndicatorDataPoint>(left, right, (l, r) => { Assert.AreEqual(left, l); Assert.AreEqual(right, r); return l + r; }); composite.Update(DateTime.Today, 1m); Assert.AreEqual(2m, composite.Current.Value); }
public void CompositeIsReadyWhenBothAre() { var composite = new CompositeIndicator<IndicatorDataPoint>(new Delay(1), new Delay(2), (left, right) => left + right); composite.Update(DateTime.Today.AddSeconds(0), 1m); Assert.IsFalse(composite.IsReady); Assert.IsFalse(composite.Left.IsReady); Assert.IsFalse(composite.Right.IsReady); composite.Update(DateTime.Today.AddSeconds(1), 2m); Assert.IsFalse(composite.IsReady); Assert.IsTrue(composite.Left.IsReady); Assert.IsFalse(composite.Right.IsReady); composite.Update(DateTime.Today.AddSeconds(2), 3m); Assert.IsTrue(composite.IsReady); Assert.IsTrue(composite.Left.IsReady); Assert.IsTrue(composite.Right.IsReady); composite.Update(DateTime.Today.AddSeconds(3), 4m); Assert.IsTrue(composite.IsReady); Assert.IsTrue(composite.Left.IsReady); Assert.IsTrue(composite.Right.IsReady); }
public void CompositeIsReadyWhenBothAre() { var composite = new CompositeIndicator <IndicatorDataPoint>(new Delay(1), new Delay(2), (left, right) => left + right); composite.Update(DateTime.Today.AddSeconds(0), 1m); Assert.IsFalse(composite.IsReady); Assert.IsFalse(composite.Left.IsReady); Assert.IsFalse(composite.Right.IsReady); composite.Update(DateTime.Today.AddSeconds(1), 2m); Assert.IsFalse(composite.IsReady); Assert.IsTrue(composite.Left.IsReady); Assert.IsFalse(composite.Right.IsReady); composite.Update(DateTime.Today.AddSeconds(2), 3m); Assert.IsTrue(composite.IsReady); Assert.IsTrue(composite.Left.IsReady); Assert.IsTrue(composite.Right.IsReady); composite.Update(DateTime.Today.AddSeconds(3), 4m); Assert.IsTrue(composite.IsReady); Assert.IsTrue(composite.Left.IsReady); Assert.IsTrue(composite.Right.IsReady); }