Пример #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));
 }
Пример #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);
        }
Пример #3
0
 public void Cancel_BeforeSimulation_DoesNothing()
 {
     var sut = new Simulator();
     Assert.DoesNotThrow(() => sut.Cancel(false));
 }
Пример #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);
        }