Ejemplo n.º 1
0
        public void GetTimeLogsReturnsListOfTimeLogsFromFileManager()
        {
            DateTime             from        = DateTime.Parse("2020-01-01");
            DateTime             to          = DateTime.Parse("2020-01-02");
            ITimeLogsFileManager fileManager = NewMock <ITimeLogsFileManager>();

            Stub.On(fileManager).GetProperty("AllTimeLogDates").Will(Return.Value(new List <DateTime>(new DateTime[] { from, to })));
            Stub.On(fileManager).Method("GetTimeLog").With(from).Will(Return.Value(NewMock <ITimeLog>()));
            Stub.On(fileManager).Method("GetTimeLog").With(to).Will(Return.Value(NewMock <ITimeLog>()));
            var timeLogsManager = new TimeLogsManager(fileManager);

            Assert.AreEqual(2, timeLogsManager.GetTimeLogs(from, to).Count);
        }
Ejemplo n.º 2
0
        public void GetTimeLogsUseActiveTimeLogInsteadOfFileSystemFileExists()
        {
            var date            = DateTime.Today;
            var timeLog         = new TimeLog(date);
            var fileManager     = NewMock <ITimeLogsFileManager>();
            var timeLogsManager = new TimeLogsManager(fileManager);

            Stub.On(fileManager).GetProperty("AllTimeLogDates").Will(Return.Value(new List <DateTime> {
                date
            }));
            Expect.Never.On(fileManager).Method("GetTimeLog").With(date);

            timeLogsManager.ActiveTimeLog = timeLog;

            var timeLogs = timeLogsManager.GetTimeLogs(date, date);

            Assert.AreEqual(1, timeLogs.Count, "number of TimeLogs returned");
            Assert.AreSame(timeLog, timeLogs[0]);
        }