public void WhenExecuteAndThrowExceptionShouldCatchIt() { const string BuildUrl = "Build Url"; this.jenkinsRestClientMock.Setup(x => x.RunJobAsync(BuildUrl)).Throws <Exception>(); var stopBuildCommand = new RunBuildCommand(this.jenkinsRestClientMock.Object, BuildUrl); Check.ThatAsyncCode(async() => await stopBuildCommand.ExecuteAsync()).DoesNotThrow(); }
public void WhenExecuteThenJenkinsRestClientRunJobIsCalled() { const string BuildUrl = "Build Url"; var runBuildCommand = new RunBuildCommand(this.jenkinsRestClientMock.Object, BuildUrl); runBuildCommand.ExecuteAsync().Wait(); this.jenkinsRestClientMock.Verify(job => job.RunJobAsync(BuildUrl), Times.Once); }
public async void WhenExecuteThenCommandIsNotExecutable() { const string BuildUrl = "Build Url"; var runBuildCommand = new RunBuildCommand(this.jenkinsRestClientMock.Object, BuildUrl); Check.That(runBuildCommand.CanExecute(null)).IsTrue(); await runBuildCommand.ExecuteAsync(); Check.That(runBuildCommand.CanExecute(null)).IsFalse(); }