public void GetPreviousDayCountLessThan1Exception()
        {
            int            dayCount       = 0;
            DateProjection dateProjection = DateProjection(dayCount);

            Assert.That(() => dateProjection.GetPrevious(new DateTime(2017, 2, 28)), Throws.TypeOf <InvalidOperationException>());
        }
        public void GetNext()
        {
            int            dayCount       = 2;
            DateProjection dateProjection = DateProjection(dayCount);

            Assert.That(dateProjection.GetNext(new DateTime(2017, 2, 28)), Is.EqualTo(new DateTime(2017, 3, 2)));
        }
        public void GetPrevious()
        {
            int            dayCount       = 2;
            DateProjection dateProjection = DateProjection(dayCount);

            Assert.That(dateProjection.GetPrevious(new DateTime(2017, 2, 28)), Is.EqualTo(new DateTime(2017, 2, 26)));
        }
        public void GetPreviousMonthCountLessThan1Exception()
        {
            int            monthCount     = 0;
            int            dayOfMonth     = 31;
            DateProjection dateProjection = DateProjection(monthCount, dayOfMonth);

            Assert.That(() => dateProjection.GetPrevious(new DateTime(2017, 2, 28)), Throws.TypeOf <InvalidOperationException>());
        }
        public void GetPrevious()
        {
            int            monthCount     = 3;
            int            dayOfMonth     = 31;
            DateProjection dateProjection = DateProjection(monthCount, dayOfMonth);

            Assert.That(dateProjection.GetPrevious(new DateTime(2017, 2, 28)), Is.EqualTo(new DateTime(2016, 11, 30)));
        }
        public void GetNext()
        {
            int            monthCount     = 2;
            int            dayOfMonth     = 31;
            DateProjection dateProjection = DateProjection(monthCount, dayOfMonth);

            Assert.That(dateProjection.GetNext(new DateTime(2017, 2, 28)), Is.EqualTo(new DateTime(2017, 4, 30)));
        }
Exemplo n.º 7
0
        public void LeadTimePropertyIsReadWrite()
        {
            var            activity   = new Activity();
            DateProjection projection = new DateProjection(new WeeklyProjection());

            activity.LeadTime = projection;
            Assert.That(activity.LeadTime, Is.SameAs(projection));
        }
        public void GetPreviousDayOfWeekIsNoneException()
        {
            int weekCount = 2;
            EDaysOfWeekFlags daysOfWeek     = EDaysOfWeekFlags.None;
            DateProjection   dateProjection = DateProjection(weekCount, daysOfWeek);

            Assert.That(() => dateProjection.GetPrevious(new DateTime(2017, 2, 28)), Throws.TypeOf <InvalidOperationException>());
        }
        public void GetNextWeekCountLessThan1Exception()
        {
            int weekCount = 0;
            EDaysOfWeekFlags daysOfWeek     = EDaysOfWeekFlags.Monday;
            DateProjection   dateProjection = DateProjection(weekCount, daysOfWeek);

            Assert.That(() => dateProjection.GetNext(new DateTime(2017, 2, 28)), Throws.TypeOf <InvalidOperationException>());
        }
        public void GetPrevious()
        {
            int weekCount = 2;
            EDaysOfWeekFlags daysOfWeek     = EDaysOfWeekFlags.Monday;
            DateProjection   dateProjection = DateProjection(weekCount, daysOfWeek);

            Assert.That(dateProjection.GetPrevious(new DateTime(2017, 2, 28)), Is.EqualTo(new DateTime(2017, 2, 20)));
        }
Exemplo n.º 11
0
        public void GetPreviousDayOfMonthLessThan1Exception()
        {
            EMonth         month          = EMonth.February;
            int            dayOfMonth     = 0;
            DateProjection dateProjection = DateProjection(month, dayOfMonth);

            Assert.That(() => dateProjection.GetPrevious(new DateTime(2017, 2, 28)), Throws.TypeOf <InvalidOperationException>());
        }
