예제 #1
0
        public void SetMonthData(TimeMerge.Model.SingleMonthData monthData)
        {
            _monthData = monthData;

            bool loadFromFileWentOK = this.LoadData_BkgndWithModalLoop();

            if (!loadFromFileWentOK)
            {
                PopulateDataFromWebOnBackground();
            }
        }
예제 #2
0
        public void WorkSpan0ToolTip_UsesInvariantCulture_Always()
        {
            var oldCulture = Thread.CurrentThread.CurrentCulture;

            Thread.CurrentThread.CurrentCulture  = new System.Globalization.CultureInfo("sk");
            TimeMerge.Utils.Calculations.NowTime = new DateTime(2012, 10, 26, 11, 11, 59);
            var mainVM = new FakeMainViewModel();

            mainVM.Init();
            var monthData = new TimeMerge.Model.SingleMonthData()
            {
                YearMonth = new DateTime(2012, 10, 1)
            };

            mainVM.MonthViewModel.SetMonthData(monthData);
            TimeMerge.Model.SingleDayData dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };

            //               now |11:11|
            // 6:36 -
            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkInterruptions[0].CorrectionStartTime = new DateTime(2012, 10, 26, 6, 36, 0);
            //             dayData.WorkInterruptions[0].EndTime = new DateTime(2012, 10, 26, 12, 10, 0);
            dayData.WorkInterruptions[0].CorrectedType = WorkInterruption.WorkInterruptionType.PDOMA;
            TimeMerge.ViewModel.SingleDayViewModel dayVM = new TimeMerge.ViewModel.SingleDayViewModel();
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);
            mainVM.MonthViewModel.Days.Add(dayVM);

            string tooltip = dayVM.Interrupt0ToolTip;

            Assert.AreEqual("Korekcia z 00:00 - 00:00, z typu PDOMA" + System.Environment.NewLine + "+0:00 sa dosiahne o 14:36 (s obedom o 14:56)", tooltip, false);
            Thread.CurrentThread.CurrentCulture = oldCulture;
        }
