public void Strength_Buy0Sell100_ReturnsSell0() { var combinedSignal = new DefensiveCombinedSignal( new BuySignal( 0 ), new SellSignal( 100 ) ); var expectedSignal = new SellSignal( 0 ); Assert.That( combinedSignal, Is.EqualTo( expectedSignal ) ); }
public void Strength_Buy100Sell50_ReturnsNeutral75() { var combinedSignal = new DefensiveCombinedSignal( new BuySignal( 100 ), new SellSignal( 50 ) ); var expectedSignal = new NeutralSignal( 75 ); Assert.That( combinedSignal, Is.EqualTo( expectedSignal ) ); }
public void Equals_WithDifferentSignal_ReturnsFalse() { var signal1 = new DefensiveCombinedSignal( new BuySignal( 4, 7 ) ); var signal2 = new DefensiveCombinedSignal( new BuySignal( 4, 8 ) ); Assert.IsFalse( signal1.Equals( signal2 ) ); }
public void Equals_WithSimilarSignal_ReturnsTrue() { var signal1 = new DefensiveCombinedSignal( new BuySignal( 4, 7 ) ); var signal2 = new DefensiveCombinedSignal( new BuySignal( 4, 7 ) ); Assert.IsTrue( signal1.Equals( signal2 ) ); }
public void Ctor_WhenCalled_SignalsAreSet() { var signals = new Signal[] { new BuySignal(), new SellSignal() }; var combinedSignal = new DefensiveCombinedSignal( signals ); Assert.That( combinedSignal.Signals, Is.EquivalentTo( signals ) ); }
public void Ctor_WithCombinedSignals_SignalsAreSet() { var signals = new Signal[] { new BuySignal(), new SellSignal() }; var signalsToAdd = signals.Select( s => new DefensiveCombinedSignal( s ) ); var combinedSignal = new DefensiveCombinedSignal( signalsToAdd ); Assert.That( combinedSignal.Signals, Is.EquivalentTo( signals ) ); }
public void Weight_WhenCalled_AllInternalSignalsAreWeighted() { var signals = new Signal[] { new BuySignal( 20 ), new SellSignal( 50 ) }; var combinedSignal = new DefensiveCombinedSignal( signals ); var weightedSignal = (CombinedSignal)combinedSignal.Weight( 0.5d ); var weightedSignals = signals.Select( s => s.Weight( 0.5d ) ).ToList(); Assert.That( weightedSignal.Signals, Is.EquivalentTo( weightedSignals ) ); }
public void Strength_Buy50Neutral100_ReturnsBuy25() { var combinedSignal = new DefensiveCombinedSignal( new BuySignal( 50 ), new NeutralSignal( 100 ) ); var expectedSignal = new BuySignal( 25 ); Assert.That( combinedSignal, Is.EqualTo( expectedSignal ) ); }
public void Strength_Sell100Neutral50_ReturnsSell50() { var combinedSignal = new DefensiveCombinedSignal( new SellSignal( 100 ), new NeutralSignal( 50 ) ); var expectedSignal = new SellSignal( 25 ); Assert.That( combinedSignal, Is.EqualTo( expectedSignal ) ); }
public void Strength_SellSignalsOnly_AverageIsReturned() { var combinedSignal = new DefensiveCombinedSignal( new SellSignal( 20 ), new SellSignal( 40 ), new SellSignal( 60 ) ); Assert.That( combinedSignal.Strength.Value, Is.EqualTo( 40 ) ); }
public void Strength_NoSignalsOnly_ReturnsZero() { var combinedSignal = new DefensiveCombinedSignal( Signal.None, Signal.None ); Assert.That( combinedSignal.Strength.Value, Is.EqualTo( 0 ) ); }
public void Quality_WhenCalled_AverageIsReturned() { var combinedSignal = new DefensiveCombinedSignal( new BuySignal( 20, 20 ), new BuySignal( 40, 40 ), new BuySignal( 60, 60 ) ); Assert.That( combinedSignal.Quality.Value, Is.EqualTo( 40 ) ); }