public void When_Invoke_A_Task_Of_100_ms_Then_Should_Returns_Before_Cancellation(INavigator navigator) { // Arrange using var globalCTS = new CancellationTokenSource(TimeSpan.FromMilliseconds(200)); // Act navigator.Do(navigator.Map.Nodes.First(), (cancellationToken) => Thread.Sleep(100), globalCTS.Token); // Assert globalCTS.IsCancellationRequested.Should().BeFalse(); }
public void When_Invoke_A_Task_Then_Should_Returns_Before_Cancellation(INavigator navigator) { // Arrange using var globalCTS = new CancellationTokenSource(TimeSpan.FromMilliseconds(200)); Mock.Get(navigator.Map.Nodes.Last()).Setup(x => x.PublishStatus().Exist.Value).Returns(true); // Act navigator.Do(navigator.Map.Nodes.First(), (cancellationToken) => { }, globalCTS.Token); // Assert globalCTS.IsCancellationRequested.Should().BeFalse(); }
public void When_Invoke_A_Task_Of_400_ms_Then_Should_Returns_Throws_OperationCanceledException(INavigator navigator) { // Arrange using var globalCTS = new CancellationTokenSource(TimeSpan.FromMilliseconds(200)); // Act Action act = () => navigator.Do(navigator.Map.Nodes.First(), (cancellationToken) => Thread.Sleep(400), globalCTS.Token); // Assert act.Should().Throw <OperationCanceledException>(); globalCTS.IsCancellationRequested.Should().BeTrue(); }
public void When_Invoke_A_Task_Then_Should_Returns_Throws_OperationCanceledException(INavigator navigator) { // Arrange using var globalCTS = new CancellationTokenSource(TimeSpan.FromMilliseconds(200)); Mock.Get(navigator.Map.Nodes.First()).Setup(x => x.PublishStatus().Exist.Value).Returns(false); // Act Action act = () => navigator.Do(navigator.Map.Nodes.First(), (cancellationToken) => { }, globalCTS.Token); // Assert act.Should().Throw <OperationCanceledException>(); globalCTS.IsCancellationRequested.Should().BeTrue(); }