public void When_high_price_is_not_sustained_trigger_stays_the_same() { var bus = new FakeBus(); var processManager = new StoplossProcessManager(bus); processManager.Handle(new PositionAcquired { Price = 1, Symbol = "ABC" }); processManager.Handle(new PriceChanged { Symbol = "ABC", Price = 1.01m }); processManager.Handle(new PriceChanged { Symbol = "ABC", Price = 0.99m }); var fisrt = (WakeMeUpIn15Seconds)bus.PublishedMessages[0]; var second = (WakeMeUpIn20Seconds)bus.PublishedMessages[1]; bus.PublishedMessages.Clear(); processManager.Handle((ShouldWeSell)fisrt.Message); processManager.Handle((ShouldWeMoveTriggerPrice)second.Message); Assert.That(bus.PublishedMessages.Count, Is.EqualTo(0)); }
public void When_low_price_is_not_sustained_below_trigger_we_do_nothing() { var bus = new FakeBus(); var processManager = new StoplossProcessManager(bus); processManager.Handle(new PositionAcquired { Price = 1, Symbol = "ABC" }); processManager.Handle(new PriceChanged { Symbol = "ABC", Price = 0.89m }); processManager.Handle(new PriceChanged { Symbol = "ABC", Price = 0.90m }); var first = (WakeMeUpIn15Seconds)bus.PublishedMessages.First(); bus.PublishedMessages.Clear(); processManager.Handle((ShouldWeSell)first.Message); Assert.That(bus.SentMessages.Count, Is.EqualTo(0)); }
public void When_position_is_acquired() { var bus = new FakeBus(); var processManager = new StoplossProcessManager(bus); processManager.Handle(new PositionAcquired {Price = 15, Symbol = "ABC"}); Assert.That(bus.PublishedMessages.Count, Is.EqualTo(0)); }