Пример #1
0
        public void ParseWithZeroPeriodAndDiscard()
        {
            var rule = SettleRule.Parse("day-P0D+PT0H");

            Assert.Equal("day", rule.ToString());
            Assert.Equal(new SettleRuleBuilder().StartOf(SettleUnit.Day).Rule, rule);
        }
Пример #2
0
        public void SettleExpectedReadingDate(int expectedMonth, int expectedDay, int day)
        {
            var origin  = new LocalDateTime(2014, 11, day, 21, 0).InZoneLeniently(Timezone);
            var settled = SettleRule.Parse("-P15D_month+P1M-P1D").Settle(origin);

            Assert.Equal(new LocalDateTime(2014, expectedMonth, expectedDay, 0, 0).InZoneLeniently(Timezone), settled);
        }
Пример #3
0
        public void SettleShouldApplyParts()
        {
            var origin  = new LocalDateTime(2014, 11, 12, 21, 0).InZoneLeniently(Timezone);
            var settled = SettleRule.Parse("day+P2D-PT1H").Settle(origin);

            Assert.Equal(new LocalDateTime(2014, 11, 13, 23, 0).InZoneLeniently(Timezone), settled);
        }
Пример #4
0
        public void SettleNoParts()
        {
            var origin  = new LocalDateTime(2014, 11, 12, 21, 0).InZoneLeniently(Timezone);
            var settled = SettleRule.Parse(string.Empty).Settle(origin);

            Assert.Equal(origin, settled);
        }
Пример #5
0
        public void EnumeratingRuleShouldEmitParts()
        {
            // Given
            var rule = SettleRule.Parse("day+PT2H~january-P1Y");

            // When
            var parts = rule.ToList();

            // Then
            Assert.Equal(4, parts.Count);
            Assert.Equal(new StartOfPart(SettleUnit.Day), Assert.IsType <StartOfPart>(parts[0]));
            Assert.Equal(new OffsetPart(1, Period.FromHours(2)), Assert.IsType <OffsetPart>(parts[1]));
            Assert.Equal(new NearestPart(SettleUnit.January), Assert.IsType <NearestPart>(parts[2]));
            Assert.Equal(new OffsetPart(-1, Period.FromYears(1)), Assert.IsType <OffsetPart>(parts[3]));
        }
Пример #6
0
        public void ParseStartOfWithMultiplePeriods()
        {
            var rule = SettleRule.Parse("day+P1D-PT2H");

            Assert.Equal(new SettleRuleBuilder().StartOf(SettleUnit.Day).Plus(Period.FromDays(1)).Minus(Period.FromHours(2)).Rule, rule);
        }
Пример #7
0
        public void ParseStartOfWithPeriod()
        {
            var rule = SettleRule.Parse("day+P1D");

            Assert.Equal(new SettleRuleBuilder().StartOf(SettleUnit.Day).Plus(Period.FromDays(1)).Rule, rule);
        }
Пример #8
0
        public void ParsePeriodWithMinus()
        {
            var rule = SettleRule.Parse("-P1D");

            Assert.Equal(new SettleRuleBuilder().Minus(Period.FromDays(1)).Rule, rule);
        }
Пример #9
0
        public void ParseEndOf()
        {
            var rule = SettleRule.Parse("^day");

            Assert.Equal(new SettleRuleBuilder().EndOf(SettleUnit.Day).Rule, rule);
        }
Пример #10
0
        public void ParseNearest()
        {
            var rule = SettleRule.Parse("~day");

            Assert.Equal(new SettleRuleBuilder().Nearest(SettleUnit.Day).Rule, rule);
        }
Пример #11
0
        public void ParseStartOfWithPrefix()
        {
            var rule = SettleRule.Parse("_day");

            Assert.Equal(new SettleRuleBuilder().StartOf(SettleUnit.Day).Rule, rule);
        }
Пример #12
0
        public void ParseEmpty()
        {
            var rule = SettleRule.Parse(string.Empty);

            Assert.Equal(new SettleRule(), rule);
        }