public void SuccessfulIntegrationUpdatesSuccessCounter()
        {
            var counters = this.InitialiseCounters();

            Mock.Get(counters).Setup(_counters => _counters.IncrementCounter(
                                         IntegrationPerformanceCountersExtension.CategoryName,
                                         IntegrationPerformanceCountersExtension.NumberCompletedCounter)).Verifiable();
            Mock.Get(counters).Setup(_counters => _counters.IncrementCounter(
                                         IntegrationPerformanceCountersExtension.CategoryName,
                                         IntegrationPerformanceCountersExtension.NumberTotalCounter)).Verifiable();
            Mock.Get(counters).Setup(_counters => _counters.IncrementCounter(
                                         IntegrationPerformanceCountersExtension.CategoryName,
                                         IntegrationPerformanceCountersExtension.AverageTimeCounter,
                                         It.IsAny <long>())).Verifiable();
            var extension = new IntegrationPerformanceCountersExtension
            {
                PerformanceCounters = counters
            };
            var serverMock = this.mocks.Create <ICruiseServer>(MockBehavior.Strict).Object;
            var config     = new ExtensionConfiguration();

            Mock.Get(serverMock).SetupAdd(_serverMock => _serverMock.IntegrationCompleted += It.IsAny <EventHandler <IntegrationCompletedEventArgs> >()).Verifiable();
            Mock.Get(serverMock).SetupAdd(_serverMock => _serverMock.IntegrationStarted   += It.IsAny <EventHandler <IntegrationStartedEventArgs> >()).Verifiable();
            var request = new IntegrationRequest(BuildCondition.ForceBuild, "Testing", null);

            extension.Initialise(serverMock, config);
            Mock.Get(serverMock).Raise(_serverMock => _serverMock.IntegrationStarted   += null, new IntegrationStartedEventArgs(request, "TestProject"));
            Mock.Get(serverMock).Raise(_serverMock => _serverMock.IntegrationCompleted += null, new IntegrationCompletedEventArgs(request, "TestProject", IntegrationStatus.Success));

            mocks.VerifyAll();
        }
Beispiel #2
0
        public void StartAndAbortDoesNothing()
        {
            var counters  = this.InitialiseCounters();
            var extension = new IntegrationPerformanceCountersExtension
            {
                PerformanceCounters = counters
            };
            var serverMock = this.mocks.StrictMock <ICruiseServer>();
            var config     = new ExtensionConfiguration();

            Expect.Call(() => serverMock.IntegrationCompleted += null).IgnoreArguments();
            Expect.Call(() => serverMock.IntegrationStarted   += null).IgnoreArguments();

            this.mocks.ReplayAll();
            extension.Initialise(serverMock, config);
            extension.Start();
            extension.Abort();

            this.mocks.VerifyAll();
        }
        public void StartAndAbortDoesNothing()
        {
            var counters  = this.InitialiseCounters();
            var extension = new IntegrationPerformanceCountersExtension
            {
                PerformanceCounters = counters
            };
            var serverMock = this.mocks.Create <ICruiseServer>(MockBehavior.Strict).Object;
            var config     = new ExtensionConfiguration();

            Mock.Get(serverMock)
            .SetupAdd(_serverMock => _serverMock.IntegrationCompleted += It.IsAny <EventHandler <IntegrationCompletedEventArgs> >()).Verifiable();
            Mock.Get(serverMock)
            .SetupAdd(_serverMock => _serverMock.IntegrationStarted += It.IsAny <EventHandler <IntegrationStartedEventArgs> >()).Verifiable();

            extension.Initialise(serverMock, config);
            extension.Start();
            extension.Abort();

            mocks.VerifyAll();
        }
Beispiel #4
0
        public void SuccessfulIntegrationUpdatesSuccessCounter()
        {
            var counters = this.InitialiseCounters();

            Expect.Call(() => counters.IncrementCounter(
                            IntegrationPerformanceCountersExtension.CategoryName,
                            IntegrationPerformanceCountersExtension.NumberCompletedCounter));
            Expect.Call(() => counters.IncrementCounter(
                            IntegrationPerformanceCountersExtension.CategoryName,
                            IntegrationPerformanceCountersExtension.NumberTotalCounter));
            Expect.Call(() => counters.IncrementCounter(
                            Arg <string> .Is.Equal(IntegrationPerformanceCountersExtension.CategoryName),
                            Arg <string> .Is.Equal(IntegrationPerformanceCountersExtension.AverageTimeCounter),
                            Arg <long> .Is.Anything));
            var extension = new IntegrationPerformanceCountersExtension
            {
                PerformanceCounters = counters
            };
            var serverMock      = this.mocks.StrictMock <ICruiseServer>();
            var config          = new ExtensionConfiguration();
            var completedRaiser = Expect.Call(() => serverMock
                                              .IntegrationCompleted += null)
                                  .IgnoreArguments()
                                  .GetEventRaiser();
            var startRaiser = Expect
                              .Call(() => serverMock.IntegrationStarted += null)
                              .IgnoreArguments()
                              .GetEventRaiser();
            var request = new IntegrationRequest(BuildCondition.ForceBuild, "Testing", null);

            this.mocks.ReplayAll();
            extension.Initialise(serverMock, config);
            startRaiser.Raise(serverMock, new IntegrationStartedEventArgs(request, "TestProject"));
            completedRaiser.Raise(serverMock, new IntegrationCompletedEventArgs(request, "TestProject", IntegrationStatus.Success));

            this.mocks.VerifyAll();
        }