Exemplo n.º 1
0
 public void Cancel_AfterSimulation_DoesNothing()
 {
     var sut = new Simulator();
     sut.RunAsync(CreateSyncTickersStub(), new EmptyStrategy(), new SimulationSettings());
     sut.Wait();
     Assert.DoesNotThrow(() => sut.Cancel(false));
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public void Cancel_BeforeSimulation_DoesNothing()
 {
     var sut = new Simulator();
     Assert.DoesNotThrow(() => sut.Cancel(false));
 }
Exemplo n.º 4
0
        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);
        }