예제 #3
0
        public void GetLunchDurationTest()
        {
            TimeMerge.Utils.Calculations.NowTime = new DateTime(2012, 10, 26, 15, 48, 59);

            var mainVM = new FakeMainViewModel();

            mainVM.Init();

            var monthData = new TimeMerge.Model.SingleMonthData()
            {
                YearMonth = new DateTime(2012, 10, 1)
            };

            mainVM.MonthViewModel.SetMonthData(monthData);

            TimeMerge.Model.SingleDayData          dayData;
            TimeMerge.ViewModel.SingleDayViewModel dayVM = new TimeMerge.ViewModel.SingleDayViewModel();



            // Work Spans:
            // 7:00 - 14:00
            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkSpans[0].StartTime = new DateTime(2012, 10, 26, 7, 0, 0);
            dayData.WorkSpans[0].EndTime   = new DateTime(2012, 10, 26, 14, 0, 0);
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);

            Assert.AreEqual(TimeSpan.FromMinutes(0), dayVM.GetLunchDuration());


            // Work Spans:                                  Work Interruptions:
            // 7:00 - 12:00   12:20 - 15:00                 12:00 - 12:10 [OBED]   12:10 - 12:20 [OBED]
            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkSpans[0].StartTime         = new DateTime(2012, 10, 26, 7, 0, 0);
            dayData.WorkSpans[0].EndTime           = new DateTime(2012, 10, 26, 12, 0, 0);
            dayData.WorkSpans[1].StartTime         = new DateTime(2012, 10, 26, 12, 20, 0);
            dayData.WorkSpans[1].EndTime           = new DateTime(2012, 10, 26, 15, 0, 0);
            dayData.WorkInterruptions[0].StartTime = new DateTime(2012, 10, 26, 12, 0, 0);
            dayData.WorkInterruptions[0].EndTime   = new DateTime(2012, 10, 26, 12, 10, 0);
            dayData.WorkInterruptions[0].Type      = WorkInterruption.WorkInterruptionType.OBED;
            dayData.WorkInterruptions[1].StartTime = new DateTime(2012, 10, 26, 12, 10, 0);
            dayData.WorkInterruptions[1].EndTime   = new DateTime(2012, 10, 26, 12, 20, 0);
            dayData.WorkInterruptions[1].Type      = WorkInterruption.WorkInterruptionType.OBED;
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);

            Assert.AreEqual(TimeSpan.FromMinutes(SingleDayData.LunchTimeMinimalTime), dayVM.GetLunchDuration());



            // Work Spans:                                  Work Interruptions:
            //                                              6:36 - . []
            TimeMerge.Utils.Calculations.NowTime = new DateTime(2012, 10, 26, 8, 30, 59);
            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkInterruptions[0].CorrectionStartTime = new DateTime(2012, 10, 26, 6, 36, 0);
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);

            Assert.AreEqual(TimeSpan.FromMinutes(0), dayVM.GetLunchDuration());



            // Work Spans:
            // 7:00 - 9:00   10:30 - 11:00   11:01 - 11:10   11:11 - 11:20   11:31 - 11:40   11:41 - 12:00   12:20 - 15:00
            // Work Interruptions:
            // 9:00 - 10:30 [LEK]   11:00 - 11:01 [ZP]   11:10 - 11:11 [ZP]   11:20 - 11:21 [ZP]   11:21 - 11:31 [ZP]   11:40 - 11:41 [ZP]   12:00 - 12:10 [OBED]   12:10 - 12:20 [OBED]
            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkSpans[0].StartTime         = new DateTime(2012, 10, 26, 7, 0, 0);
            dayData.WorkSpans[0].EndTime           = new DateTime(2012, 10, 26, 9, 0, 0);
            dayData.WorkSpans[1].StartTime         = new DateTime(2012, 10, 26, 10, 30, 0);
            dayData.WorkSpans[1].EndTime           = new DateTime(2012, 10, 26, 11, 0, 0);
            dayData.WorkSpans[2].StartTime         = new DateTime(2012, 10, 26, 11, 1, 0);
            dayData.WorkSpans[2].EndTime           = new DateTime(2012, 10, 26, 11, 10, 0);
            dayData.WorkSpans[3].StartTime         = new DateTime(2012, 10, 26, 11, 11, 0);
            dayData.WorkSpans[3].EndTime           = new DateTime(2012, 10, 26, 11, 20, 0);
            dayData.WorkSpans[4].StartTime         = new DateTime(2012, 10, 26, 11, 31, 0);
            dayData.WorkSpans[4].EndTime           = new DateTime(2012, 10, 26, 11, 40, 0);
            dayData.WorkSpans[5].StartTime         = new DateTime(2012, 10, 26, 11, 41, 0);
            dayData.WorkSpans[5].EndTime           = new DateTime(2012, 10, 26, 12, 0, 0);
            dayData.WorkSpans[6].StartTime         = new DateTime(2012, 10, 26, 12, 20, 0);
            dayData.WorkSpans[6].EndTime           = new DateTime(2012, 10, 26, 15, 0, 0);
            dayData.WorkInterruptions[0].StartTime = new DateTime(2012, 10, 26, 9, 0, 0);
            dayData.WorkInterruptions[0].EndTime   = new DateTime(2012, 10, 26, 10, 30, 0);
            dayData.WorkInterruptions[0].Type      = WorkInterruption.WorkInterruptionType.LEK;
            dayData.WorkInterruptions[1].StartTime = new DateTime(2012, 10, 26, 11, 0, 0);
            dayData.WorkInterruptions[1].EndTime   = new DateTime(2012, 10, 26, 11, 1, 0);
            dayData.WorkInterruptions[1].Type      = WorkInterruption.WorkInterruptionType.ZP;
            dayData.WorkInterruptions[2].StartTime = new DateTime(2012, 10, 26, 11, 10, 0);
            dayData.WorkInterruptions[2].EndTime   = new DateTime(2012, 10, 26, 11, 11, 0);
            dayData.WorkInterruptions[2].Type      = WorkInterruption.WorkInterruptionType.ZP;
            dayData.WorkInterruptions[3].StartTime = new DateTime(2012, 10, 26, 11, 20, 0);
            dayData.WorkInterruptions[3].EndTime   = new DateTime(2012, 10, 26, 11, 21, 0);
            dayData.WorkInterruptions[3].Type      = WorkInterruption.WorkInterruptionType.ZP;
            dayData.WorkInterruptions[4].StartTime = new DateTime(2012, 10, 26, 11, 21, 0);
            dayData.WorkInterruptions[4].EndTime   = new DateTime(2012, 10, 26, 11, 31, 0);
            dayData.WorkInterruptions[4].Type      = WorkInterruption.WorkInterruptionType.ZP;
            dayData.WorkInterruptions[5].StartTime = new DateTime(2012, 10, 26, 11, 40, 0);
            dayData.WorkInterruptions[5].EndTime   = new DateTime(2012, 10, 26, 11, 41, 0);
            dayData.WorkInterruptions[5].Type      = WorkInterruption.WorkInterruptionType.ZP;
            dayData.WorkInterruptions[6].StartTime = new DateTime(2012, 10, 26, 12, 0, 0);
            dayData.WorkInterruptions[6].EndTime   = new DateTime(2012, 10, 26, 12, 10, 0);
            dayData.WorkInterruptions[6].Type      = WorkInterruption.WorkInterruptionType.OBED;
            dayData.WorkInterruptions[7].StartTime = new DateTime(2012, 10, 26, 12, 10, 0);
            dayData.WorkInterruptions[7].EndTime   = new DateTime(2012, 10, 26, 12, 20, 0);
            dayData.WorkInterruptions[7].Type      = WorkInterruption.WorkInterruptionType.OBED;
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);

            Assert.AreEqual(TimeSpan.FromMinutes(SingleDayData.LunchTimeMinimalTime), dayVM.GetLunchDuration());
        }
