コード例 #1
0
        public void GivenDecreasingPrice_ThenWeTriggerHitStopLost_X()
        {
            var publisher = new FakeMessagePublisher();
            var sut       = new StopLossProcessManager(publisher);

            sut.Handle(new PositionAcquired {
                Price = 100
            });
            sut.Handle(new PriceUpdated {
                Price = 89
            });
            sut.Handle(new PriceUpdated {
                Price = 89
            });
            publisher.Clear();

            sut.Handle(new PriceExpiredFromStopLossHitWindow {
                Price = 100
            });
            sut.Handle(new PriceExpiredFromStopLossHitWindow {
                Price = 89
            });

            var message = publisher.FindMessage <StopLossHit>();

            Assert.IsInstanceOf <StopLossHit>(message);
        }
コード例 #2
0
        public void SetUp()
        {
            _publisher = new FakeMessagePublisher();
            _sut       = new StopLossProcessManager(_publisher);

            When();
        }
コード例 #3
0
        public void GivePositionAcquired_ThenRemoveFrom13SencondWindowIsPublished()
        {
            var publisher = new FakeMessagePublisher();
            var sut       = new StopLossProcessManager(publisher);

            sut.Handle(new PositionAcquired {
                Price = 100
            });

            var message = publisher.FindSendMeInMessage <PriceExpiredFromStopLossHitWindow>();

            //Assert.That(message.DelayInSeconds == 13);
            Assert.That(message.Price == 100);
        }
コード例 #4
0
        public void WhenPositionAcquiredIsPublished_StopLossPriceIsUpdated()
        {
            var publisher = new FakeMessagePublisher();
            var sut       = new StopLossProcessManager(publisher);

            sut.Handle(new PositionAcquired {
                Price = 105
            });

            var message = publisher.FindSendMeInMessage <PriceExpiredFromStopLossWindow>();

            Assert.That(message != null);
            //Assert.That(message.DelayInSeconds == 10);
            var message2 = publisher.FindMessage <StopLossPriceUpdated>();

            Assert.That(message2.Price == 95);
        }
コード例 #5
0
        public void GivenPriceUpdated_ThenRemoveIn10SecondsIsPublished()
        {
            var publisher = new FakeMessagePublisher();
            var sut       = new StopLossProcessManager(publisher);

            sut.Handle(new PositionAcquired {
                Price = 100
            });
            publisher.Clear();

            var priceUpdated = new PriceUpdated {
                Price = 95
            };

            sut.Handle(priceUpdated);


            var message = publisher.FindSendMeInMessage <PriceExpiredFromStopLossWindow>();

            Assert.That(message != null);
            //Assert.That(message.DelayInSeconds == 10);
        }
コード例 #6
0
        public void GivenDecreasingPrice_ThenWeShouldNotReduceTheStopLossPrice()
        {
            var publisher = new FakeMessagePublisher();
            var sut       = new StopLossProcessManager(publisher);

            sut.Handle(new PositionAcquired {
                Price = 105
            });
            sut.Handle(new PriceUpdated {
                Price = 95
            });
            publisher.Clear();

            sut.Handle(new PriceExpiredFromStopLossWindow()
            {
                Price = 105
            });

            var message = publisher.FindMessage <StopLossPriceUpdated>();

            Assert.That(message.Price == 95);
            //Assert.IsNull(message);
        }
コード例 #7
0
        public void GivenPriceUpdated_WhenRemovingIn10Seconds_ThenStopLossPriceUpdated()
        {
            var publisher = new FakeMessagePublisher();
            var sut       = new StopLossProcessManager(publisher);

            sut.Handle(new PositionAcquired {
                Price = 100
            });
            var priceUpdated = new PriceUpdated {
                Price = 101
            };

            sut.Handle(priceUpdated);
            publisher.Clear();

            sut.Handle(new PriceExpiredFromStopLossWindow()
            {
                Price = 100
            });

            StopLossPriceUpdated actual = publisher.FindMessage <StopLossPriceUpdated>();

            Assert.AreEqual(91, actual.Price);
        }