public void WhenExecuteAndThrowExceptionShouldCatchIt() { const string StopBuildUrl = "stop url"; this.jenkinsRestClientMock.Setup(x => x.StopJobAsync(StopBuildUrl)).Throws <Exception>(); var stopBuildCommand = new StopBuildCommand(this.jenkinsRestClientMock.Object, StopBuildUrl); Check.ThatAsyncCode(async() => await stopBuildCommand.ExecuteAsync()).DoesNotThrow(); }
public async void WhenExecuteThenJenkinsRestClientStopJobIsCalled() { const string StopBuildUrl = "stop url"; var stopBuildCommand = new StopBuildCommand(this.jenkinsRestClientMock.Object, StopBuildUrl); await stopBuildCommand.ExecuteAsync(); this.jenkinsRestClientMock.Verify(job => job.StopJobAsync(StopBuildUrl), Times.Once); }
public async void WhenExecuteThenCommandIsNotExecutable() { const string StopBuildUrl = "stop url"; var stopBuildCommand = new StopBuildCommand(this.jenkinsRestClientMock.Object, StopBuildUrl); Check.That(stopBuildCommand.CanExecute(null)).IsTrue(); await stopBuildCommand.ExecuteAsync(); Check.That(stopBuildCommand.CanExecute(null)).IsFalse(); }