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 void StopBuildCommandEqualsOtherStopBuildCommandWhenShareSameBuildUrl()
        {
            const string StopBuildUrl      = "stop url";
            var          stopBuildCommand1 = new StopBuildCommand(this.jenkinsRestClientMock.Object, StopBuildUrl);
            var          stopBuildCommand2 = new StopBuildCommand(this.jenkinsRestClientMock.Object, StopBuildUrl);
            var          stopBuildCommand3 = new StopBuildCommand(this.jenkinsRestClientMock.Object, "fake url");

            Check.That(stopBuildCommand1).Equals(stopBuildCommand2);
            Check.That(stopBuildCommand1).IsNotEqualTo(stopBuildCommand3);
        }
        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();
        }
Example #5
0
      /// <summary>Initializes a new instance of the <see cref="BuildAdapter"/> class.</summary>
      /// <param name="mainWindowViewModel">The main window view model.</param>
      /// <param name="buildInformation">The build information.</param>
      /// <param name="isPinedView">if set to <c>true</c> [is pined view].</param>
      internal BuildAdapter(MainWindowViewModel mainWindowViewModel, BuildInformation buildInformation, bool isPinedView)
      {
         BuildInformation = buildInformation;
         this.mainWindowViewModel = mainWindowViewModel;
         this.isPinedView = isPinedView;
         buildExplorer = BuildExplorerFactory.CreateBuildExplorer(buildInformation.TfsVersion);

         OpenBrowserCommand = new RelayCommand(OpenBrowser);
         StopBuildCommand = new StopBuildCommand(this, buildInformation);
         RequestBuildCommand = new RequestBuildCommand(this, buildInformation);
         RunningBuildErrorDetails = new ObservableCollection<string>();
         Tags = new ObservableCollection<string>(buildInformation.Tags ?? new string[0]);

         if (!isPinedView)
         {
            PinBuildCommand = new PinBuildCommand(mainWindowViewModel, buildInformation);
         }

         var buildDefinition = MonitorSettingsContainer.BuildServers.SelectMany(x => x.BuildDefinitions).FirstOrDefault(x => x.Id == buildInformation.BuildDefinitionId);
         if (PinBuildCommand != null && buildDefinition != null && buildDefinition.IsPined)
         {
            PinBuildCommand.Execute(null);
         }
      }
        public void WhenStopBuildUrlIsEmptyThenCommandIsNotExecutable()
        {
            var stopBuildCommand = new StopBuildCommand(this.jenkinsRestClientMock.Object, string.Empty);

            Check.That(stopBuildCommand.CanExecute(null)).IsFalse();
        }