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