示例#1
0
            private static void AssertRules(LinuxAdjustmentMultiRuleData data, IReadOnlyList <EnhancedAdjustmentRule> sourceRules)
            {
                var expectedIntervals  = data.ExpectedIntervals;
                var bclAdjustmentRules = sourceRules
                                         .Select(rule => BclAdjustmentRule.ConvertUnixRuleToBclAdjustmentRule(rule.Rule, "Standard", "Daylight", rule.ZoneStandardOffset, rule.RuleStandardOffset, rule.ForceDaylight))
                                         .ToArray();

                BclDateTimeZone.FixUnixTransitions(bclAdjustmentRules);

                // Convert our rules to a full map, as there's coalescing code in there that we want to take advantage of.
                var map = BclDateTimeZone.BuildMap(bclAdjustmentRules, Offset.FromTimeSpan(data.ZoneStandardOffset), "Standard");;

                // Get all of the zone intervals in the expected interval
                var actualIntervals = new List <ZoneInterval>();

                actualIntervals.Add(map.GetZoneInterval(expectedIntervals[0].RawStart));
                while (actualIntervals.Last().RawEnd < expectedIntervals.Last().RawEnd)
                {
                    actualIntervals.Add(map.GetZoneInterval(actualIntervals.Last().RawEnd));
                }
                Assert.AreEqual(expectedIntervals, actualIntervals);
            }