상속: INotifyPropertyChanged, IDataErrorInfo
예제 #1
0
        public void WDParser_HoleDayExpansionAndNormalExpansionShareSameKey_ReturnBothExpansions()
        {
            var abbr = new List<ShortCut>();
            abbr.Add(new ShortCut("a", "11111-111(b)") { WholeDayExpansion = false });
            abbr.Add(new ShortCut("a", "8,8;11111-111(b)") { WholeDayExpansion = true });
            WorkDayParserSettings workDayParserSettings = new WorkDayParserSettings { ShortCuts = abbr };
            WorkDayParser wdp = new WorkDayParser(workDayParserSettings);
            // find wholeday expansion
            WorkDay wd = new WorkDay(1, 1, 1, null);
            var workItemParserResult = wdp.Parse("a", ref wd);
            Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
            CollectionAssert.IsNotEmpty(wd.Items);
            CollectionAssert.AreEqual(new[] {
                new WorkItem(new TimeItem(8), new TimeItem(16), "11111", "111", "b")
            }, wd.Items);
            Assert.IsEmpty(workItemParserResult.Error);
            Assert.AreEqual(8, wd.HoursDuration);

            // find normal expansion
            wd = new WorkDay(1, 1, 2, null);
            workItemParserResult = wdp.Parse("8,8;a", ref wd);
            Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
            CollectionAssert.IsNotEmpty(wd.Items);
            CollectionAssert.AreEqual(new[] {
                new WorkItem(new TimeItem(8), new TimeItem(16), "11111", "111", "b")
            }, wd.Items);
            Assert.IsEmpty(workItemParserResult.Error);
            Assert.AreEqual(8, wd.HoursDuration);
        }
예제 #2
0
파일: WorkMonth.cs 프로젝트: vipwolf/moni
        public WorkMonth(int year, int month, GermanSpecialDays specialDays, IEnumerable<ShortCut> shortCuts, float hoursPerDay)
        {
            this.year = year;
              this.month = month;
              this.hoursPerDay = hoursPerDay;
              this.Weeks = new ObservableCollection<WorkWeek>();
              this.Days = new ObservableCollection<WorkDay>();
              this.ShortCutStatistic = new ObservableCollection<KeyValuePair<string, ShortCutStatistic>>();
              // TODO which date should i take?
              this.ReloadShortcutStatistic(shortCuts);

              var cal = new GregorianCalendar();
              WorkWeek lastWeek = null;
              for (int day = 1; day <= cal.GetDaysInMonth(year, month); day++) {
            var dt = new DateTime(year, month, day);

            WorkDay wd = new WorkDay(year, month, day, specialDays);
            this.Days.Add(wd);
            var weekOfYear = cal.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
            if (lastWeek == null || lastWeek.WeekOfYear != weekOfYear) {
              lastWeek = new WorkWeek(this, weekOfYear);
              lastWeek.PropertyChanged += new PropertyChangedEventHandler(this.WeekPropertyChanged);
              this.Weeks.Add(lastWeek);
            }
            lastWeek.AddDay(wd);
              }
        }
예제 #3
0
 public void WDParser_DestroyBreakWithAbsolutTimes_ShouldGiveError()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParserSettings workDayParserSettings = new WorkDayParserSettings { DayBreakDurationInMinutes = 30, InsertDayBreak = true, DayBreakTime = new TimeItem(12) };
     WorkDayParser wdp = new WorkDayParser(workDayParserSettings);
     var workItemParserResult = wdp.Parse("7:30,-11;11111-111,-11:45;11111-111,-12:15;11111-111,-15;11111-111", ref wd);
     Assert.IsFalse(workItemParserResult.Success, workItemParserResult.Error);
 }
예제 #4
0
 public void WDParser_EmptyString_ReturnError()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParser wdp = new WorkDayParser();
     var workItemParserResult = wdp.Parse(string.Empty, ref wd);
     Assert.IsFalse(workItemParserResult.Success);
     Assert.IsNotEmpty(workItemParserResult.Error);
 }
