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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
public void CurrentActivityDiffersFromFinished() { timeManager.TimeLogsManager = null; timeManager.FinishActivity("prev", "second"); Assert.AreNotSame(timeManager.PreviousActivity, timeManager.CurrentActivity, "current and previous different"); }