Example #1
0
 /// <summary>
 ///     Try to parse event's title to find indication of how long is the event. This method does not process all-day
 ///     events.
 ///     If such information is found and considered reliable, event's EndDate is set based on StartDate and found event
 ///     duration.
 /// </summary>
 private void PredictEventDuration(bool removeEventDurationFromTitle)
 {
     foreach (VEvent evnt in calendar.VCalendar.Events)
     {
         if (evnt.IsAllDayEvent())
         {
             continue;
         }
         EventLengthFinder elf = new EventLengthFinder(evnt.Summary.Value);
         if (elf.PatternFound)
         {
             evnt.EndDateTime.DateTimeValue = evnt.StartDateTime.DateTimeValue.AddMinutes(elf.TotalMinutes);
             if (removeEventDurationFromTitle)
             {
                 evnt.Summary.Value = elf.TaskSummaryWithoutPattern;
             }
         }
     }
 }
Example #2
0
    public void RegexShouldNotMatch4()
    {
        EventLengthFinder elf = new EventLengthFinder("Check Philippians 4:11 - 4:12");

        Assert.IsFalse(elf.PatternFound);
    }
Example #3
0
    public void RegexShouldMatch5()
    {
        EventLengthFinder elf = new EventLengthFinder("Play drums (2h 30 min) @home");

        Assert.IsTrue(elf.PatternFound);
    }
Example #4
0
    public void CutRegex4()
    {
        EventLengthFinder elf = new EventLengthFinder("Meditate 0.5h @home");

        Assert.AreEqual("Meditate @home", elf.TaskSummaryWithoutPattern);
    }
Example #5
0
    public void RegexShouldMatch4()
    {
        EventLengthFinder elf = new EventLengthFinder("Meditate 0.5h @home");

        Assert.IsTrue(elf.PatternFound);
    }
Example #6
0
    public void CalculateTime3()
    {
        EventLengthFinder elf = new EventLengthFinder("Exercise @gym 1 H");

        Assert.AreEqual(60, elf.TotalMinutes);
    }
Example #7
0
    public void CutRegex2()
    {
        EventLengthFinder elf = new EventLengthFinder("@home Read for 45 minutes");

        Assert.AreEqual("@home Read for", elf.TaskSummaryWithoutPattern);
    }
Example #8
0
    public void RegexShouldMatch2()
    {
        EventLengthFinder elf = new EventLengthFinder("@home Read for 45 minutes");

        Assert.IsTrue(elf.PatternFound);
    }
Example #9
0
    public void RegexShouldMatch8()
    {
        EventLengthFinder elf = new EventLengthFinder("Some short thing [5m]");

        Assert.IsTrue(elf.PatternFound);
    }
Example #10
0
    public void CutRegex6()
    {
        EventLengthFinder elf = new EventLengthFinder("Czas po polsku (5 minut) @home");

        Assert.AreEqual("Czas po polsku @home", elf.TaskSummaryWithoutPattern);
    }
Example #11
0
    public void CalculateTime6()
    {
        EventLengthFinder elf = new EventLengthFinder("Czas po polsku (5 minut) @home");

        Assert.AreEqual(5, elf.TotalMinutes);
    }
Example #12
0
    public void RegexShouldMatch6()
    {
        EventLengthFinder elf = new EventLengthFinder("Czas po polsku (5 minut) @home");

        Assert.IsTrue(elf.PatternFound);
    }
Example #13
0
    public void CutRegex5()
    {
        EventLengthFinder elf = new EventLengthFinder("Play drums (2h 30 min) @home");

        Assert.AreEqual("Play drums @home", elf.TaskSummaryWithoutPattern);
    }
Example #14
0
    public void CalculateTime5()
    {
        EventLengthFinder elf = new EventLengthFinder("Play drums (2h 30 min) @home");

        Assert.AreEqual(2 * 60 + 30, elf.TotalMinutes);
    }
Example #15
0
 public void NoTimeSpecified1()
 {
     EventLengthFinder elf = new EventLengthFinder("No time specified in this string");
     int totalMinutes      = elf.TotalMinutes;
 }
Example #16
0
    public void CutRegex1()
    {
        EventLengthFinder elf = new EventLengthFinder("Review english lesson @home 20m");

        Assert.AreEqual("Review english lesson @home", elf.TaskSummaryWithoutPattern);
    }
Example #17
0
    public void CalculateTime1()
    {
        EventLengthFinder elf = new EventLengthFinder("Review english lesson @home 20m");

        Assert.AreEqual(20, elf.TotalMinutes);
    }
Example #18
0
    public void CalculateTime2()
    {
        EventLengthFinder elf = new EventLengthFinder("@home Read for 45 minutes");

        Assert.AreEqual(45, elf.TotalMinutes);
    }
Example #19
0
    public void CalculateTime8()
    {
        EventLengthFinder elf = new EventLengthFinder("Some short thing [5m]");

        Assert.AreEqual(elf.TotalMinutes, 5);
    }
Example #20
0
    public void RegexShouldMatch3()
    {
        EventLengthFinder elf = new EventLengthFinder("Exercise @gym 1 H");

        Assert.IsTrue(elf.PatternFound);
    }
Example #21
0
    public void CutRegex8()
    {
        EventLengthFinder elf = new EventLengthFinder("Some short thing [5m]");

        Assert.AreEqual(elf.TaskSummaryWithoutPattern, "Some short thing");
    }
Example #22
0
    public void CutRegex3()
    {
        EventLengthFinder elf = new EventLengthFinder("Exercise @gym 1 H");

        Assert.AreEqual("Exercise @gym", elf.TaskSummaryWithoutPattern);
    }
Example #23
0
    public void RegexShouldNotMatch1()
    {
        EventLengthFinder elf = new EventLengthFinder("@market Buy a car");

        Assert.IsFalse(elf.PatternFound);
    }
Example #24
0
    public void CalculateTime4()
    {
        EventLengthFinder elf = new EventLengthFinder("Meditate 0.5h @home");

        Assert.AreEqual(30, elf.TotalMinutes);
    }
Example #25
0
    public void RegexShouldNotMatch2()
    {
        EventLengthFinder elf = new EventLengthFinder("Buy 3 milk bottles @market");

        Assert.IsFalse(elf.PatternFound);
    }
Example #26
0
    public void RegexShouldNotMatch3()
    {
        EventLengthFinder elf = new EventLengthFinder("123 45 6");

        Assert.IsFalse(elf.PatternFound);
    }
Example #27
0
    public void RegexShouldMatch1()
    {
        EventLengthFinder elf = new EventLengthFinder("Review english lesson @home 20m");

        Assert.IsTrue(elf.PatternFound);
    }