예제 #5
0
 public WorkDayParserResult Parse(string userInput, ref WorkDay wdToFill)
 {
     // remove newlines
       userInput = userInput.Replace(Environment.NewLine, "");
       ShortCut wholeDayShortcut;
       userInput = this.PreProcessWholeDayExpansion(userInput, wdToFill.DateTime, out wholeDayShortcut);
       bool ignoreBreakSettings = userInput.StartsWith(automaticPauseDeactivation);
       if (ignoreBreakSettings) {
     userInput = userInput.Substring(2);
       }
       WorkDayParserResult ret = new WorkDayParserResult();
       if (!String.IsNullOrEmpty(userInput)) {
     TimeItem dayStartTime;
     string remainingString;
     string error;
     // should be like "<daystarttime>,..."
     // eg 7,... or 7:30,...
     if (this.GetDayStartTime(userInput, out dayStartTime, out remainingString, out error)) {
       // proceed with parsing items
       var parts = remainingString.SplitWithIgnoreRegions(new[]{itemSeparator}, new IgnoreRegion('(',')'));
       var wdItemsAsString = parts.Where(p => !string.IsNullOrWhiteSpace(p)).ToList();
       if (wdItemsAsString.Any()) {
     List<WorkItemTemp> tmpList = new List<WorkItemTemp>();
     foreach (var wdItemString in wdItemsAsString) {
       WorkItemTemp workItem;
       if (this.GetWDTempItem(wdItemString, out workItem, out error, wdToFill.DateTime, wholeDayShortcut)) {
         tmpList.Add(workItem);
       } else {
         ret.Error = error;
         ret.Success = false;
         // todo: fail fast??
       }
     }
     IEnumerable<WorkItem> resultList;
     if (this.ProcessTempWorkItems(dayStartTime, tmpList, ignoreBreakSettings, out resultList, out error)) {
       wdToFill.Clear();
       foreach (var workItem in resultList) {
         wdToFill.AddWorkItem(workItem);
       }
       ret.Success = true;
     } else {
       ret.Error = error;
     }
       } else {
     // this is no error for now
     ret.Success = true;
     ret.Error = "Noch keine Einträge gemacht";
       }
     } else {
       ret.Error = error;
     }
       } else {
     ret.Error = "Noch keine Eingabe";
       }
       return ret;
 }
예제 #6
0
 public void HoursDuration_OnADay_ShouldSumCorrect()
 {
     WorkDay wd = new WorkDay(2011, 1, 1, null);
     wd.AddWorkItem(new WorkItem(new TimeItem(10), new TimeItem(11)));
     Assert.AreEqual(1, wd.HoursDuration);
     wd.AddWorkItem(new WorkItem(new TimeItem(11), new TimeItem(12)));
     Assert.AreEqual(2, wd.HoursDuration);
     wd.AddWorkItem(new WorkItem(new TimeItem(12), new TimeItem(12, 15)));
     Assert.AreEqual(2.25, wd.HoursDuration);
     wd.AddWorkItem(new WorkItem(new TimeItem(12, 15), new TimeItem(13)));
     Assert.AreEqual(3, wd.HoursDuration);
 }
예제 #7
0
 private void ParseData(string value)
 {
     // do parsing
     if (WorkDayParser.Instance != null)
     {
         WorkDay wd = this;
         this.lastParseResult = WorkDayParser.Instance.Parse(value, ref wd);
         if (!this.LastParseResult.Success)
         {
             // todo what now?
         }
         this.ImportantStuffChanged();
     }
 }
예제 #8
0
 public void WDParser_BrokenHours_CalculateCorrectly()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParser wdp = new WorkDayParser();
     var workItemParserResult = wdp.Parse("8:15,-15:30;11111-111,1;11111-111", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] {
         new WorkItem(new TimeItem(8, 15), new TimeItem(15, 30), "11111", "111"),
         new WorkItem(new TimeItem(15, 30), new TimeItem(16, 30), "11111", "111")
     }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
     Assert.AreEqual(8.25, wd.HoursDuration);
 }