예제 #4
0
        public void TimeToReachZeroBalanceTest()
        {
            TimeMerge.Utils.Calculations.NowTime = new DateTime(2012, 10, 26, 15, 48, 59);

            var mainVM = new FakeMainViewModel();

            mainVM.Init();

            var monthData = new TimeMerge.Model.SingleMonthData()
            {
                YearMonth = new DateTime(2012, 10, 1)
            };

            mainVM.MonthViewModel.SetMonthData(monthData);

            TimeMerge.Model.SingleDayData          dayData;
            TimeMerge.ViewModel.SingleDayViewModel dayVM = new TimeMerge.ViewModel.SingleDayViewModel();

            //                     now |15:48|
            // 7:00 - 14:00
            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkSpans[0].StartTime = new DateTime(2012, 10, 26, 7, 0, 0);
            dayData.WorkSpans[0].EndTime   = new DateTime(2012, 10, 26, 14, 0, 0);
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);

            mainVM.MonthViewModel.Days.Clear();
            mainVM.MonthViewModel.Days.Add(dayVM);
            Assert.IsNull(dayVM.WorkSpan0ToolTip);

            //                     now |15:48|
            // 7:00 - .
            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkSpans[0].StartTime = new DateTime(2012, 10, 26, 7, 0, 0);
            dayData.WorkSpans[0].EndTime   = new DateTime(2012, 10, 26, 0, 0, 0);
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);

            mainVM.MonthViewModel.Days.Clear();
            mainVM.MonthViewModel.Days.Add(dayVM);
            Assert.AreEqual("+0:00 bol dosiahnutý o 15:00 (s obedom o 15:20)", dayVM.WorkSpan0ToolTip, false);

            //                     now |15:48|
            // 10:00 - .
            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkSpans[0].StartTime = new DateTime(2012, 10, 26, 10, 0, 0);
            dayData.WorkSpans[0].EndTime   = new DateTime(2012, 10, 26, 0, 0, 0);
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);

            mainVM.MonthViewModel.Days.Clear();
            mainVM.MonthViewModel.Days.Add(dayVM);
            Assert.AreEqual("+0:00 sa dosiahne o 18:00 (s obedom o 18:20)", dayVM.WorkSpan0ToolTip, false);

            TimeMerge.Utils.Calculations.NowTime = new DateTime(2012, 10, 26, 11, 11, 59);

            //               now |11:11|
            // 7:00 - 9:00                 12:12 - .
            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkSpans[0].StartTime = new DateTime(2012, 10, 26, 7, 0, 0);
            dayData.WorkSpans[0].EndTime   = new DateTime(2012, 10, 26, 9, 0, 0);
            dayData.WorkSpans[1].StartTime = new DateTime(2012, 10, 26, 12, 12, 0);
            dayData.WorkSpans[1].EndTime   = new DateTime(2012, 10, 26, 0, 0, 0);
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);

            mainVM.MonthViewModel.Days.Clear();
            mainVM.MonthViewModel.Days.Add(dayVM);
            Assert.IsNull(dayVM.WorkSpan0ToolTip);
            Assert.AreEqual("+0:00 sa dosiahne o 18:12 (s obedom o 18:32)", dayVM.WorkSpan1ToolTip, false);

            //               now |11:11|
            // 7:00 - 9:00                 12:12 - 18:18
            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkSpans[0].StartTime = new DateTime(2012, 10, 26, 7, 0, 0);
            dayData.WorkSpans[0].EndTime   = new DateTime(2012, 10, 26, 9, 0, 0);
            dayData.WorkSpans[1].StartTime = new DateTime(2012, 10, 26, 12, 12, 0);
            dayData.WorkSpans[1].EndTime   = new DateTime(2012, 10, 26, 18, 18, 0);
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);
            mainVM.MonthViewModel.NotifyPropertyChanged("BalanceWholeMonth");

            mainVM.MonthViewModel.Days.Clear();
            mainVM.MonthViewModel.Days.Add(dayVM);
            Assert.IsNull(dayVM.WorkSpan0ToolTip);
            Assert.IsNull(dayVM.WorkSpan1ToolTip);
            Assert.AreEqual(TimeSpan.FromMinutes(6), mainVM.MonthViewModel.BalanceWholeMonth);



            // Work Spans:                                  Work Interruptions:
            //                                              06:36 - .
            TimeMerge.Utils.Calculations.NowTime = new DateTime(2012, 10, 26, 8, 30, 59);

            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkInterruptions[0].CorrectionStartTime = new DateTime(2012, 10, 26, 6, 36, 0);
            //             dayData.WorkInterruptions[0].EndTime = new DateTime(2012, 10, 26, 12, 10, 0);
            dayData.WorkInterruptions[0].CorrectedType = WorkInterruption.WorkInterruptionType.PDOMA;
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);

            mainVM.MonthViewModel.Days.Clear();
            mainVM.MonthViewModel.Days.Add(dayVM);
            Assert.AreEqual("Korekcia z 00:00 - 00:00, z typu PDOMA" + System.Environment.NewLine + "+0:00 sa dosiahne o 14:36 (s obedom o 14:56)", dayVM.Interrupt0ToolTip, false);



            // Work Spans:                                  Work Interruptions:
            //                                              7:10 - 11:50 [PDOMA]   11:50 - 12:00 [ZP]   12:00 - 12:20 [OBED]   12:20 - . [PDOMA]
            TimeMerge.Utils.Calculations.NowTime = new DateTime(2012, 10, 26, 13, 40, 59);

            dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.WorkInterruptions[0].CorrectionStartTime = new DateTime(2012, 10, 26, 7, 10, 0);
            dayData.WorkInterruptions[0].EndTime             = new DateTime(2012, 10, 26, 11, 50, 0);
            dayData.WorkInterruptions[0].CorrectedType       = WorkInterruption.WorkInterruptionType.PDOMA;
            dayData.WorkInterruptions[1].CorrectionStartTime = new DateTime(2012, 10, 26, 11, 50, 0);
            dayData.WorkInterruptions[1].EndTime             = new DateTime(2012, 10, 26, 12, 0, 0);
            dayData.WorkInterruptions[1].CorrectedType       = WorkInterruption.WorkInterruptionType.ZP;
            dayData.WorkInterruptions[2].CorrectionStartTime = new DateTime(2012, 10, 26, 12, 0, 0);
            dayData.WorkInterruptions[2].EndTime             = new DateTime(2012, 10, 26, 12, 20, 0);
            dayData.WorkInterruptions[2].CorrectedType       = WorkInterruption.WorkInterruptionType.OBED;
            dayData.WorkInterruptions[3].CorrectionStartTime = new DateTime(2012, 10, 26, 12, 20, 0);
            // dayData.WorkInterruptions[3].EndTime = new DateTime(2012, 10, 26, 12, 10, 0);
            dayData.WorkInterruptions[3].CorrectedType = WorkInterruption.WorkInterruptionType.PDOMA;
            dayVM.ReInit(dayData, mainVM.MonthViewModel, monthData.Days);

            mainVM.MonthViewModel.Days.Clear();
            mainVM.MonthViewModel.Days.Add(dayVM);
            Assert.AreEqual("Korekcia z 00:00 - 00:00, z typu PDOMA" + System.Environment.NewLine + "+0:00 sa dosiahne o 15:30", dayVM.Interrupt3ToolTip, false);
        }