Beispiel #1
0
        public void IntersectDatePairDicts_WTRFromToContainsFromDateOfCalendarItem_SixKeyDictionary()
        {
            //Arrange
            DateTime     from  = new DateTime(2013, 12, 01);
            DateTime     to    = new DateTime(2014, 02, 01);
            WTRViewModel model = new WTRViewModel();

            DateTime wtrFrom = new DateTime(2013, 11, 01);
            DateTime wtrTo   = new DateTime(2014, 01, 01);
            Dictionary <int, WTRViewModel.StartEndDatePair> dict    = model.GetWeeksInTimeSpan(from, to);
            Dictionary <int, WTRViewModel.StartEndDatePair> wtrDict = model.GetWeeksInTimeSpan(wtrFrom, wtrTo);

            //Act
            var result = model.IntersectDatePairDicts(dict, wtrDict);

            //Assert
            Assert.AreEqual(7, result.Count);
            Assert.AreEqual(48, result.Keys.FirstOrDefault());
            Assert.AreEqual(1, result.Keys.Last());
            Assert.AreEqual(new DateTime(2013, 12, 01), result[48].startDate);
            Assert.AreEqual(new DateTime(2013, 12, 01), result[48].endDate);
            Assert.AreEqual(new DateTime(2013, 12, 29), result[52].endDate);
            Assert.AreEqual(new DateTime(2013, 12, 30), result[53].startDate);
            Assert.AreEqual(new DateTime(2013, 12, 31), result[53].endDate);
            Assert.AreEqual(new DateTime(2014, 01, 01), result[1].startDate);
            Assert.AreEqual(new DateTime(2014, 01, 01), result[1].endDate);
        }
Beispiel #2
0
        public void IntersectDatePairDicts_WTRFromToNotContainCalendarItem_OneKeyDictionary()
        {
            //Arrange
            DateTime     from  = new DateTime(2014, 01, 01);
            DateTime     to    = new DateTime(2014, 01, 01);
            WTRViewModel model = new WTRViewModel();

            DateTime wtrFrom = new DateTime(2015, 12, 12);
            DateTime wtrTo   = new DateTime(2015, 01, 10);
            Dictionary <int, WTRViewModel.StartEndDatePair> dict    = model.GetWeeksInTimeSpan(from, to);
            Dictionary <int, WTRViewModel.StartEndDatePair> wtrDict = model.GetWeeksInTimeSpan(wtrFrom, wtrTo);

            //Act
            var result = model.IntersectDatePairDicts(dict, wtrDict);

            //Assert
            Assert.AreEqual(0, result.Count);
        }
Beispiel #3
0
        public void IntersectDatePairDicts_CalendarItemDuesForOneDay_OneKeyDictionary()
        {
            //Arrange
            DateTime     from  = new DateTime(2014, 01, 01);
            DateTime     to    = new DateTime(2014, 01, 01);
            WTRViewModel model = new WTRViewModel();

            DateTime wtrFrom = new DateTime(2013, 12, 12);
            DateTime wtrTo   = new DateTime(2014, 01, 10);
            Dictionary <int, WTRViewModel.StartEndDatePair> dict    = model.GetWeeksInTimeSpan(from, to);
            Dictionary <int, WTRViewModel.StartEndDatePair> wtrDict = model.GetWeeksInTimeSpan(wtrFrom, wtrTo);

            //Act
            var result = model.IntersectDatePairDicts(dict, wtrDict);

            //Assert
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(1, result.Keys.FirstOrDefault());
            Assert.AreEqual(1, result.Keys.Last());
            Assert.AreEqual(new DateTime(2014, 01, 01), result[1].startDate);
            Assert.AreEqual(new DateTime(2014, 01, 01), result[1].endDate);
        }
Beispiel #4
0
        public void GetWeeksInTimeSpan_IllegalDatesToIsLesserThanFrom_0Weeks()
        {
            //Arrange
            DateTime     from  = new DateTime(2014, 01, 02);
            DateTime     to    = new DateTime(2014, 01, 01);
            WTRViewModel model = new WTRViewModel();

            //Act
            Dictionary <int, WTRViewModel.StartEndDatePair> result = model.GetWeeksInTimeSpan(from, to);

            //Assert
            Assert.AreEqual(0, result.Count);
        }