예제 #9
0
 public void WDParser_BrokenHoursWithBreak_CalculateCorrectly()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParserSettings workDayParserSettings = new WorkDayParserSettings { DayBreakDurationInMinutes = 30, InsertDayBreak = true, DayBreakTime = new TimeItem(12) };
     WorkDayParser wdp = new WorkDayParser(workDayParserSettings);
     var workItemParserResult = wdp.Parse("8:15,-15:30;11111-111,1;11111-111", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] {
         new WorkItem(new TimeItem(8, 15), new TimeItem(12, 00), "11111", "111"),
         new WorkItem(new TimeItem(12, 30), new TimeItem(15, 30), "11111", "111"),
         new WorkItem(new TimeItem(15, 30), new TimeItem(16, 30), "11111", "111")
     }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
     Assert.AreEqual(7.75, wd.HoursDuration);
 }
예제 #10
0
 private void ParseData(string value)
 {
     // do parsing
     if (WorkDayParser.Instance != null)
     {
         WorkDay wd = this;
         this.lastParseResult = WorkDayParser.Instance.Parse(value, ref wd); // todo why is this a ref?
         if (this.LastParseResult.Success)
         {
             this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("HoursDuration"));
         }
         else
         {
             // todo what now?
             logger.Error($"Error while parsing the string: {value}");
         }
     }
 }
예제 #11
0
        public ReadWriteResult SetDataOfYear(WorkYear workYear)
        {
            var ret = ReadData();

            if (ret.Success)
            {
                foreach (WorkDayPersistenceData data in this.WorkDaysData.Where(wdpd => wdpd.Year == workYear.Year).ToList())
                {
                    var     workDay  = workYear.GetDay(data.Month, data.Day);
                    WorkDay errorDay = workDay;
                    try
                    {
                        workDay.SetData(data.OriginalString);
                    }
                    catch (Exception exception)
                    {
                        ret.ErrorCount++;
                        // only remember first error for now
                        if (ret.Success)
                        {
                            ret.Success = false;
                            string errorMessage = exception.Message;
                            if (errorDay != null)
                            {
                                errorMessage = string.Format("Beim Einlesen von {0} in der Datei {1} trat in Zeile {2} folgender Fehler auf: {3}", errorDay, data.FileName, data.LineNumber, exception.Message);
                                logger.Error(errorMessage);
                            }

                            ret.Error = errorMessage;
                        }
                    }
                }

                if (ret.ErrorCount > 1)
                {
                    ret.Error += string.Format("\n\n\nEs liegen noch {0} weitere Fehler vor.", ret.ErrorCount);
                }
            }

            return(ret);
        }
예제 #12
0
파일: MainViewModel.cs 프로젝트: dotob/moni
 public void SelectWorkDay(WorkDay selectedWorkDay)
 {
     if (this.SelectedWorkDay != null)
     {
         this.SelectedWorkDay.FocusMe = false;
     }
     this.SelectedWorkDay = selectedWorkDay;
     if (this.SelectedWorkDay != null)
     {
         this.SelectedWorkDay.FocusMe = true;
     }
 }
예제 #13
0
 public void WDParser_WhiteSpace_StillWork()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParser wdp = new WorkDayParser(new WorkDayParserSettings { InsertDayBreak = true, DayBreakTime = new TimeItem(12, 00), DayBreakDurationInMinutes = 30 });
     var workItemParserResult = wdp.Parse("9 : 00 , 2; 11111   -111 , 3;   22222-222", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] { new WorkItem(new TimeItem(9, 0), new TimeItem(11, 0), "11111", "111"), new WorkItem(new TimeItem(11, 0), new TimeItem(12, 00), "22222", "222"), new WorkItem(new TimeItem(12, 30), new TimeItem(14, 30), "22222", "222") }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
 }
