コード例 #1
0
        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();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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();
        }