public void Cancel_AfterSimulation_DoesNothing() { var sut = new Simulator(); sut.RunAsync(CreateSyncTickersStub(), new EmptyStrategy(), new SimulationSettings()); sut.Wait(); Assert.DoesNotThrow(() => sut.Cancel(false)); }
public void EndResult_AfterCancelation_Cancelation() { bool executionHolder = true; var sut = new Simulator(); var strategyStub = new Mock<StrategyBase>(); strategyStub.Setup(x => x.Initialize()).Returns(true); strategyStub.Setup(x => x.Run()).Callback(() => { while (executionHolder);}).Returns(true); var settings = new SimulationSettingsImmutableDecorator(new SimulationSettings()); sut.RunAsync(CreateSyncTickersStub(), strategyStub.Object, settings); sut.Cancel(); Assert.Equal<SimulationEndReason>(SimulationEndReason.Cancellation, sut.EndInfo.EndReason); }
public void Cancel_BeforeSimulation_DoesNothing() { var sut = new Simulator(); Assert.DoesNotThrow(() => sut.Cancel(false)); }
public void InfinitiveSimulation_CanBeCanceled() { bool executionHolder = true; var sut = new Simulator(); var strategyStub = new Mock<StrategyBase>(); strategyStub.Setup(x => x.Initialize()).Returns(true); strategyStub.Setup(x => x.Run()).Callback(() => { while (executionHolder);}).Returns(true); var settings = new SimulationSettingsImmutableDecorator(new SimulationSettings()); sut.RunAsync(CreateSyncTickersStub(), strategyStub.Object, settings); sut.Cancel(); Assert.False(sut.IsBusy); }