예제 #14
0
 public void WDParser_UsingEndTimeAndBreak_CalculateBreak()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     var abbr = new List<ShortCut>();
     abbr.Add(new ShortCut("ctb", "11111-111"));
     abbr.Add(new ShortCut("ktl", "22222-222"));
     WorkDayParserSettings workDayParserSettings = new WorkDayParserSettings { ShortCuts = abbr, DayBreakDurationInMinutes = 30, InsertDayBreak = true, DayBreakTime = new TimeItem(12) };
     WorkDayParser wdp = new WorkDayParser(workDayParserSettings);
     var workItemParserResult = wdp.Parse("9:00,-14;ctb,-16;ktl", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] {
         new WorkItem(new TimeItem(9, 0), new TimeItem(12, 0), "11111", "111"),
         new WorkItem(new TimeItem(12, 30), new TimeItem(14, 0), "11111", "111"),
         new WorkItem(new TimeItem(14, 0), new TimeItem(16, 0), "22222", "222")
     }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
 }
예제 #15
0
 public void WDParser_UseAbbreviations_ExpandAbbreviations()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     var abbr = new List<ShortCut>();
     abbr.Add(new ShortCut("ctb", "11111-111"));
     abbr.Add(new ShortCut("ktl", "22222-222"));
     abbr.Add(new ShortCut("u", "33333-333"));
     WorkDayParserSettings workDayParserSettings = new WorkDayParserSettings { ShortCuts = abbr };
     WorkDayParser wdp = new WorkDayParser(workDayParserSettings);
     var workItemParserResult = wdp.Parse("9:00,2;ctb,1;u", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] { new WorkItem(new TimeItem(9, 0), new TimeItem(11, 0), "11111", "111"), new WorkItem(new TimeItem(11, 0), new TimeItem(12, 00), "33333", "333") }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
 }
예제 #16
0
 public void WDParser_MoreItems_ReturnWorkItemWithMoreItems()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParser wdp = new WorkDayParser();
     var workItemParserResult = wdp.Parse("7:30,1.5;11111-111,3;22222-222", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] { new WorkItem(new TimeItem(7, 30), new TimeItem(9, 0), "11111", "111"), new WorkItem(new TimeItem(9, 0), new TimeItem(12, 0), "22222", "222") }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
 }
예제 #17
0
파일: WorkWeek.cs 프로젝트: etienne-k/moni
 public void AddDay(WorkDay wd)
 {
     this.days.Add(wd);
     wd.PropertyChanged += this.WDPropertyChanged;
 }
예제 #18
0
파일: MainViewModel.cs 프로젝트: dotob/moni
 public void CopyFromPreviousDay(WorkDay currentDay)
 {
     WorkDay lastValidBefore =
         this.WorkMonth.Days.LastOrDefault(x => x.Day < currentDay.Day && x.Items != null && x.Items.Any());
     if (lastValidBefore != null)
     {
         currentDay.OriginalString = lastValidBefore.OriginalString;
     }
 }
예제 #19
0
 public void WDParser_InsertTimeIntervalPauseItem_LeavePause()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParser wdp = new WorkDayParser();
     var workItemParserResult = wdp.Parse("7,1;11111-111,2!,2;11111-111", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] {
         new WorkItem(new TimeItem(7, 0), new TimeItem(8, 0), "11111", "111"),
         new WorkItem(new TimeItem(10, 0), new TimeItem(12, 0), "11111", "111")
     }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
 }
예제 #20
0
 public void WDParser_PartEndsAtBreakTime_AddBreakCorrectly()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParserSettings workDayParserSettings = new WorkDayParserSettings { DayBreakDurationInMinutes = 30, InsertDayBreak = true, DayBreakTime = new TimeItem(12) };
     WorkDayParser wdp = new WorkDayParser(workDayParserSettings);
     var workItemParserResult = wdp.Parse("8,4;11111-111,4;11111-111", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] {
         new WorkItem(new TimeItem(8), new TimeItem(12, 00), "11111", "111"),
         new WorkItem(new TimeItem(12, 30), new TimeItem(16, 30), "11111", "111")
     }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
     Assert.AreEqual(8, wd.HoursDuration);
 }
