예제 #1
0
        /// <summary>
        /// Creates a new TimeReport instance.
        /// </summary>
        /// <param name="tracker">Time tracker instance.</param>
        public TimeReport(TimeTracker timeTracker)
        {
            InitializeComponent();
              FormClosing += new FormClosingEventHandler(MainFormClosing);

              _timeTracker = timeTracker;

              // The start labels are only used for helping in layout design
              _lblTimeStart.Visible = false;
              _lblTextStart.Visible = false;

              EVENT_LABEL_HEIGHT = _lblTextCurrent.Top - _lblTextStart.Top;
              FORM_INITIAL_HEIGHT = Height;
        }
 /// <summary>
 /// Restores the application settings.
 /// </summary>
 private void RestoreSettings()
 {
     _timeTracker = new TimeTracker(Settings.Default.TimeTrackerStartTime);
 }
예제 #3
0
 /// <summary>
 /// Adds an event and checks that the last time period has expected values.
 /// </summary>
 /// <param name="tracker">Time tracker to test.</param>
 /// <param name="type">Type of event to add.</param>
 private void CheckLastPeriod(TimeTracker tracker,
                          TrackableEvent.EventType type)
 {
     TrackableEvent previousEvent = tracker.LastEvent;
       AddEvent(tracker, type, new TimeSpan(0, 1, 0));
       TimePeriod period = tracker.LastCompletedTimePeriod;
       TimePeriod.PeriodType expectedType = TimeTracker.GetPeriodTypeFromEvent(previousEvent.Activity);
       Assert.That(period.Type, Is.EqualTo(expectedType));
       Assert.That(period.Duration,
           Is.EqualTo(tracker.LastEvent.Time.Subtract(previousEvent.Time)));
 }
예제 #4
0
        /// <summary>
        /// Adds a trackable event to the tracker and verifies that it matches the
        /// last event in the tracker.
        /// </summary>
        /// <param name="tracker">Time tracker to test.</param>
        /// <param name="type">Type of event to add.</param>
        /// <param name="delay">Delay of the new event since the previous event.</param>
        private void AddEvent(TimeTracker tracker,
                          TrackableEvent.EventType type, TimeSpan delay)
        {
            Console.WriteLine(String.Format("Adding {0} after {1}", type, delay));

              // Add delay to last event time
              int eventCount = tracker.GetEvents().Count;
              DateTime time = tracker.GetEvents()[eventCount - 1].Time.Add(delay);

              // Add and verify the event
              tracker.AddEvent(new TrackableEvent(type, time));
              Assert.That(tracker.GetEvents().Count, Is.EqualTo(++eventCount));
              TrackableEvent lastEvent = tracker.LastEvent;
              Assert.That(lastEvent.Type, Is.EqualTo(type));
              Assert.That(lastEvent.Time, Is.EqualTo(time));
        }
예제 #5
0
 public void AddEvents()
 {
     TimeTracker tracker = new TimeTracker(new SystemClock().Now);
       AddEvent(tracker, TrackableEvent.EventType.Lock, new TimeSpan(0, 5, 0));
       AddEvent(tracker, TrackableEvent.EventType.Unlock, new TimeSpan(1, 5, 0));
 }
예제 #6
0
 public void CheckWorkTime()
 {
     DateTime startTime = new SystemClock().Now;
       TimeTracker tracker = new TimeTracker(startTime);
       TimeSpan workTime = new TimeSpan(1, 2, 3);
       Assert.That(tracker.GetWorkTime(startTime.Add(workTime)), Is.EqualTo(workTime));
 }
예제 #7
0
 public void CheckStartTime()
 {
     DateTime now = new SystemClock().Now;
       TimeTracker tracker = new TimeTracker(now);
       Console.WriteLine("Checking start time " + now);
       Assert.That(tracker.StartTime, Is.EqualTo(now));
       Assert.That(tracker.FirstEvent.Time, Is.EqualTo(now));
       Assert.That(tracker.FirstEvent.Type, Is.EqualTo(TrackableEvent.EventType.Start));
 }