public void TimeEntryDurationValidationTest() { // Prepare the time entries for test purposes. DateTime dateTime = DateTime.Today; msdyn_timeentry timeEntry1 = new msdyn_timeentry(); timeEntry1.msdyn_timeentryId = new Guid(); timeEntry1.msdyn_description = "entry 1"; timeEntry1.msdyn_date = dateTime; timeEntry1.msdyn_duration = 20 * 60; // 20 hours. msdyn_timeentry timeEntry2 = new msdyn_timeentry(); timeEntry2.msdyn_timeentryId = new Guid(); timeEntry2.msdyn_description = "entry 2"; timeEntry2.msdyn_date = dateTime; timeEntry2.msdyn_duration = 4 * 60 + 1; // 4 hours and 1 minute. TimeViewModel entry = new TimeViewModel(timeEntry1); TimeCollectionViewModel viewModel = new TimeCollectionViewModel(); viewModel.AddTimeEntries(new msdyn_timeentry[] { timeEntry1, timeEntry2 }); Assert.IsFalse(entry.CanTimeBeSaved(timeEntry1), "The time entry should not be able to save since the total duration is 24:01"); timeEntry1.msdyn_duration = 19 * 60 + 59; // 19 hours and 59 minutes. Assert.IsTrue(entry.CanTimeBeSaved(timeEntry1), "The time entry should be able to save since the total duration is 24:00"); }