public void NotesContent_WritesDayModel()
        {
            Calculations.NowTime = new DateTime(2017, 1, 27);
            TimeMerge.Model.SingleDayData dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = Calculations.NowTime.Day, IsNoWorkDay = false
            };
            var dayViewModel = new SingleDayViewModel();

            dayViewModel.ReInit(dayData, null, null);
            var fakeMonthVM = new FakeMonthViewModel()
            {
                ForcedYearMonth = Calculations.NowTime
            };

            fakeMonthVM.AddDayVM(dayViewModel);
            var dayModel = (from dayVM in fakeMonthVM.Days.AsQueryable()
                            where dayVM.GetDayData().Day == Calculations.NowTime.Day
                            select dayVM.GetDayData()).FirstOrDefault();
            var notesPanelVM = new NotesPanelViewModel(fakeMonthVM, Calculations.NowTime.Day);

            notesPanelVM.NotesContent = "abc\ndef";

            Assert.AreEqual(notesPanelVM.NotesContent, dayModel.NotesContent);
        }
Esempio n. 2
0
        public void HomeOfficeDay_CannotBeAutoStarted_WhenNoWorkDay()
        {
            TimeMerge.Model.SingleDayData dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = true
            };
            var dayVM = new FakeSingleDayViewModel();

            dayVM.ReInit(dayData, null, null);

            bool canExecute = dayVM.StartHomeOfficeDayCommand.CanExecute(null);

            Assert.IsFalse(canExecute);
        }
Esempio n. 3
0
        public void SingleDayViewModel_EmptyNotes_AreNotInTooltip_WhenNoCorrections()
        {
            TimeMerge.Utils.Calculations.NowTime = new DateTime(2012, 10, 26, 21, 11, 59);
            TimeMerge.Model.SingleDayData dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            var dayVM = new FakeSingleDayViewModel();

            dayVM.ReInit(dayData, new FakeMonthViewModel(), null);

            string tooltip = dayVM.WorkSpan0ToolTip;

            Assert.AreEqual(null, tooltip);
        }
Esempio n. 4
0
        public void HomeOfficeDay_CanBeStarted_WhenWorkDayCompletelyEmpty()
        {
            TimeMerge.Utils.Calculations.NowTime = new DateTime(2012, 10, 26, 21, 11, 59);
            TimeMerge.Model.SingleDayData dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            var dayVM = new FakeSingleDayViewModel();

            dayVM.ReInit(dayData, null, null);

            bool canExecute = dayVM.StartHomeOfficeDayCommand.CanExecute(null);

            Assert.IsTrue(canExecute);
        }
Esempio n. 5
0
        public void SingleDayViewModel_Notes_ShownInTooltip_WhenNoCorrections()
        {
            TimeMerge.Utils.Calculations.NowTime = new DateTime(2012, 10, 26, 21, 11, 59);
            TimeMerge.Model.SingleDayData dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.NotesContent = "some dummy notes";
            var dayVM = new FakeSingleDayViewModel();

            dayVM.ReInit(dayData, new FakeMonthViewModel(), null);

            string tooltip = dayVM.WorkSpan0ToolTip;

            Assert.AreEqual(NotesContentFormatter.Prefix + "some dummy notes", tooltip);
        }
Esempio n. 6
0
        public void SingleDayViewModel_Notes_ShownInTooltip_WhenCorrectionsExist()
        {
            TimeMerge.Utils.Calculations.NowTime = new DateTime(2012, 10, 26, 21, 11, 59);
            TimeMerge.Model.SingleDayData dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            dayData.NotesContent = "some dummy notes";
            dayData.WorkSpans[0].CorrectionStartTime = new DateTime(2012, 10, 26, 7, 7, 7);
            var dayVM = new FakeSingleDayViewModel();

            dayVM.ReInit(dayData, new FakeMonthViewModel(), null);

            string tooltip = dayVM.WorkSpan0ToolTip;

            string expected = "Korekcia z 00:00 - 00:00\r\n+0:00 bol dosiahnutý o 21:11 (s obedom o 21:31)\r\n" + NotesContentFormatter.Prefix + "some dummy notes";

            Assert.AreEqual(expected, tooltip);
        }
