public ErrorAuthViewModel(INavigationService navigationService) { RetryCommand = ReactiveCommand.Create(() => {}); Activator = new ViewModelActivator(); this.WhenActivated(disposables => { RetryCommand.Select(unit => typeof(LoginViewModel)) .Subscribe(navigationService.Navigate) .DisposeWith(disposables); Disposable.Create(() => { }).DisposeWith(disposables); }); }
public void should_retry_three_times() { int i = 0; var command = new RetryCommand(() => { if (i < 3) { i++; throw new NotFiniteNumberException(); } }, 4); command.Execute(1); Assert.AreEqual(3, command.Errors().Length); }
public async Task WhenProcessingRetringCommandThenRetry() { // Arrange Mock <ISpy> spy = new Mock <ISpy>(MockBehavior.Strict); spy.Setup(s => s.Spy("Trying")); RetryHandler commandCommandHandler = new RetryHandler(spy.Object); this.SetupHandler <RetryCommand>(commandCommandHandler); MessageProcessor processor = this.CreatTestableProcessor(); RetryCommand command = new RetryCommand(2); // Act var result = await processor.ProcessAsync(command); // Assert spy.Verify(s => s.Spy("Trying"), Times.Exactly(3)); }
public void WhenProcessingRetringCommandButAlwayFailsThenThrowsInvalidOperationException() { // Arrange Mock <ISpy> spy = new Mock <ISpy>(MockBehavior.Strict); spy.Setup(s => s.Spy("Trying")); RetryHandler commandCommandHandler = new RetryHandler(spy.Object); this.SetupHandler <RetryCommand>(commandCommandHandler); MessageProcessor processor = this.CreatTestableProcessor(); RetryCommand command = new RetryCommand(10); // Act Assert.ThrowsAsync <InvalidOperationException>(async() => await processor.ProcessAsync(command)); // Assert spy.Verify(s => s.Spy("Trying"), Times.Exactly(6)); }