public void WhenPositionAcquiredIsPublished_StopLossPriceIsUpdated()
        {
            var publisher = new FakePublisher();
            var sut       = new StopLossProcessManager(publisher);

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

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

            Assert.IsInstanceOf <RemoveFrom10SecondWindow>(message.Inner);
            Assert.That(message.DelayInSeconds == 10);
            var message2 = publisher.FindMessage <StopLossPriceUpdated>();

            Assert.That(message2.Price == 95);
        }
        public void GivenDecreasingPrice_ThenWeShouldNotReduceTheStopLossPrice()
        {
            var publisher = new FakePublisher();
            var sut       = new StopLossProcessManager(publisher);

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

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

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

            Assert.IsNull(message);
        }
        public void GivenPriceUodated_WhenRemovingIn10Seconds_ThenStopLossPriceUpdated()
        {
            var publisher = new FakePublisher();
            var sut       = new StopLossProcessManager(publisher);

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

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

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

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

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