예제 #21
0
 public void WDParser_ParseHourFragment_MultiplyBy60()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParser wdp = new WorkDayParser();
     var workItemParserResult = wdp.Parse("7,1.75;11111-111", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] {
         new WorkItem(new TimeItem(7, 0), new TimeItem(8, 45), "11111", "111")
     }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
 }
예제 #22
0
 public void WDParser_ParseDescription_GetDesc()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParser wdp = new WorkDayParser();
     var workItemParserResult = wdp.Parse("9:15,7.25;11111-111(lalala)", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] {
         new WorkItem(new TimeItem(9, 15), new TimeItem(16, 30), "11111", "111", "lalala", null, string.Empty)
     }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
 }
예제 #23
0
 public void WDParser_HoleDayExpansion_UseCompleteString()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     var abbr = new List<ShortCut>();
     abbr.Add(new ShortCut("krank", "8,8;11111-111(krank)") { WholeDayExpansion = true });
     WorkDayParserSettings workDayParserSettings = new WorkDayParserSettings { ShortCuts = abbr };
     WorkDayParser wdp = new WorkDayParser(workDayParserSettings);
     var workItemParserResult = wdp.Parse("krank", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] {
         new WorkItem(new TimeItem(8), new TimeItem(16), "11111", "111", "krank")
     }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
     Assert.AreEqual(8, wd.HoursDuration);
 }
예제 #24
0
        public WorkDayParserResult Parse(string userInput, ref WorkDay wdToFill)
        {
            // remove newlines
            userInput = userInput.Replace(Environment.NewLine, "");
            ShortCut wholeDayShortcut;

            userInput = this.PreProcessWholeDayExpansion(userInput, wdToFill.DateTime, out wholeDayShortcut);
            bool ignoreBreakSettings = userInput.StartsWith(automaticPauseDeactivation);

            if (ignoreBreakSettings)
            {
                userInput = userInput.Substring(2);
            }
            WorkDayParserResult ret = new WorkDayParserResult();

            if (!String.IsNullOrEmpty(userInput))
            {
                TimeItem dayStartTime;
                string   remainingString;
                string   error;
                // should be like "<daystarttime>,..."
                // eg 7,... or 7:30,...

                if (this.ForceDurationToZero(userInput))
                {
                    ret.Success = true;
                }
                else if (this.GetDayStartTime(userInput, out dayStartTime, out remainingString, out error))
                {
                    // proceed with parsing items
                    var parts           = remainingString.SplitWithIgnoreRegions(new[] { itemSeparator }, new IgnoreRegion('(', ')'));
                    var wdItemsAsString = parts.Where(p => !string.IsNullOrWhiteSpace(p)).ToList();
                    if (wdItemsAsString.Any())
                    {
                        List <WorkItemTemp> tmpList = new List <WorkItemTemp>();
                        foreach (var wdItemString in wdItemsAsString)
                        {
                            WorkItemTemp workItem;
                            if (this.GetWDTempItem(wdItemString, out workItem, out error, wdToFill.DateTime, wholeDayShortcut))
                            {
                                tmpList.Add(workItem);
                            }
                            else
                            {
                                ret.Error   = error;
                                ret.Success = false;
                                // todo: fail fast??
                            }
                        }
                        IEnumerable <WorkItem> resultList;
                        if (this.ProcessTempWorkItems(dayStartTime, tmpList, ignoreBreakSettings, out resultList, out error))
                        {
                            wdToFill.Clear();
                            foreach (var workItem in resultList)
                            {
                                wdToFill.AddWorkItem(workItem);
                            }
                            ret.Success = true;
                        }
                        else
                        {
                            ret.Error = error;
                        }
                    }
                    else
                    {
                        // this is no error for now
                        ret.Success = true;
                        ret.Error   = "Noch keine Einträge gemacht";
                    }
                }
                else
                {
                    ret.Error = error;
                }
            }
            else
            {
                ret.Error = "Noch keine Eingabe";
            }
            return(ret);
        }