Exemplo n.º 12
0
        public void GetPrevious()
        {
            EMonth         month          = EMonth.February;
            int            dayOfMonth     = 31;
            DateProjection dateProjection = DateProjection(month, dayOfMonth);

            Assert.That(dateProjection.GetPrevious(new DateTime(2017, 2, 28)), Is.EqualTo(new DateTime(2016, 2, 29)));
        }
        public void GetPrevious()
        {
            int            monthCount     = 3;
            EWeeksInMonth  weeksInMonth   = EWeeksInMonth.Second;
            EDaysOfWeekExt daysOfWeek     = EDaysOfWeekExt.Monday;
            DateProjection dateProjection = DateProjection(monthCount, weeksInMonth, daysOfWeek);

            Assert.That(dateProjection.GetPrevious(new DateTime(2017, 2, 28)), Is.EqualTo(new DateTime(2016, 12, 12)));
        }
        public void GetPreviousMonthCountLessThan1Exception()
        {
            int            monthCount     = 0;
            EWeeksInMonth  weeksInMonth   = EWeeksInMonth.Second;
            EDaysOfWeekExt daysOfWeek     = EDaysOfWeekExt.Monday;
            DateProjection dateProjection = DateProjection(monthCount, weeksInMonth, daysOfWeek);

            Assert.That(() => dateProjection.GetPrevious(new DateTime(2017, 2, 28)), Throws.TypeOf <InvalidOperationException>());
        }
        public void GetPrevious()
        {
            EMonth         month          = EMonth.March;
            EWeeksInMonth  weeksInMonth   = EWeeksInMonth.Second;
            EDaysOfWeekExt daysOfWeek     = EDaysOfWeekExt.Monday;
            DateProjection dateProjection = DateProjection(month, weeksInMonth, daysOfWeek);

            Assert.That(dateProjection.GetPrevious(new DateTime(2017, 2, 28)), Is.EqualTo(new DateTime(2016, 3, 14)));
        }
        private static DateProjection DateProjection(int dayCount)
        {
            var projection = new DailyProjection()
            {
                DayCount = dayCount,
            };
            var dateProjection = new DateProjection(projection);

            return(dateProjection);
        }
        private static DateProjection DateProjection(int weekCount, EDaysOfWeekFlags daysOfWeek)
        {
            var projection = new WeeklyProjection()
            {
                WeekCount  = weekCount,
                DaysOfWeek = daysOfWeek,
            };
            var dateProjection = new DateProjection(projection);

            return(dateProjection);
        }
        private static DateProjection DateProjection(int monthCount, int dayOfMonth)
        {
            var projection = new MonthlyProjection()
            {
                MonthCount = monthCount,
                DayOfMonth = dayOfMonth,
            };
            var dateProjection = new DateProjection(projection);

            return(dateProjection);
        }
Exemplo n.º 19
0
        private static DateProjection DateProjection(EMonth month, int dayOfMonth)
        {
            var projection = new YearlyProjection()
            {
                Month      = month,
                DayOfMonth = dayOfMonth,
            };
            var dateProjection = new DateProjection(projection);

            return(dateProjection);
        }
        private static DateProjection DateProjection(EMonth month, EWeeksInMonth weeksInMonth, EDaysOfWeekExt daysOfWeek)
        {
            var projection = new YearlyRelativeProjection()
            {
                Month         = month,
                WeeksInMonth  = weeksInMonth,
                DaysOfWeekExt = daysOfWeek,
            };
            var dateProjection = new DateProjection(projection);

            return(dateProjection);
        }
Exemplo n.º 21
0
        public void DtoAndDomainRoundTrip()
        {
            Fixture fixture = TestHelper.CreateSerializationAutoFixture();

            DateProjectionDto sourceDto = fixture.Create <DateProjectionDto>();
            DateProjection    domain    = DateProjection.FromDto(sourceDto);
            DateProjectionDto targetDto = DateProjection.ToDto(domain);

            var sourceDtoLikeness = sourceDto.AsSource().OfLikeness <DateProjectionDto>();

            sourceDtoLikeness.ShouldEqual(targetDto);
        }
        private static DateProjection DateProjection(int monthCount, EWeeksInMonth weeksInMonth, EDaysOfWeekExt daysOfWeek)
        {
            var projection = new MonthlyRelativeProjection()
            {
                MonthCount    = monthCount,
                WeeksInMonth  = weeksInMonth,
                DaysOfWeekExt = daysOfWeek,
            };
            var dateProjection = new DateProjection(projection);

            return(dateProjection);
        }
Exemplo n.º 23
0
        public void FluentlyCreateWithLeadTimeAsDateProjection()
        {
            var dateProjection = new DateProjection(EDateProjectionType.Weekly)
            {
                DaysOfWeekFlags = EDaysOfWeekFlags.Monday, PeriodCount = 1,
            };
            Activity activity = Activity.FluentNew("New Activity")
                                .ActiveDueDate(new DateTime(2017, 2, 28))
                                .LeadTime(dateProjection);

            Assert.That(activity.LeadTimeDate, Is.EqualTo(new DateTime(2017, 2, 27)));
        }
