示例#1
0
        public void WithMaxDate()
        {
            var stream = new DayStream(new DateTime(2010, 1, 1), DateTime.MaxValue);

            Assert.AreEqual(new DateTime(2010, 1, 1), stream.First());
            Assert.AreEqual(new DateTime(2010, 1, 1), stream.ToList().First()); //duurt lang!
        }
示例#2
0
        public void FirstOrDefault()
        {
            var dag = new DateTime(2010, 1, 1);
            var p   = new DayStream(dag, dag).FirstOrDefault(d => false);

            Assert.False(p.HasValue);
        }
示例#3
0
        public void ForYear()
        {
            var p = DayStream.ForYear(2014);

            Assert.AreEqual(365, p.Count());
            Assert.AreEqual(new DateTime(2014, 1, 1), p.First());
            Assert.AreEqual(new DateTime(2014, 12, 31), p.Last());
        }
示例#4
0
        public void LinqQeuries()
        {
            var result = new DayStream(new DateTime(2014, 8, 24), DateTime.MinValue)
                         .Where(d => d.DayOfWeek != DayOfWeek.Saturday && d.DayOfWeek != DayOfWeek.Sunday)
                         .Skip(3);

            Assert.AreEqual(new DateTime(2014, 8, 19), result.First());
        }
示例#5
0
        public void Reverse()
        {
            var p = new DayStream(new DateTime(2014, 3, 13), new DateTime(2014, 5, 14)).Reverse();

            Assert.AreEqual(63, p.Count());
            Assert.AreEqual(new DateTime(2014, 5, 14), p.First());
            Assert.AreEqual(new DateTime(2014, 3, 13), p.Last());
        }
示例#6
0
        public void EenDag()
        {
            var dag = new DateTime(2010, 1, 1);
            var p   = new DayStream(dag, dag);

            Assert.AreEqual(1, p.Count());
            Assert.AreEqual(new DateTime(2010, 1, 1), p.First());
            Assert.AreEqual(new DateTime(2010, 1, 1), p.Last());
        }
示例#7
0
        public void StreamVersusList()
        {
            var p      = new DayStream(new DateTime(2014, 1, 1), new DateTime(2014, 12, 31));
            var stream = p.MoveNextCounter();
            var list   = p.MoveNextCounter();

            stream.First();
            list.ToList().First();

            Assert.AreEqual(1, stream.MoveNextCounter);
            Assert.AreEqual(365, list.MoveNextCounter);
        }