示例#1
0
        public void EnableValues_StartOverConstrained_LimitsRespected([Values(5, 30)] int interval)
        {
            // setup one hour block starting at 1100 today
            // cannot do in Setup because Start and/or Duration changed in each test
            var block = (new Block(DateTimeOffset.Now.Date + new TimeSpan(11, 0, 0),
                                   new TimeSpan(1, 0, 0), 1, BlockType.NotAvailable,
                                   "test"));
            var startLimit       = block.Start - TimeSpan.FromMinutes(interval - 0.5);
            var endLimit         = block.End + TimeSpan.FromMinutes(interval - 0.5);
            var minBlockDuration = 30;
            var enableValues     = BlockTimeUtilities.GetEnableSettings(block, isStart: true,
                                                                        startLimit, endLimit, minBlockDuration);

            if (interval == 5)
            {
                Assert.IsFalse(enableValues.Plus5);
                Assert.IsFalse(enableValues.Plus30);
                Assert.IsFalse(enableValues.Minus5);
                Assert.IsFalse(enableValues.Minus30);
            }
            if (interval == 30)
            {
                Assert.IsTrue(enableValues.Plus5);
                Assert.IsFalse(enableValues.Plus30);
                Assert.IsTrue(enableValues.Minus5);
                Assert.IsFalse(enableValues.Minus30);
            }
        }
示例#2
0
        public void EnableValues_DurationTightlyConstrainedDurationAtLowLimit_LimitsRespected([Values(5, 30)] int interval)
        {
            // setup half hour block starting at 1100 today
            // cannot do in Setup because Start and/or Duration changed in each test
            var block = (new Block(0, DateTimeOffset.Now.Date + new TimeSpan(11, 0, 0),
                                   new TimeSpan(0, interval, 0), 1, BlockType.NotAvailable,
                                   "test", "", ""));
            var startLimit       = block.Start - TimeSpan.FromMinutes(interval);
            var endLimit         = block.End + TimeSpan.FromMinutes(interval);
            var minBlockDuration = interval;
            var enableValues     = BlockTimeUtilities.GetEnableSettings(block, isStart: false,
                                                                        startLimit, endLimit, minBlockDuration);

            if (interval == 5)
            {
                Assert.IsTrue(enableValues.Plus5);
                Assert.IsFalse(enableValues.Plus30);
                Assert.IsFalse(enableValues.Minus5);
                Assert.IsFalse(enableValues.Minus30);
            }
            if (interval == 30)
            {
                Assert.IsTrue(enableValues.Plus5);
                Assert.IsTrue(enableValues.Plus30);
                Assert.IsFalse(enableValues.Minus5);
                Assert.IsFalse(enableValues.Minus30);
            }
            Assert.AreEqual(1, 1);
        }
        private void SetAllowSettings()
        {
            // the number of arguments for GetEnableSettings is a bit clumsy
            //   but this critical piece of logic can be tested easily
            var enableValues = BlockTimeUtilities.GetEnableSettings(_block, IsStart,
                                                                    _startLimit, _endLimit, _calendarSettings.MinBlockDuration);

            _enablePlus30  = enableValues.Plus30;
            _enablePlus5   = enableValues.Plus5;
            _enableMinus5  = enableValues.Minus5;
            _enableMinus30 = enableValues.Minus30;
        }