public void CalculatingAutomaticallyFalse()
        {
            ITimeLog timeLog = new TimeLog(DateTime.Now.Date);
            workingTime = new WorkingTimeForDay(timeLog, workDefiner);
            timeLog.AddActivity(new Activity("work", DateTime.Parse("9:30"), TimeSpan.Parse("0:25")));
            workingTime.CalculateAutomatically = false;
            timeLog.AddActivity(new Activity("work", DateTime.Parse("9:55"), TimeSpan.Parse("0:05")));
            DataTable table = workingTime.Intervals;

            Assert.AreEqual(DateTime.Parse("9:55"), table.Rows[0]["End"]);
        }
        public void WorkingIntervalsUpdatedWhenTimeLogIsChanged()
        {
            ITimeLog timeLog = new TimeLog(DateTime.Now.Date);

            workingTime = new WorkingTimeForDay(timeLog, workDefiner);
            timeLog.AddActivity(new Activity("work", DateTime.Parse("10:30"), TimeSpan.Parse("10:55")));
            DataTable table = workingTime.Intervals;

            Assert.AreEqual(DateTime.Parse("10:30"), table.Rows[0]["Start"]);
            Assert.AreEqual(1, table.Rows.Count, "rows count");
        }
        public void CalculatingAutomaticallyFalse()
        {
            ITimeLog timeLog = new TimeLog(DateTime.Now.Date);

            workingTime = new WorkingTimeForDay(timeLog, workDefiner);
            timeLog.AddActivity(new Activity("work", DateTime.Parse("9:30"), TimeSpan.Parse("0:25")));
            workingTime.CalculateAutomatically = false;
            timeLog.AddActivity(new Activity("work", DateTime.Parse("9:55"), TimeSpan.Parse("0:05")));
            DataTable table = workingTime.Intervals;

            Assert.AreEqual(DateTime.Parse("9:55"), table.Rows[0]["End"]);
        }
        public void WorkingTasksTime()
        {
            ITimeLog timeLog = NewMock <ITimeLog>();

            Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(new List <IActivity>(
                                                                             new IActivity[] {
                new Activity("work", DateTime.Parse("0:00"), TimeSpan.Parse("0:01"))
            })));
            Stub.On(timeLog).GetProperty("Data").Will(Return.Value(new DataTable()));
            workingTime = new WorkingTimeForDay(timeLog, workDefiner);
            Assert.AreEqual(TimeSpan.Parse("0:01"), workingTime.WorkingTasksTime);
        }
        public void WorkingIntervalsExcludeRestOnLeftEdge()
        {
            ITimeLog timeLog = NewMock <ITimeLog>();

            Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(new List <IActivity>(
                                                                             new IActivity[] {
                new Activity("rest", DateTime.Parse("9:00"), TimeSpan.Parse("0:15")),
                new Activity("work", DateTime.Parse("9:15"), TimeSpan.Parse("10:15"))
            })));
            Stub.On(timeLog).GetProperty("Data").Will(Return.Value(new DataTable()));
            workingTime = new WorkingTimeForDay(timeLog, workDefiner);

            Assert.AreEqual(DateTime.Parse("9:15"), workingTime.Intervals.Rows[0]["Start"]);
        }
 public void IntervalsChangesWhenActivityBecomesWorking()
 {
     ITaskCollection taskCollection = NewMock<ITaskCollection>();
     ITimeLog timeLog = NewMock<ITimeLog>();
     Expect.Once.On(taskCollection).Method("IsWorkingActivity").With("test").
         Will(Return.Value(false));
     Stub.On(timeLog).GetProperty("Data").Will(Return.Value(null));
     List<IActivity> activities = new List<IActivity>();
     activities.Add(new Activity("test",DateTime.Now,TimeSpan.FromMinutes(1)));
     Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(activities));
     workingTime = new WorkingTimeForDay(timeLog, taskCollection);
     Expect.AtLeastOnce.On(taskCollection).Method("IsWorkingActivity").With("test").
         Will(Return.Value(true));
     TimeSpan workingTasksTime = workingTime.WorkingTasksTime;
     Assert.AreEqual(1, workingTime.Intervals.Rows.Count);
 }
        public void PossibleWorkInterruptionMore()
        {
            ITimeLog timeLog = NewMock <ITimeLog>();

            Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(new List <IActivity>(
                                                                             new IActivity[] {
                new Activity("work", DateTime.Parse("9:00"), TimeSpan.Parse("1:00")),
                new Activity("rest", DateTime.Parse("10:00"), TimeSpan.Parse("0:15")),
                new Activity("work", DateTime.Parse("10:15"), TimeSpan.Parse("0:30"))
            })));
            Stub.On(timeLog).GetProperty("Data").Will(Return.Value(new DataTable()));

            workingTime = new WorkingTimeForDay(timeLog, workDefiner);
            workingTime.PossibleWorkInterruption = TimeSpan.Parse("0:14");

            Assert.AreEqual(TimeSpan.Parse("1:30"), workingTime.TimeOnWork);
        }
        public void WorkingIntervals()
        {
            ITimeLog timeLog = NewMock <ITimeLog>();

            Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(new List <IActivity>(
                                                                             new IActivity[] {
                new Activity("work1", DateTime.Parse("9:00"), TimeSpan.Parse("1:00")),
                new Activity("dinner", DateTime.Parse("10:00"), TimeSpan.Parse("1:00")),
                new Activity("work2", DateTime.Parse("11:00"), TimeSpan.Parse("0:30"))
            })));
            Stub.On(timeLog).GetProperty("Data").Will(Return.Value(new DataTable()));
            workingTime = new WorkingTimeForDay(timeLog, workDefiner);
            DataTable table = workingTime.Intervals;

            Assert.AreEqual(DateTime.Parse("9:00"), table.Rows[0]["Start"]);
            Assert.AreEqual(DateTime.Parse("10:00"), table.Rows[0]["End"]);
            Assert.AreEqual(DateTime.Parse("11:00"), table.Rows[1]["Start"]);
            Assert.AreEqual(DateTime.Parse("11:30"), table.Rows[1]["End"]);
        }
        public void IntervalsChangesWhenActivityBecomesWorking()
        {
            ITaskCollection taskCollection = NewMock <ITaskCollection>();
            ITimeLog        timeLog        = NewMock <ITimeLog>();

            Expect.Once.On(taskCollection).Method("IsWorkingActivity").With("test").
            Will(Return.Value(false));
            Stub.On(timeLog).GetProperty("Data").Will(Return.Value(null));
            List <IActivity> activities = new List <IActivity>();

            activities.Add(new Activity("test", DateTime.Now, TimeSpan.FromMinutes(1)));
            Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(activities));
            workingTime = new WorkingTimeForDay(timeLog, taskCollection);
            Expect.AtLeastOnce.On(taskCollection).Method("IsWorkingActivity").With("test").
            Will(Return.Value(true));
            TimeSpan workingTasksTime = workingTime.WorkingTasksTime;

            Assert.AreEqual(1, workingTime.Intervals.Rows.Count);
        }
        public void SetUp()
        {
            ITimeLog timeLog = NewMock <ITimeLog>();

            Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(new List <IActivity>(
                                                                             new IActivity[] {
                new Activity("work", DateTime.Parse("9:00"), TimeSpan.Parse("4:00")),
                new Activity("rest", DateTime.Parse("14:30"), TimeSpan.Parse("3:30"))
            })));
            Stub.On(timeLog).GetProperty("Data").Will(Return.Value(new DataTable()));
            workDefiner = NewMock <IWorkDefiner>();
            Stub.On(workDefiner).Method("IsWorkingActivity").With("work").Will(Return.Value(true));
            Stub.On(workDefiner).Method("IsWorkingActivity").With("work1").Will(Return.Value(true));
            Stub.On(workDefiner).Method("IsWorkingActivity").With("work2").Will(Return.Value(true));
            Stub.On(workDefiner).Method("IsWorkingActivity").With("rest").Will(Return.Value(false));
            Stub.On(workDefiner).Method("IsWorkingActivity").With("dinner").Will(Return.Value(false));
            Stub.On(workDefiner).Method("IsWorkingActivity").With(string.Empty).Will(Return.Value(false));
            Stub.On(workDefiner).Method("IsWorkingActivity").With(null).Will(Return.Value(false));
            workingTime = new WorkingTimeForDay(timeLog, workDefiner);
        }
        public void PossibleWorkInterruptionLess()
        {
            ITimeLog timeLog = NewMock<ITimeLog>();
            Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(new List<IActivity>(
                new IActivity[] {
                    new Activity("work", DateTime.Parse("9:00"), TimeSpan.Parse("1:00")),
                    new Activity("rest", DateTime.Parse("10:00"), TimeSpan.Parse("0:15")),
                    new Activity("work", DateTime.Parse("10:15"), TimeSpan.Parse("0:30"))
                })));
            Stub.On(timeLog).GetProperty("Data").Will(Return.Value(new DataTable()));

            workingTime = new WorkingTimeForDay(timeLog, workDefiner);
            workingTime.PossibleWorkInterruption = TimeSpan.Parse("0:15");

            Assert.AreEqual(TimeSpan.Parse("1:45"),workingTime.TimeOnWork);
        }
 public void WorkingTasksTimeForEmptyTask()
 {
     ITimeLog timeLog = NewMock<ITimeLog>();
     Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(new List<IActivity>(
         new IActivity[] {
             new Activity(null, DateTime.Parse("0:00"), TimeSpan.Parse("0:04")),
             new Activity("rest", DateTime.Parse("0:00"), TimeSpan.Parse("0:01"))
         })));
     Stub.On(timeLog).GetProperty("Data").Will(Return.Value(new DataTable()));
     workingTime = new WorkingTimeForDay(timeLog, workDefiner);
     Assert.AreEqual(TimeSpan.Parse("0:00"), workingTime.WorkingTasksTime);
 }
        public void WorkingIntervalsUpdatedWhenTimeLogIsChanged()
        {
            ITimeLog timeLog = new TimeLog(DateTime.Now.Date);
            workingTime = new WorkingTimeForDay(timeLog, workDefiner);
            timeLog.AddActivity(new Activity("work", DateTime.Parse("10:30"), TimeSpan.Parse("10:55")));
            DataTable table = workingTime.Intervals;

            Assert.AreEqual(DateTime.Parse("10:30"), table.Rows[0]["Start"]);
            Assert.AreEqual(1, table.Rows.Count, "rows count");
        }
        public void WorkingIntervalsExcludeRestOnRightEdge()
        {
            ITimeLog timeLog = NewMock<ITimeLog>();
            Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(new List<IActivity>(
                new IActivity[] {
                    new Activity("work", DateTime.Parse("9:00"), TimeSpan.Parse("1:00")),
                    new Activity("rest", DateTime.Parse("10:00"), TimeSpan.Parse("0:15"))
                })));
            Stub.On(timeLog).GetProperty("Data").Will(Return.Value(new DataTable()));
            workingTime = new WorkingTimeForDay(timeLog, workDefiner);

            Assert.AreEqual(DateTime.Parse("10:00"), workingTime.Intervals.Rows[0]["End"]);
        }
 public void WorkingIntervals()
 {
     ITimeLog timeLog = NewMock<ITimeLog>();
     Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(new List<IActivity>(
         new IActivity[] {
             new Activity("work1", DateTime.Parse("9:00"), TimeSpan.Parse("1:00")),
             new Activity("dinner", DateTime.Parse("10:00"), TimeSpan.Parse("1:00")),
             new Activity("work2", DateTime.Parse("11:00"), TimeSpan.Parse("0:30"))
         })));
     Stub.On(timeLog).GetProperty("Data").Will(Return.Value(new DataTable()));
     workingTime = new WorkingTimeForDay(timeLog, workDefiner);
     DataTable table = workingTime.Intervals;
     Assert.AreEqual(DateTime.Parse("9:00"), table.Rows[0]["Start"]);
     Assert.AreEqual(DateTime.Parse("10:00"), table.Rows[0]["End"]);
     Assert.AreEqual(DateTime.Parse("11:00"), table.Rows[1]["Start"]);
     Assert.AreEqual(DateTime.Parse("11:30"), table.Rows[1]["End"]);
 }
 public void SetUp()
 {
     ITimeLog timeLog = NewMock<ITimeLog>();
     Stub.On(timeLog).GetProperty("Activities").Will(Return.Value(new List<IActivity>(
         new IActivity[] {
             new Activity("work", DateTime.Parse("9:00"), TimeSpan.Parse("4:00")),
             new Activity("rest", DateTime.Parse("14:30"), TimeSpan.Parse("3:30"))
         })));
     Stub.On(timeLog).GetProperty("Data").Will(Return.Value(new DataTable()));
     workDefiner = NewMock<IWorkDefiner>();
     Stub.On(workDefiner).Method("IsWorkingActivity").With("work").Will(Return.Value(true));
     Stub.On(workDefiner).Method("IsWorkingActivity").With("work1").Will(Return.Value(true));
     Stub.On(workDefiner).Method("IsWorkingActivity").With("work2").Will(Return.Value(true));
     Stub.On(workDefiner).Method("IsWorkingActivity").With("rest").Will(Return.Value(false));
     Stub.On(workDefiner).Method("IsWorkingActivity").With("dinner").Will(Return.Value(false));
     Stub.On(workDefiner).Method("IsWorkingActivity").With(string.Empty).Will(Return.Value(false));
     Stub.On(workDefiner).Method("IsWorkingActivity").With(null).Will(Return.Value(false));
     workingTime = new WorkingTimeForDay(timeLog, workDefiner);
 }