public void ValidDaily() { string rule = "FREQ=DAILY;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(RecurrenceType.Daily, props.RecurrenceType); }
/// <summary> /// Convert the specified properties into a Recurrence Rule. /// </summary> /// <returns>A recurrence rule. On conversion error: return null, HasError and ErrorMessage are set</returns>> /// <param name="properties">Properties.</param> public string Convert(RecurrenceProperties properties) { ParsePropsToRule parser = new ParsePropsToRule(); string rule = parser.Convert(properties); HasError = parser.HasError; ErrorMessage = parser.ErrorMessage; return(rule); }
public void Monthly_ByDAY_BySetPOS_ByMonthDay() { string rule = "FREQ=Monthly;BYDAY=FR;BYSETPOS=4;BYMONTHDAY=15; "; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = converter.Convert(rule, startDate); Assert.AreEqual(true, converter.HasError); Assert.AreEqual("BYSETPOS/BYDAY or BYMONTHDAY should be set for Monthly, not both.", converter.ErrorMessage); }
public void NoByDay() { string rule = "FREQ=WEEKLY;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(true, parser.HasError); Assert.AreEqual("BYDAY should be set for Weekly", parser.ErrorMessage); }
public void Valid31() { string rule = "FREQ=MONTHLY;BYMONTHDAY=31;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(true, props.IsMonthlySpecific); Assert.AreEqual(31, props.DayOfMonth); }
public void NoIntervalWeekly() { string rule = "FREQ=Weekly;BYDAY=MO,TU,WE;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(RecurrenceType.Weekly, props.RecurrenceType); Assert.AreEqual(1, props.Interval); }
public void ValidMonthly3() { string rule = "FREQ=monthly;INTERVAL=3;BYMONTHDAY=15;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(RecurrenceType.Monthly, props.RecurrenceType); Assert.AreEqual(3, props.Interval); }
public void InValidMoByDay() { string rule = "FREQ=MONTHLY;BYSETPOS=1;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(true, parser.HasError); StringAssert.Contains("BYDAY or BYMONTHDAY should be set for Monthly", parser.ErrorMessage); }
public void InValidNegative() { string rule = "FREQ=MONTHLY;BYSETPOS=-31;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(true, parser.HasError); StringAssert.Contains("BYSETPOS has non valid value ", parser.ErrorMessage); }
public void ValidYearly4() { string rule = "FREQ=YEARLY;INTERVAL=4;ByMonth=3;ByDay=FR;BySetPos=3;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(RecurrenceType.Yearly, props.RecurrenceType); Assert.AreEqual(4, props.Interval); }
public void InvalidWeekDay() { string rule = "FREQ=WEEKLY;BYDAY=MA"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(true, parser.HasError); StringAssert.Contains("BYDAY has non valid value ", parser.ErrorMessage); }
public void ValidWeekly2() { string rule = "FREQ=Weekly;INTERVAL=2;BYDAY=TH;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(RecurrenceType.Weekly, props.RecurrenceType); Assert.AreEqual(2, props.Interval); }
/// <summary> /// Convert the specified rule and startDate into a recurrence property object. /// </summary> /// <returns>A recurrence property object. On conversion error: return null, HasError and ErrorMessage are set</returns> /// <param name="rule">Rule.</param> /// <param name="startDate">Start date.</param> public RecurrenceProperties Convert(string rule, DateTime startDate) { ParseRuleToProps parser = new ParseRuleToProps(); RecurrenceProperties props = parser.Convert(rule, startDate); HasError = parser.HasError; ErrorMessage = parser.ErrorMessage; return(props); }
public void InvalidNegative1() { string rule = "FREQ=DAily;INTERVAL=-1;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(true, parser.HasError); StringAssert.Contains("INTERVAL has non valid value ", parser.ErrorMessage); }
public void Valid1() { string rule = "FREQ=MONTHLY;BYSETPOS=1;BYDAY=SU;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(1, props.Week); Assert.AreEqual(0, props.DayOfWeek); }
public void Valid15() { string rule = "FREQ=YEARLY;BYMONTH=9;BYMONTHDAY=15;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(false, props.IsMonthlySpecific); Assert.AreEqual(15, props.DayOfMonth); }
public void InValid() { string rule = "FREQ=YEARLY;BYMONTHDAY=wrong#;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(true, parser.HasError); StringAssert.Contains("BYMONTHDAY has non valid value ", parser.ErrorMessage); }
public void NoBYMONTHDAY() { string rule = "FREQ=YEARLY;BYMONTH=1;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(true, parser.HasError); Assert.AreEqual("BYSETPOS/BYDAY or BYMONTHDAY should be set for Yearly", parser.ErrorMessage); }
public void Daily() { string rule = "FREQ=DAILY;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = converter.Convert(rule, startDate); string ruleResult = converter.Convert(props); Assert.AreEqual("FREQ=DAILY;INTERVAL=1;", ruleResult); }
public void Valid6() { string rule = "FREQ=YEARLY;BYMONTH=6;BYDAY=SU; BYSETPOS=2;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(true, props.IsYearlySpecific); Assert.AreEqual(6, props.Month); }
//creating RecurrsiveAppointments private void CreateRecurrsiveAppointments() { RecurssiveAppointmentCollection = new ScheduleAppointmentCollection(); //Recurrence Appointment 1 ScheduleAppointment alternativeDayAppointment = new ScheduleAppointment(); DateTime currentDate = DateTime.Now; DateTime startTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 9, 0, 0); DateTime endTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 10, 0, 0); alternativeDayAppointment.StartTime = startTime; alternativeDayAppointment.EndTime = endTime; alternativeDayAppointment.Color = Color.FromHex("#FFA2C139"); alternativeDayAppointment.Subject = "Occurs every 2 days"; alternativeDayAppointment.IsRecursive = true; RecurrenceProperties recurrencePropertiesForAlternativeDay = new RecurrenceProperties(); recurrencePropertiesForAlternativeDay.RecurrenceType = RecurrenceType.Daily; recurrencePropertiesForAlternativeDay.IsDailyEveryNDays = true; recurrencePropertiesForAlternativeDay.DailyNDays = 2; recurrencePropertiesForAlternativeDay.IsRangeRecurrenceCount = true; recurrencePropertiesForAlternativeDay.IsRangeNoEndDate = false; recurrencePropertiesForAlternativeDay.IsRangeEndDate = false; recurrencePropertiesForAlternativeDay.RangeRecurrenceCount = 10; recurrencePropertiesForAlternativeDay.RecurrenceRule = "FREQ=DAILY;COUNT=10;INTERVAL=2"; alternativeDayAppointment.RecurrenceRule = recurrencePropertiesForAlternativeDay.RecurrenceRule; RecurssiveAppointmentCollection.Add(alternativeDayAppointment); //Recurrence Appointment 2 ScheduleAppointment weeklyAppointment = new ScheduleAppointment(); DateTime startTime1 = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 11, 0, 0); DateTime endTime1 = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 12, 0, 0); weeklyAppointment.StartTime = startTime1; weeklyAppointment.EndTime = endTime1; weeklyAppointment.Color = Color.FromHex("#FFD80073"); weeklyAppointment.Subject = "Occurs every monday"; weeklyAppointment.IsRecursive = true; RecurrenceProperties recurrencePropertiesForWeeklyAppointment = new RecurrenceProperties(); recurrencePropertiesForWeeklyAppointment.RecurrenceType = RecurrenceType.Weekly; recurrencePropertiesForWeeklyAppointment.IsRangeRecurrenceCount = true; recurrencePropertiesForWeeklyAppointment.WeeklyEveryNWeeks = 1; recurrencePropertiesForWeeklyAppointment.IsWeeklySunday = false; recurrencePropertiesForWeeklyAppointment.IsWeeklyMonday = true; recurrencePropertiesForWeeklyAppointment.IsWeeklyTuesday = false; recurrencePropertiesForWeeklyAppointment.IsWeeklyWednesday = false; recurrencePropertiesForWeeklyAppointment.IsWeeklyThursday = false; recurrencePropertiesForWeeklyAppointment.IsWeeklyFriday = false; recurrencePropertiesForWeeklyAppointment.IsWeeklySaturday = false; recurrencePropertiesForWeeklyAppointment.RangeRecurrenceCount = 10; recurrencePropertiesForWeeklyAppointment.RecurrenceRule = "FREQ=WEEKLY;COUNT=10;BYDAY=MO"; weeklyAppointment.RecurrenceRule = recurrencePropertiesForWeeklyAppointment.RecurrenceRule; RecurssiveAppointmentCollection.Add(weeklyAppointment); }
public void ValidDaily1() { string rule = "FREQ=DAILY;INTERVAL=1;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); Assert.AreEqual(RecurrenceType.Daily, props.RecurrenceType); Assert.AreEqual(true, props.IsDailyEveryNDays); Assert.AreEqual(1, props.Interval); }
public void ValidWeekly() { string rule = "FREQ=Weekly;INTERVAL=2;COUNT=4;UNTIL=20181231;BYDAY=WE;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); string ruleResult = converter.Convert(props); Assert.AreEqual("FREQ=WEEKLY;INTERVAL=2;UNTIL=20181231;BYDAY=WE;", ruleResult); }
public void Valid31() { string rule = "FREQ=MONTHLY;BYMONTHDAY=31;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); string ruleResult = converter.Convert(props); Assert.AreEqual("FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=31;", ruleResult); }
public void EveryDayExample3() { string rule = "FREQ=WEEKLY; BYDAY=MO, TU, WE, TH, FR; UNTIL=20170715"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = converter.Convert(rule, startDate); string ruleResult = converter.Convert(props); Assert.AreEqual("FREQ=WEEKLY;INTERVAL=1;UNTIL=20170715;BYDAY=MO,TU,WE,TH,FR;", ruleResult); }
public void Monthly() { string rule = "FREQ=Monthly;BYDAY=WE; BYSETPOS=4;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = converter.Convert(rule, startDate); string ruleResult = converter.Convert(props); Assert.AreEqual("FREQ=MONTHLY;INTERVAL=1;BYDAY=WE;BYSETPOS=4;", ruleResult); }
public void YearlyExample3() { string rule = "FREQ=YEARLY; BYMONTHDAY=12; BYMONTH=12; INTERVAL=1; UNTIL=20180611"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = converter.Convert(rule, startDate); string ruleResult = converter.Convert(props); Assert.AreEqual("FREQ=YEARLY;INTERVAL=1;UNTIL=20180611;BYMONTHDAY=12;BYMONTH=12;", ruleResult); }
public void MonthlyExample2() { string rule = "FREQ=MONTHLY; BYMONTHDAY=16; INTERVAL=1; COUNT=10"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = converter.Convert(rule, startDate); string ruleResult = converter.Convert(props); Assert.AreEqual("FREQ=MONTHLY;INTERVAL=1;COUNT=10;BYMONTHDAY=16;", ruleResult); }
public void WeeklyExample4() { string rule = "FREQ=WEEKLY; INTERVAL=2; BYDAY=MO, WE, FR; COUNT=10"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = converter.Convert(rule, startDate); string ruleResult = converter.Convert(props); Assert.AreEqual("FREQ=WEEKLY;INTERVAL=2;COUNT=10;BYDAY=MO,WE,FR;", ruleResult); }
public void NoIntervalWeekly() { string rule = "FREQ=Weekly;BYDAY=TU,WE;"; DateTime startDate = new DateTime(2018, 09, 01, 10, 0, 0); RecurrenceProperties props = parser.Convert(rule, startDate); string ruleResult = converter.Convert(props); Assert.AreEqual("FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,WE;", ruleResult); }