Пример #1
0
        public void AddRecordToTimeLog()
        {
            ITimeSystem mockSystem = NewMock<ITimeSystem>();
            Expect.Exactly(2).On(mockSystem).GetProperty("Now").Will(Return.Value(startTime));
            ITimeLog mockTimeLog = NewMock<ITimeLog>();
            Stub.On(timeLogsManager).GetProperty("ActiveTimeLog").Will(Return.Value(mockTimeLog));
            timeManager = new TimeManager(mockSystem, timeLogsManager);
            Expect.Once.On(mockTimeLog).Method("AddActivity").With(timeManager.CurrentActivity);

            timeManager.FinishActivity("first", "second");

            VerifyAllExpectationsHaveBeenMet();
        }
Пример #2
0
        public void CurrentActivityDuration()
        {
            TimeSpan duration = TimeSpan.FromMinutes(15);
            DateTime endTime = startTime + duration;
            ITimeSystem timeSystem = NewMock<ITimeSystem>();
            using (Ordered)
            {
                Expect.Once.On(timeSystem).GetProperty("Now").Will(Return.Value(startTime));
                Expect.Once.On(timeSystem).GetProperty("Now").Will(Return.Value(endTime));
            }

            timeManager = new TimeManager(timeSystem);

            Assert.AreEqual(duration, timeManager.CurrentActivity.Duration);
        }
Пример #3
0
 public void CurrentActivityIsLastingTooLongIsFalseBeforeAnHourOfInactivity()
 {
     ITimeSystem timeSystem = NewMock<ITimeSystem>();
     using (Ordered)
     {
         Expect.Once.On(timeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("5:00:00")));
         Expect.AtLeastOnce.On(timeSystem).GetProperty("Now").Will(Return.Value(DateTime.Parse("5:59:59")));
     }
     timeManager = new TimeManager(timeSystem);
     Assert.IsFalse(timeManager.CurrentActivityIsLastingTooLong);
 }
Пример #4
0
        public void SwitchAtMidnightWithoutTimeLogsManager()
        {
            ITimeSystem mockTime = NewMock<ITimeSystem>();
            using (Ordered)
            {
                Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-07 23:59:55")));
                Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-08 0:00:06")));
            }
            timeManager = new TimeManager(mockTime);

            timeManager.SwitchTo("second");
        }
Пример #5
0
        public void SwitchAtMidnightFalse()
        {
            ITimeSystem mockTime = NewMock<ITimeSystem>();
            using (Ordered)
            {
                Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-07 23:59:55")));
                Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-08 0:00:06")));
            }
            ITimeLogsManager timeLogsManager = NewMock<ITimeLogsManager>();
            ITimeLog timeLog1 = NewMock<ITimeLog>();
            Expect.Once.On(timeLog1).Method("AddActivity").With(new Activities.Activity("first", DateTime.Parse("2008-08-07 23:59:55"), TimeSpan.Parse("0:00:11")));
            Expect.Once.On(timeLogsManager).Method("ActivateTimeLog").With(DateTime.Parse("2008-08-07"));
            Stub.On(timeLogsManager).GetProperty("ActiveTimeLog").Will(Return.Value(timeLog1));
            timeManager = new TimeManager(mockTime, timeLogsManager);
            var midnightCorrector = NewMock<IMidnightCorrector>();
            timeManager.MidnightCorrector = midnightCorrector;
            Expect.Never.On(midnightCorrector).Method("PerformMidnightCorrection");
            timeManager.SwitchAtMidnight = false;
            timeManager.FinishActivity("first", "second");

            VerifyAllExpectationsHaveBeenMet();
        }
Пример #6
0
 public void SplitByCommaAtMidnight()
 {
     ITimeSystem mockTime = NewMock<ITimeSystem>();
     using (Ordered)
     {
         Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-07 23:59:55")));
         Expect.Once.On(mockTime).GetProperty("Now").Will(Return.Value(DateTime.Parse("2008-08-08 0:00:15")));
     }
     ITimeLog timeLog = NewMock<ITimeLog>();
     Stub.On(timeLogsManager).GetProperty("ActiveTimeLog").Will(Return.Value(timeLog));
     using (Ordered)
     {
         Expect.Once.On(timeLog).Method("AddActivity").With(new Activity("first", DateTime.Parse("2008-08-07 23:59:55"), TimeSpan.Parse("0:00:05")));
         Expect.Once.On(timeLog).Method("AddActivity").With(new Activity("first", DateTime.Parse("2008-08-08 0:00:00"), TimeSpan.Parse("0:00:05")));
         Expect.Once.On(timeLog).Method("AddActivity").With(new Activity("second", DateTime.Parse("2008-08-08 0:00:05"), TimeSpan.Parse("0:00:10")));
     }
     timeManager = new TimeManager(mockTime, timeLogsManager);
     timeManager.SwitchAtMidnight = true;
     timeManager.SplitByComma = true;
     timeManager.FinishActivity("first,second", "next");
     VerifyAllExpectationsHaveBeenMet();
 }
Пример #7
0
 public void SetUp()
 {
     ITimeSystem mockTime = NewMock<ITimeSystem>();
     Stub.On(mockTime).GetProperty("Now").Will(Return.Value(startTime));
     timeLogsManager = NewMock<ITimeLogsManager>();
     timeLog = NewMock<ITimeLog>();
     Stub.On(timeLogsManager).Method("ActivateTimeLog").Will(Return.Value(timeLog));
     timeManager = new TimeManager(mockTime, timeLogsManager);
 }
Пример #8
0
        public void FinishActivityUseNowOnce()
        {
            ITimeSystem mockSystem = NewMock<ITimeSystem>();
            Expect.Exactly(2).On(mockSystem).GetProperty("Now").Will(Return.Value(startTime));
            timeManager = new TimeManager(mockSystem);

            timeManager.FinishActivity("activityName", "second");

            VerifyAllExpectationsHaveBeenMet();
        }