Exemplo n.º 24
0
        public void LeadTimeDateIsNullWhenActiveDueDateIsNull()
        {
            var            activity           = new Activity();
            DateProjection leadTimeProjection = new DateProjection(new DailyProjection()
            {
                DayCount = 7
            });

            activity.ActiveDueDate = null;
            activity.LeadTime      = leadTimeProjection;
            Assert.That(activity.LeadTimeDate, Is.Null);
        }
Exemplo n.º 25
0
        public void VerifyLeadTimeDate()
        {
            var            activity           = new Activity();
            DateProjection leadTimeProjection = new DateProjection(new DailyProjection()
            {
                DayCount = 7
            });

            activity.ActiveDueDate = new DateTime(2017, 2, 8);
            activity.LeadTime      = leadTimeProjection;
            Assert.That(activity.LeadTime, Is.SameAs(leadTimeProjection));
            Assert.That(activity.LeadTimeDate, Is.EqualTo(new DateTime(2017, 2, 1)));
        }
Exemplo n.º 26
0
        public void VerifyLeadTimeDateAfterDateProjectionTranslation()
        {
            var            activity           = new Activity();
            DateProjection leadTimeProjection = new DateProjection(new WeeklyProjection()
            {
                WeekCount = 2, DaysOfWeek = EDaysOfWeekFlags.Monday
            });

            activity.ActiveDueDate = new DateTime(2017, 2, 28);
            activity.LeadTime      = leadTimeProjection;
            Assert.That(activity.LeadTime, Is.SameAs(leadTimeProjection));
            Assert.That(activity.LeadTimeDate, Is.EqualTo(new DateTime(2017, 2, 20)));

            activity.LeadTime.ProjectionType = EDateProjectionType.Daily;
            Assert.That(activity.LeadTimeDate, Is.EqualTo(new DateTime(2017, 2, 26)));
        }
Exemplo n.º 27
0
        public void TranslateProjectionType()
        {
            const int              periodCount    = 1;
            const EMonth           month          = EMonth.February;
            const int              dayOfMonth     = 3;
            const EDaysOfWeekExt   dayOfWeekExt   = EDaysOfWeekExt.Thursday;
            const EDaysOfWeekFlags dayOfWeekFlags = EDaysOfWeekFlags.Friday;
            const EWeeksInMonth    weekInMonth    = EWeeksInMonth.Last;

            DateProjection prj = new DateProjection(EDateProjectionType.Daily)
            {
                PeriodCount     = periodCount,
                Month           = month,
                DayOfMonth      = dayOfMonth,
                DaysOfWeekExt   = dayOfWeekExt,
                DaysOfWeekFlags = dayOfWeekFlags,
                WeeksInMonth    = weekInMonth,
            };

            prj.ProjectionType = EDateProjectionType.Weekly;
            Assert.That(DateProjection.ToShortDescription(prj), Is.EqualTo("Weekly"));
            prj.ProjectionType = EDateProjectionType.Monthly;
            Assert.That(DateProjection.ToShortDescription(prj), Is.EqualTo("Monthly"));
            prj.ProjectionType = EDateProjectionType.MonthlyRelative;
            Assert.That(DateProjection.ToShortDescription(prj), Is.EqualTo("Monthly Relative"));
            prj.ProjectionType = EDateProjectionType.Yearly;
            Assert.That(DateProjection.ToShortDescription(prj), Is.EqualTo("Yearly"));
            prj.ProjectionType = EDateProjectionType.YearlyRelative;
            Assert.That(DateProjection.ToShortDescription(prj), Is.EqualTo("Yearly Relative"));
            prj.ProjectionType = EDateProjectionType.Daily;
            Assert.That(DateProjection.ToShortDescription(prj), Is.EqualTo("Daily"));

            Assert.That(prj.PeriodCount, Is.EqualTo(periodCount));
            Assert.That(prj.Month, Is.EqualTo(month));
            Assert.That(prj.DayOfMonth, Is.EqualTo(dayOfMonth));
            Assert.That(prj.DaysOfWeekExt, Is.EqualTo(dayOfWeekExt));
            Assert.That(prj.DaysOfWeekFlags, Is.EqualTo(dayOfWeekFlags));
            Assert.That(prj.WeeksInMonth, Is.EqualTo(weekInMonth));

            Assert.That(DateProjection.ToShortDescription(null), Is.EqualTo("None"));
        }
Exemplo n.º 28
0
        public void TranslateToInvalidProjectionType()
        {
            var prj = new DateProjection();

            Assert.That(() => prj.ProjectionType = (EDateProjectionType)int.MaxValue, Throws.TypeOf <InvalidOperationException>());
        }
 public TReturn LeadTime(DateProjection dateProjection)
 {
     this.Activity.LeadTime = dateProjection;
     return((TReturn)this);
 }