Esempio n. 7
0
        public DesignMainViewModel()
        {
            var now = TimeMerge.Utils.Calculations.NowTime;

            var mainViewModel = this;

            mainViewModel.Year  = now.Year;
            mainViewModel.Month = now.Month;
            mainViewModel.SettingsPanelVM.UserID = "D0C22AC4-B7BE-4B5E-B0CC-B99419E822B4";
            mainViewModel.UserName = "******";

            MonthData           = new TimeMerge.Model.SingleMonthData();
            MonthData.YearMonth = now;
            var webDavConnection = new WebDavConnection();

            webDavConnection.Init(SettingsPanelVM.UserID, "dummyLogin", "001122", "dummyWebDavUrl");
            mainViewModel.MonthViewModel = new SingleMonthViewModel(mainViewModel, new NoActionOnWebRequest(), webDavConnection);
            mainViewModel.MonthViewModel.SetMonthData(MonthData);

            DayData             = new TimeMerge.Model.SingleDayData();
            DayData.Day         = 1;
            DayData.IsNoWorkDay = false;
            DayData.WorkInterruptions[0].StartTime         = now - TimeSpan.FromHours(1);
            DayData.WorkInterruptions[0].EndTime           = now + TimeSpan.FromHours(7.5);
            DayData.WorkInterruptions[0].CorrectionEndTime = now + TimeSpan.FromHours(8);
            DayData.WorkInterruptions[0].Type = TimeMerge.Model.WorkInterruption.WorkInterruptionType.OBED;
            SingleDayViewModel dayVM = new SingleDayViewModel();

            dayVM.ReInit(DayData, mainViewModel.MonthViewModel, MonthData.Days);
            mainViewModel.MonthViewModel.Days.Add(dayVM);

            var holidayData = new TimeMerge.Model.SingleDayData();

            holidayData.Day         = 2;
            holidayData.IsNoWorkDay = true;
            SingleDayViewModel dayVM2 = new SingleDayViewModel();

            dayVM2.ReInit(holidayData, mainViewModel.MonthViewModel, MonthData.Days);
            mainViewModel.MonthViewModel.Days.Add(dayVM2);
        }
Esempio n. 8
0
        public void notifyPropertiesAfterAddingLunchTimeInterruption_WillUpdateVirtualTimeEnding_Always()
        {
            TimeMerge.Model.SingleDayData dayData = new TimeMerge.Model.SingleDayData()
            {
                Day = 26, IsNoWorkDay = false
            };
            var dayVM = new FakeSingleDayViewModel();

            dayVM.ReInit(dayData, null, null);
            var propertiesUpdated = new List <string>();

            dayVM.PropertyChanged += (sender, e) => propertiesUpdated.Add(e.PropertyName);

            dayVM.ForceUpdateAfterLunchTimeAddition();

            Assert.IsTrue(propertiesUpdated.Contains("Interrupt0VirtualTimeEnding"));
            Assert.IsTrue(propertiesUpdated.Contains("Interrupt1VirtualTimeEnding"));
            Assert.IsTrue(propertiesUpdated.Contains("Interrupt2VirtualTimeEnding"));
            Assert.IsTrue(propertiesUpdated.Contains("Interrupt3VirtualTimeEnding"));
            Assert.IsTrue(propertiesUpdated.Contains("Interrupt4VirtualTimeEnding"));
            Assert.IsTrue(propertiesUpdated.Contains("Interrupt5VirtualTimeEnding"));
            Assert.IsTrue(propertiesUpdated.Contains("Interrupt6VirtualTimeEnding"));
            Assert.IsTrue(propertiesUpdated.Contains("Interrupt7VirtualTimeEnding"));
        }