public void Instantiate_DateFrom1stJanuaryTo31December2012InFrenchWithLongFormat_ListWithAllDays()
        {
            var dateRange = new DateRange()
            {
                Start = new DateTime(2012, 1, 1),
                End = new DateTime(2012, 12, 31),
                Culture = new CultureInfo("fr"),
                Format = "MMMM dd, yyyy"
            };

            var factory = new RangeMembersFactory();
            var values = factory.Instantiate(dateRange).ToList();

            Assert.That(values.Count, Is.EqualTo(366));
            Assert.That(values[0], Is.EqualTo("janvier 01, 2012"));
            Assert.That(values[365], Is.EqualTo("décembre 31, 2012"));
        }
        public void Instantiate_IntegerFrom1To52WithPrefixPattern_ListFromWeek1ToWeek52()
        {
            var integerRange = new IntegerPatternRange()
            {
                Start = 1,
                End = 52,
                Step = 1,
                Pattern="Week ",
                Position= PositionValue.Prefix
            };

            var factory = new RangeMembersFactory();
            var values = factory.Instantiate(integerRange).ToList();

            Assert.That(values[0], Is.EqualTo("Week 1"));
            Assert.That(values[51], Is.EqualTo("Week 52"));
            Assert.That(values.Count, Is.EqualTo(52));
        }
        public void Instantiate_DateFrom1stJanuaryTo31December2013_ListWithAllDays(string cultureTag)
        {
            var culture = new CultureInfo(cultureTag);
            var dateRange = new DateRange()
            {
                Start = new DateTime(2013, 1, 1),
                End = new DateTime(2013, 12, 31),
                Culture = culture
            };

            var factory = new RangeMembersFactory();
            var values = factory.Instantiate(dateRange).ToList();

            Assert.That(values.Count, Is.EqualTo(365));

            var januaryFirst = new DateTime(2013, 1, 1).ToString(culture.DateTimeFormat.ShortDatePattern);
            Assert.That(values[0], Is.EqualTo(januaryFirst));
            var decemberLast = new DateTime(2013, 12, 31).ToString(culture.DateTimeFormat.ShortDatePattern);
            Assert.That(values[364], Is.EqualTo(decemberLast));
        }
Esempio n. 4
0
 public IEnumerable<string> GetItems()
 {
     var factory = new RangeMembersFactory();
     return factory.Instantiate(this);
 }
        public void Instantiate_IntegerFrom3To10Step3_ListFrom3To9()
        {
            var integerRange = new IntegerRange()
            {
                Start = 3,
                End = 10,
                Step = 3
            };

            var factory = new RangeMembersFactory();
            var values = factory.Instantiate(integerRange).ToList();

            Assert.That(values[0], Is.EqualTo("3"));
            Assert.That(values[2], Is.EqualTo("9"));
            Assert.That(values.Count, Is.EqualTo(3));
        }