Ejemplo n.º 1
0
        public void LoadTimesFromMultipleDays()
        {
            DateTime dateTime1 = new DateTime(2015, 7, 28, 9, 58, 0);
            DateTime dateTime2 = new DateTime(2014, 1, 22, 23, 19, 0);

            msdyn_timeentry timeEntry1 = new msdyn_timeentry();

            timeEntry1.msdyn_timeentryId = new Guid();
            timeEntry1.msdyn_description = "entry 1";
            timeEntry1.msdyn_date        = dateTime1;
            timeEntry1.msdyn_duration    = 2;

            msdyn_timeentry timeEntry2 = new msdyn_timeentry();

            timeEntry2.msdyn_timeentryId = new Guid();
            timeEntry2.msdyn_description = "entry 2";
            timeEntry2.msdyn_date        = dateTime2;
            timeEntry2.msdyn_duration    = 2;

            TimeCollectionViewModel viewModel = new TimeCollectionViewModel();

            viewModel.AddTimeEntries(new msdyn_timeentry[] { timeEntry1, timeEntry2 });

            // Validate
            IEnumerable <TimeCollection> days = viewModel.Days;

            Assert.AreEqual(2, days.Count(), "Incorrect number of days");
        }
Ejemplo n.º 2
0
        public void ClearRemovesAllDays()
        {
            DateTime dateTime1 = new DateTime(2015, 7, 28, 9, 58, 0);
            DateTime dateTime2 = new DateTime(2014, 1, 22, 23, 19, 0);

            msdyn_timeentry timeEntry1 = new msdyn_timeentry();

            timeEntry1.msdyn_timeentryId = new Guid();
            timeEntry1.msdyn_description = "entry 1";
            timeEntry1.msdyn_date        = dateTime1;
            timeEntry1.msdyn_duration    = 2;

            msdyn_timeentry timeEntry2 = new msdyn_timeentry();

            timeEntry2.msdyn_timeentryId = new Guid();
            timeEntry2.msdyn_description = "entry 2";
            timeEntry2.msdyn_date        = dateTime2;
            timeEntry2.msdyn_duration    = 2;

            TimeCollectionViewModel viewModel = new TimeCollectionViewModel();

            viewModel.AddTimeEntries(new msdyn_timeentry[] { timeEntry1, timeEntry2 });

            viewModel.ClearTimes();
            Assert.AreEqual(0, viewModel.Days.Count);
        }
Ejemplo n.º 3
0
        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");
        }