public void IntegrationStartAllowedAtTopOfQueue()
        {
            var extension      = new IntegrationRequestThrottleExtension();
            var serverMock     = this.mocks.StrictMock <ICruiseServer>();
            var config         = new ExtensionConfiguration();
            var completeRaiser = Expect
                                 .Call(() => serverMock.IntegrationCompleted += null)
                                 .IgnoreArguments()
                                 .GetEventRaiser();
            var startRaiser = Expect
                              .Call(() => serverMock.IntegrationStarted += null)
                              .IgnoreArguments()
                              .GetEventRaiser();
            var eventArgs = new IntegrationStartedEventArgs(null, "TestProject");

            this.mocks.ReplayAll();
            extension.Initialise(serverMock, config);
            extension.NumberOfRequestsAllowed = 1;
            startRaiser.Raise(serverMock, new IntegrationStartedEventArgs(null, "First"));
            startRaiser.Raise(serverMock, eventArgs);
            startRaiser.Raise(serverMock, new IntegrationStartedEventArgs(null, "Third"));
            completeRaiser.Raise(
                serverMock,
                new IntegrationCompletedEventArgs(null, "First", IntegrationStatus.Success));
            startRaiser.Raise(serverMock, eventArgs);

            this.mocks.VerifyAll();
            Assert.AreEqual(IntegrationStartedEventArgs.EventResult.Continue, eventArgs.Result);
        }
Пример #2
0
        public void StartAndAbortDoesNothing()
        {
            var extension  = new IntegrationRequestThrottleExtension();
            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();
        }
Пример #3
0
        public void IntegrationStartIsAllowedWhenWithinLimit()
        {
            var extension  = new IntegrationRequestThrottleExtension();
            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 eventArgs = new IntegrationStartedEventArgs(null, "TestProject");

            extension.Initialise(serverMock, config);
            Mock.Get(serverMock).Raise(_serverMock => _serverMock.IntegrationStarted += null, eventArgs);

            mocks.VerifyAll();
            Assert.AreEqual(IntegrationStartedEventArgs.EventResult.Continue, eventArgs.Result);
        }
        public void StartAndAbortDoesNothing()
        {
            var extension  = new IntegrationRequestThrottleExtension();
            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();
        }
Пример #5
0
        public void InitialiseLoadsNumberOfRequestsAllowed()
        {
            var extension  = new IntegrationRequestThrottleExtension();
            var serverMock = this.mocks.Create <ICruiseServer>(MockBehavior.Strict).Object;
            var config     = new ExtensionConfiguration();

            config.Items = new[]
            {
                GenerateElement("limit", "10")
            };
            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);

            mocks.VerifyAll();
            Assert.AreEqual(10, extension.NumberOfRequestsAllowed);
        }
        public void InitialiseLoadsNumberOfRequestsAllowed()
        {
            var extension  = new IntegrationRequestThrottleExtension();
            var serverMock = this.mocks.StrictMock <ICruiseServer>();
            var config     = new ExtensionConfiguration();

            config.Items = new[]
            {
                GenerateElement("limit", "10")
            };
            Expect.Call(() => serverMock.IntegrationCompleted += null).IgnoreArguments();
            Expect.Call(() => serverMock.IntegrationStarted   += null).IgnoreArguments();

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

            this.mocks.VerifyAll();
            Assert.AreEqual(10, extension.NumberOfRequestsAllowed);
        }
        public void IntegrationStartIsAllowedWhenWithinLimit()
        {
            var extension  = new IntegrationRequestThrottleExtension();
            var serverMock = this.mocks.StrictMock <ICruiseServer>();
            var config     = new ExtensionConfiguration();

            Expect.Call(() => serverMock.IntegrationCompleted += null).IgnoreArguments();
            var startRaiser = Expect
                              .Call(() => serverMock.IntegrationStarted += null)
                              .IgnoreArguments()
                              .GetEventRaiser();
            var eventArgs = new IntegrationStartedEventArgs(null, "TestProject");

            this.mocks.ReplayAll();
            extension.Initialise(serverMock, config);
            startRaiser.Raise(serverMock, eventArgs);

            this.mocks.VerifyAll();
            Assert.AreEqual(IntegrationStartedEventArgs.EventResult.Continue, eventArgs.Result);
        }