예제 #25
0
 public void WDParser_UseAbbreviationsAndDesc_ExpandAbbreviationsAndOverwriteDescFromAbbr()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     var abbr = new List<ShortCut>();
     abbr.Add(new ShortCut("ctb", "11111-111(donotuseme)"));
     abbr.Add(new ShortCut("ktl", "22222-222(useme)"));
     WorkDayParserSettings workDayParserSettings = new WorkDayParserSettings { ShortCuts = abbr };
     WorkDayParser wdp = new WorkDayParser(workDayParserSettings);
     var workItemParserResult = wdp.Parse("9:00,2;ctb(useme),2;ktl", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] { new WorkItem(new TimeItem(9, 0), new TimeItem(11, 0), "11111", "111", "useme", null, string.Empty), new WorkItem(new TimeItem(11, 0), new TimeItem(13, 0), "22222", "222", "useme", null, string.Empty) }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
 }
예제 #26
0
 public void WDParser_SetEmptyStringAfterSuccessfulParsing_DeleteItems()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParser wdp = new WorkDayParser();
     var workItemParserResult = wdp.Parse("7,2;11111", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] { new WorkItem(new TimeItem(7, 0), new TimeItem(9, 0), "11111", string.Empty) }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
     wd.OriginalString = string.Empty;
     CollectionAssert.IsEmpty(wd.Items);
     Assert.AreEqual(0, wd.HoursDuration);
 }
예제 #27
0
 public void WDParser_InsteadOfHoursICanTellAnEndTime_UseEndTime()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     var abbr = new List<ShortCut>();
     abbr.Add(new ShortCut("ctb", "11111-111"));
     abbr.Add(new ShortCut("ktl", "22222-222"));
     WorkDayParserSettings workDayParserSettings = new WorkDayParserSettings { ShortCuts = abbr };
     WorkDayParser wdp = new WorkDayParser(workDayParserSettings);
     var workItemParserResult = wdp.Parse("9:00,-12;ctb,-15;ktl", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] { new WorkItem(new TimeItem(9, 0), new TimeItem(12, 0), "11111", "111"), new WorkItem(new TimeItem(12, 0), new TimeItem(15, 0), "22222", "222") }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
 }
예제 #28
0
 public void WDParser_ShortcutLinkInWorkItem_WholeDayShortcut()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     var abbr = new List<ShortCut>();
     var shortCut = new ShortCut("a", "8,8;11111-111(aa)") { WholeDayExpansion = true };
     abbr.Add(shortCut);
     WorkDayParserSettings workDayParserSettings = new WorkDayParserSettings { ShortCuts = abbr };
     WorkDayParser wdp = new WorkDayParser(workDayParserSettings);
     var workItemParserResult = wdp.Parse("a", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] {
         new WorkItem(new TimeItem(8), new TimeItem(16), "11111", "111", "aa")
     }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
     Assert.AreEqual(8, wd.HoursDuration);
     Assert.AreEqual(shortCut, wd.Items.First().ShortCut);
 }
예제 #29
0
 public void WDParser_SingleItemWithOddDayStartTime_ReturnWorkItemWithOneItem()
 {
     WorkDay wd = new WorkDay(1, 1, 1, null);
     WorkDayParser wdp = new WorkDayParser();
     var workItemParserResult = wdp.Parse("7:30,2;11111-111", ref wd);
     Assert.IsTrue(workItemParserResult.Success, workItemParserResult.Error);
     CollectionAssert.IsNotEmpty(wd.Items);
     CollectionAssert.AreEqual(new[] { new WorkItem(new TimeItem(7, 30), new TimeItem(9, 30), "11111", "111") }, wd.Items);
     Assert.IsEmpty(workItemParserResult.Error);
 }
예제 #30
0
파일: WorkWeek.cs 프로젝트: vipwolf/moni
 public void AddDay(WorkDay wd)
 {
     this.days.Add(wd);
       wd.PropertyChanged += this.WDPropertyChanged;
 }
예제 #31
0
파일: MainViewModel.cs 프로젝트: dotob/moni
 public void AddCurrentTime(WorkDay currentDay)
 {
     currentDay.OriginalString = WorkDayParser.Instance.AddCurrentTime(currentDay.OriginalString);
 }