public void ToStringShouldReturnExpectedResult()
 {
     var weeks = new[] { new FiscalWeek( new DateTime( 2013, 6, 23 ) ) };
     var target = new FiscalMonth( weeks );
     var expected = string.Format( CultureInfo.CurrentCulture, "FirstDay = {0:d}, LastDay = {1:d}", target.FirstDay, target.LastDay );
     var actual = target.ToString();
     Assert.Equal( expected, actual );
 }
        public void FirstDayLastDayAndDaysInMonthPropertiesShouldBeBasedOnSuppliedWeeks()
        {
            var firstDay = new DateTime( 2013, 6, 23 );
            var lastDay = new DateTime( 2013, 6, 29 );
            var weeks = new[] { new FiscalWeek( firstDay ) };
            var target = new FiscalMonth( weeks );

            Assert.Equal( firstDay, target.FirstDay );
            Assert.Equal( lastDay, target.LastDay );
            Assert.Equal( 7, target.DaysInMonth );
        }
 public void FirstAndLastDayPropertiesShouldDefaultToToday()
 {
     var target = new FiscalMonth();
     Assert.Equal( DateTime.Today, target.FirstDay );
     Assert.Equal( DateTime.Today, target.LastDay );
 }
 public void ConstructorShouldSetWeeks()
 {
     var weeks = new[] { new FiscalWeek( new DateTime( 2013, 6, 23 ) ) };
     var target = new FiscalMonth( weeks );
     Assert.Equal( 1, target.Weeks.Count );
 }
        public static FourFourFiveCalendar CreateCalendar()
        {
            var schedule = new List<FiscalYear>();
            var xml = CreateTestData();
            var dates = from year in xml.Descendants( "week" )
                        select new
                        {
                            Year = int.Parse( year.Attribute( "year" ).Value ),
                            Month = int.Parse( year.Attribute( "month" ).Value ),
                            FirstDay = DateTime.Parse( year.Attribute( "start" ).Value ).Date,
                            LastDay = DateTime.Parse( year.Attribute( "end" ).Value ).Date
                        };

            var years = from date in dates
                        orderby date.Year, date.Month, date.FirstDay
                        group date by date.Year into yrs
                        from yr in
                            ( from date in yrs
                              group date by date.Month )
                        group yr by yrs.Key;

            foreach ( var year in years )
            {
                var fiscalYear = new FiscalYear();
                schedule.Add( fiscalYear );

                foreach ( var month in year )
                {
                    var fiscalMonth = new FiscalMonth();
                    fiscalYear.Months.Add( month.Key, fiscalMonth );

                    foreach ( var week in month )
                        fiscalMonth.Weeks.Add( new FiscalWeek( week.FirstDay, week.LastDay ) );
                }
            }

            var target = new FourFourFiveCalendar( schedule );
            return target;
        }