public void SetDefaultValuesOnlyWorksOnNewEntries() { msdyn_timeentry timeEntry = new msdyn_timeentry(); TimeViewModel entry = new TimeViewModel(timeEntry); timeEntry.Id = Guid.NewGuid(); entry.SetDefaultValues(); Assert.IsNull(timeEntry.msdyn_date); Assert.IsNull(timeEntry.msdyn_duration); Assert.IsNull(timeEntry.msdyn_type); Assert.IsNull(timeEntry.msdyn_entryStatus); }
public void CanEditTimeEntryTest() { msdyn_timeentry timeEntry = new msdyn_timeentry(); TimeViewModel entry = new TimeViewModel(timeEntry); Assert.IsTrue(entry.CanEdit(), "A time entry that hasn't been saved (has null values) should be editable."); timeEntry.Id = Guid.NewGuid(); entry.SetDefaultValues(); Assert.IsTrue(entry.CanEdit(), "A time entry that has been saved with values should be editable."); timeEntry.msdyn_entryStatus = new OptionSetValue((int)msdyn_timeentry_msdyn_entrystatus.Submitted); Assert.IsFalse(entry.CanEdit(), "A time entry that has been submitted with values should be editable."); }
public void SetDefaultValuesTest() { msdyn_timeentry timeEntry = new msdyn_timeentry(); TimeViewModel entry = new TimeViewModel(timeEntry); DateTime todayUTC = DateTime.Today; entry.SetDefaultValues(); // validate entry data Assert.AreEqual(new DateTime(todayUTC.Year, todayUTC.Month, todayUTC.Day, 12, 0, 0), timeEntry.msdyn_date, "Incorrect default date of noon today."); Assert.AreEqual(60, timeEntry.msdyn_duration, "Incorrect default duration"); Assert.AreEqual((int)msdyn_timeentrytype.Work, timeEntry.msdyn_type.Value, "Incorrect default time entry type"); Assert.AreEqual((int)msdyn_timeentry_msdyn_entrystatus.Draft, timeEntry.msdyn_entryStatus.Value, "Incorrect default time entry status"); }
/// <summary> /// Load reference data and set defaults /// </summary> /// <returns></returns> protected override async System.Threading.Tasks.Task LoadData() { await ViewModel.LoadReferenceData(); ViewModel.SetDefaultValues(); }