public void IntegrationCompletedCallsInnerTrigger()
        {
            var innerTrigger = this.mocks.Create <ITrigger>(MockBehavior.Strict).Object;

            Mock.Get(innerTrigger).Setup(_innerTrigger => _innerTrigger.IntegrationCompleted()).Verifiable();
            var trigger = new RollUpTrigger();

            trigger.MinimumTime  = new Timeout(10, TimeUnits.MINUTES);
            trigger.InnerTrigger = innerTrigger;
            trigger.IntegrationCompleted();
            mocks.VerifyAll();
        }
        public void IntegrationCompletedCallsInnerTrigger()
        {
            var innerTrigger = this.mocks.StrictMock <ITrigger>();

            Expect.Call(() => { innerTrigger.IntegrationCompleted(); });
            var trigger = new RollUpTrigger();

            trigger.MinimumTime  = new Timeout(10, TimeUnits.MINUTES);
            trigger.InnerTrigger = innerTrigger;
            mocks.ReplayAll();
            trigger.IntegrationCompleted();
            mocks.VerifyAll();
        }
        public void FireDoesNotFireBeforeTimePeriodHasExpired()
        {
            var innerTrigger = this.mocks.Create <ITrigger>(MockBehavior.Strict).Object;

            Mock.Get(innerTrigger).Setup(_innerTrigger => _innerTrigger.IntegrationCompleted()).Verifiable();
            var trigger = new RollUpTrigger();

            trigger.MinimumTime  = new Timeout(10, TimeUnits.MINUTES);
            trigger.InnerTrigger = innerTrigger;
            trigger.IntegrationCompleted();
            Assert.IsNull(trigger.Fire());
            mocks.VerifyAll();
        }
        public void NextBuildReturnsNextAllowedTimeForTimeRollUp()
        {
            var innerTrigger = this.mocks.Create <ITrigger>(MockBehavior.Strict).Object;

            Mock.Get(innerTrigger).Setup(_innerTrigger => _innerTrigger.IntegrationCompleted()).Verifiable();
            var trigger = new RollUpTrigger();

            trigger.InnerTrigger = innerTrigger;
            trigger.MinimumTime  = new Timeout(10, TimeUnits.MINUTES);
            trigger.IntegrationCompleted();
            Assert.Greater(trigger.NextBuild, DateTime.Now.AddMinutes(9));
            mocks.VerifyAll();
        }
        public void FireDoesNotFireBeforeTimePeriodHasExpired()
        {
            var innerTrigger = this.mocks.StrictMock <ITrigger>();

            Expect.Call(() => { innerTrigger.IntegrationCompleted(); });
            var trigger = new RollUpTrigger();

            trigger.MinimumTime  = new Timeout(10, TimeUnits.MINUTES);
            trigger.InnerTrigger = innerTrigger;
            mocks.ReplayAll();
            trigger.IntegrationCompleted();
            Assert.IsNull(trigger.Fire());
            mocks.VerifyAll();
        }
        public void NextBuildReturnsNextAllowedTimeForTimeRollUp()
        {
            var innerTrigger = this.mocks.StrictMock <ITrigger>();

            Expect.Call(() => { innerTrigger.IntegrationCompleted(); });
            var trigger = new RollUpTrigger();

            trigger.InnerTrigger = innerTrigger;
            trigger.MinimumTime  = new Timeout(10, TimeUnits.MINUTES);
            mocks.ReplayAll();
            trigger.IntegrationCompleted();
            Assert.Greater(trigger.NextBuild, DateTime.Now.AddMinutes(9));
            mocks.VerifyAll();
        }
        public void FireFiresAfterTimePeriodHasExpired()
        {
            var innerTrigger = this.mocks.StrictMock <ITrigger>();

            Expect.Call(() => { innerTrigger.IntegrationCompleted(); });
            var expected = new IntegrationRequest(BuildCondition.IfModificationExists, "Test", null);

            Expect.Call(innerTrigger.Fire()).Return(expected);
            var clock = new TestClock {
                Now = DateTime.Now
            };
            var trigger = new RollUpTrigger(clock);

            trigger.MinimumTime  = new Timeout(10, TimeUnits.MINUTES);
            trigger.InnerTrigger = innerTrigger;
            mocks.ReplayAll();
            trigger.IntegrationCompleted();
            clock.TimePasses(new TimeSpan(0, 11, 0));
            var actual = trigger.Fire();

            Assert.AreSame(expected, actual);
            mocks.VerifyAll();
        }
        public void FireFiresAfterTimePeriodHasExpired()
        {
            var innerTrigger = this.mocks.Create <ITrigger>(MockBehavior.Strict).Object;

            Mock.Get(innerTrigger).Setup(_innerTrigger => _innerTrigger.IntegrationCompleted()).Verifiable();
            var expected = new IntegrationRequest(BuildCondition.IfModificationExists, "Test", null);

            Mock.Get(innerTrigger).Setup(_innerTrigger => _innerTrigger.Fire())
            .Returns(expected).Verifiable();
            var clock = new TestClock {
                Now = DateTime.Now
            };
            var trigger = new RollUpTrigger(clock);

            trigger.MinimumTime  = new Timeout(10, TimeUnits.MINUTES);
            trigger.InnerTrigger = innerTrigger;
            trigger.IntegrationCompleted();
            clock.TimePasses(new TimeSpan(0, 11, 0));
            var actual = trigger.Fire();

            Assert.AreSame(expected, actual);
            mocks.VerifyAll();
        }