Beispiel #5
0
        public void IntersectDatePairDicts_WTRFromInLastYearToCurrentYear_TwoKeysDictionary()
        {
            //Arrange
            DateTime     from  = new DateTime(2014, 02, 03);
            DateTime     to    = new DateTime(2014, 02, 12);
            WTRViewModel model = new WTRViewModel();

            DateTime wtrFrom = new DateTime(2013, 12, 12);
            DateTime wtrTo   = new DateTime(2014, 02, 28);
            Dictionary <int, WTRViewModel.StartEndDatePair> dict    = model.GetWeeksInTimeSpan(from, to);
            Dictionary <int, WTRViewModel.StartEndDatePair> wtrDict = model.GetWeeksInTimeSpan(wtrFrom, wtrTo);

            //Act
            var result = model.IntersectDatePairDicts(dict, wtrDict);

            //Assert
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(6, result.Keys.FirstOrDefault());
            Assert.AreEqual(7, result.Keys.Last());
            Assert.AreEqual(new DateTime(2014, 02, 03), result[6].startDate);
            Assert.AreEqual(new DateTime(2014, 02, 09), result[6].endDate);
            Assert.AreEqual(new DateTime(2014, 02, 10), result[7].startDate);
            Assert.AreEqual(new DateTime(2014, 02, 12), result[7].endDate);
        }
Beispiel #6
0
        public void GetWeeksInTimeSpan_TwoDaysAtEndOfWeek_SingleWeek()
        {
            //Arrange
            DateTime     from  = new DateTime(2014, 04, 26);
            DateTime     to    = new DateTime(2014, 04, 27);
            WTRViewModel model = new WTRViewModel();

            //Act
            Dictionary <int, WTRViewModel.StartEndDatePair> result = model.GetWeeksInTimeSpan(from, to);

            //Assert
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(17, result.Keys.FirstOrDefault());
            Assert.AreEqual(new DateTime(2014, 04, 26), result[17].startDate);
            Assert.AreEqual(new DateTime(2014, 04, 27), result[17].endDate);
        }
Beispiel #7
0
        public void GetWeeksInTimeSpan_DaysAcrossTwoYears_TwoWeeksSecondOneHasNumber1()
        {
            //Arrange
            DateTime     from  = new DateTime(2014, 12, 29);
            DateTime     to    = new DateTime(2015, 01, 02);
            WTRViewModel model = new WTRViewModel();

            //Act
            Dictionary <int, WTRViewModel.StartEndDatePair> result = model.GetWeeksInTimeSpan(from, to);

            //Assert
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(53, result.Keys.FirstOrDefault());
            Assert.AreEqual(1, result.Keys.Skip(1).FirstOrDefault());
            Assert.AreEqual(new DateTime(2014, 12, 29), result[53].startDate);
            Assert.AreEqual(new DateTime(2014, 12, 31), result[53].endDate);
            Assert.AreEqual(new DateTime(2015, 01, 01), result[1].startDate);
            Assert.AreEqual(new DateTime(2015, 01, 02), result[1].endDate);
        }
Beispiel #8
0
        public void GetWeeksInTimeSpan_ManyDaysAcrossThreeWeeks_ThreeWeeks()
        {
            //Arrange
            DateTime     from  = new DateTime(2014, 04, 26);
            DateTime     to    = new DateTime(2014, 05, 07);
            WTRViewModel model = new WTRViewModel();

            //Act
            Dictionary <int, WTRViewModel.StartEndDatePair> result = model.GetWeeksInTimeSpan(from, to);

            //Assert
            Assert.AreEqual(3, result.Count);
            Assert.AreEqual(17, result.Keys.FirstOrDefault());
            Assert.AreEqual(18, result.Keys.Skip(1).FirstOrDefault());
            Assert.AreEqual(19, result.Keys.Skip(2).FirstOrDefault());
            Assert.AreEqual(new DateTime(2014, 04, 26), result[17].startDate);
            Assert.AreEqual(new DateTime(2014, 04, 27), result[17].endDate);
            Assert.AreEqual(new DateTime(2014, 04, 28), result[18].startDate);
            Assert.AreEqual(new DateTime(2014, 05, 04), result[18].endDate);
            Assert.AreEqual(new DateTime(2014, 05, 05), result[19].startDate);
            Assert.AreEqual(new DateTime(2014, 05, 07), result[19].endDate);
        }