Пример #1
0
        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);
        }
Пример #2
0
        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.");
        }
Пример #3
0
        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");
        }
Пример #4
0
        /// <summary>
        /// Load reference data and set defaults
        /// </summary>
        /// <returns></returns>
        protected override async System.Threading.Tasks.Task LoadData()
        {
            await ViewModel.LoadReferenceData();

            ViewModel.SetDefaultValues();
        }