예제 #1
0
        public void IsOccuringOnTest()
        {
            // Get input data for test.
            var startYear    = int.Parse(TestContext.DataRow["startYear"].ToString());
            var startMonth   = int.Parse(TestContext.DataRow["startMonth"].ToString());
            var startDay     = int.Parse(TestContext.DataRow["startDay"].ToString());
            var startHours   = int.Parse(TestContext.DataRow["startHours"].ToString());
            var startMinutes = int.Parse(TestContext.DataRow["startMinutes"].ToString());

            var endYear    = int.Parse(TestContext.DataRow["endYear"].ToString());
            var endMonth   = int.Parse(TestContext.DataRow["endMonth"].ToString());
            var endDay     = int.Parse(TestContext.DataRow["endDay"].ToString());
            var endHours   = int.Parse(TestContext.DataRow["endHours"].ToString());
            var endMinutes = int.Parse(TestContext.DataRow["endMinutes"].ToString());

            var durationMinutes = int.Parse(TestContext.DataRow["durationMinutes"].ToString());

            // Create appointment and exercise the method under test.
            var expectedStartDate = new Date(startDay, (Date.Month)startMonth, startYear);
            var appointmentTime   = new Diary.DateTime(expectedStartDate, startHours, startMinutes);
            var appointment       = (Appointment) new AppointmentBuilder().SetOccurs(appointmentTime).SetDurationMinutes(durationMinutes).Build();
            var expectedEndDate   = new Date(endDay, (Date.Month)endMonth, endYear);

            CalendarEventTest.IsOccuringOnTest(appointment, expectedStartDate, expectedEndDate);
        }
예제 #2
0
        public void IsOccuringOnTest()
        {
            // Get input occurence data for test.
            var firstOccursYear    = int.Parse(TestContext.DataRow["firstOccursYear"].ToString());
            var firstOccursMonth   = int.Parse(TestContext.DataRow["firstOccursMonth"].ToString());
            var firstOccursDay     = int.Parse(TestContext.DataRow["firstOccursDay"].ToString());
            var firstOccursHours   = int.Parse(TestContext.DataRow["firstOccursHours"].ToString());
            var firstOccursMinutes = int.Parse(TestContext.DataRow["firstOccursMinutes"].ToString());

            var notToExceedYear    = int.Parse(TestContext.DataRow["notToExceedYear"].ToString());
            var notToExceedMonth   = int.Parse(TestContext.DataRow["notToExceedMonth"].ToString());
            var notToExceedDay     = int.Parse(TestContext.DataRow["notToExceedDay"].ToString());
            var notToExceedHours   = int.Parse(TestContext.DataRow["notToExceedHours"].ToString());
            var notToExceedMinutes = int.Parse(TestContext.DataRow["notToExceedMinutes"].ToString());

            var durationMinutes = int.Parse(TestContext.DataRow["durationMinutes"].ToString());
            var periodHours     = int.Parse(TestContext.DataRow["periodHours"].ToString());

            // Create the periodic appointment, deriving the overall start and end date
            var firstOccurs         = new Diary.DateTime(new Date(firstOccursDay, (Date.Month)firstOccursMonth, firstOccursYear), firstOccursHours, firstOccursMinutes);
            var notToExceedDateTime = new Diary.DateTime(new Date(notToExceedDay, (Date.Month)notToExceedMonth, notToExceedYear), notToExceedHours, notToExceedMinutes);

            PeriodicAppointmentBuilder builder = new PeriodicAppointmentBuilder();

            builder.SetOccurs(firstOccurs);
            builder.SetDurationMinutes(durationMinutes);
            builder.SetNotToExceedDateTime(notToExceedDateTime);
            builder.SetPeriodHours(periodHours);
            var appointment = (PeriodicAppointment)builder.Build();

            // Look up and evaluate each occurence
            DataRow[] occurencesRows = TestContext.DataRow.GetChildRows("add_occurences");

            foreach (DataRow occurenceRow in occurencesRows)
            {
                DataRow[] occurenceDatePartRows = occurenceRow.GetChildRows("occurences_occurence");
                foreach (DataRow occurenceDatePart in occurenceDatePartRows)
                {
                    var startYear  = int.Parse(occurenceDatePart["startYear"].ToString());
                    var startMonth = int.Parse(occurenceDatePart["startMonth"].ToString());
                    var startDay   = int.Parse(occurenceDatePart["startDay"].ToString());

                    var endYear  = int.Parse(occurenceDatePart["endYear"].ToString());
                    var endMonth = int.Parse(occurenceDatePart["endMonth"].ToString());
                    var endDay   = int.Parse(occurenceDatePart["endDay"].ToString());

                    var expectedStartDate = new Date(startDay, (Date.Month)startMonth, startYear);
                    var expectedEndDate   = new Date(endDay, (Date.Month)endMonth, endYear);

                    CalendarEventTest.IsOccuringOnTest(appointment, expectedStartDate, expectedEndDate);
                }
            }
        }
예제 #3
0
파일: Helper.cs 프로젝트: cheriephi/diary
        /// <summary>
        /// Tests all Reminder fields match the expected values.
        /// </summary>
        internal static void AssertAreEqual(ReminderBuilder expected, Reminder actual, string message)
        {
            var messagePrefix = String.Format("{0} Label:<{1}>.", message, expected.GetLabel());

            Assert.AreEqual(expected.GetDetails(), actual.GetDetails(), String.Concat(messagePrefix, " details"));
            Assert.AreEqual(false, actual.IsRepeating(), String.Concat(messagePrefix, " IsRepeating"));
            Assert.AreEqual(expected.GetLabel(), actual.GetLabel(), String.Concat(messagePrefix, " label"));

            var expectedClassId = new ClassId("Reminder");

            Assert.AreEqual(0, actual.GetClassId().CompareTo(expectedClassId), String.Concat(messagePrefix, " classId"));

            // Test the Reminder.Date; which is exposed through the IsOccuringOn method.
            CalendarEventTest.IsOccuringOnTest(actual, expected.GetDate(), expected.GetDate());
        }