コード例 #1
0
        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 ) );
        }
コード例 #2
0
        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 ) );
        }
コード例 #3
0
ファイル: CombinedSignalTests.cs プロジェクト: bg0jr/Maui
        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 ) );
        }
コード例 #4
0
ファイル: CombinedSignalTests.cs プロジェクト: bg0jr/Maui
        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 ) );
        }
コード例 #5
0
ファイル: CombinedSignalTests.cs プロジェクト: bg0jr/Maui
        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 ) );
        }
コード例 #6
0
ファイル: CombinedSignalTests.cs プロジェクト: bg0jr/Maui
        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 ) );
        }
コード例 #7
0
ファイル: CombinedSignalTests.cs プロジェクト: bg0jr/Maui
        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 ) );
        }
コード例 #8
0
        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 ) );
        }
コード例 #9
0
        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 ) );
        }
コード例 #10
0
        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 ) );
        }
コード例 #11
0
        public void Strength_NoSignalsOnly_ReturnsZero()
        {
            var combinedSignal = new DefensiveCombinedSignal( Signal.None, Signal.None );

            Assert.That( combinedSignal.Strength.Value, Is.EqualTo( 0 ) );
        }
コード例 #12
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 ) );
        }