コード例 #1
0
        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"]);
        }
コード例 #2
0
        public static ITimeLog Deserialize(XmlNode xml)
        {
            XmlNode data = xml["LazyCureData"];
            ITimeLog timeLog;
            if (data != null)
            {
                XmlAttribute dateAttribute = data.Attributes["Date"];
                DateTime date;
                if (dateAttribute != null)
                    date = DateTime.Parse(dateAttribute.Value);
                else
                    date = DateTime.Today;
                timeLog = new TimeLog(date);

                foreach (XmlNode node in data.ChildNodes)
                {
                    if (node.Name == "Records")
                    {
                        IActivity activity = ActivitySerializer.Deserialize(node);
                        timeLog.AddActivity(activity);
                    }
                }
            }
            else
            {
                timeLog = new TimeLog(DateTime.Now.Date);
            }
            return timeLog;
        }
コード例 #3
0
ファイル: TimeLogTest.cs プロジェクト: EugeneBA/lazycure
 public void GetActivitiesWithEmptyDurationAndEnd()
 {
     timeLog.AddActivity(new Activity("name", DateTime.MinValue, new TimeSpan()));
     timeLog.Data.Rows[0]["Duration"] = DBNull.Value;
     timeLog.Data.Rows[0]["End"]      = DBNull.Value;
     Assert.IsEmpty(timeLog.Activities);
 }
コード例 #4
0
        public static ITimeLog Deserialize(XmlNode xml)
        {
            XmlNode  data = xml["LazyCureData"];
            ITimeLog timeLog;

            if (data != null)
            {
                XmlAttribute dateAttribute = data.Attributes["Date"];
                DateTime     date;
                if (dateAttribute != null)
                {
                    date = DateTime.Parse(dateAttribute.Value);
                }
                else
                {
                    date = DateTime.Today;
                }
                timeLog = new TimeLog(date);

                foreach (XmlNode node in data.ChildNodes)
                {
                    if (node.Name == "Records")
                    {
                        IActivity activity = ActivitySerializer.Deserialize(node);
                        timeLog.AddActivity(activity);
                    }
                }
            }
            else
            {
                timeLog = new TimeLog(DateTime.Now.Date);
            }
            return(timeLog);
        }
コード例 #5
0
        public void TimeSpentOnAllActivitiesIsUpdatedWhenTimeLogsIsChanged()
        {
            var timeLog = new TimeLog(DateTime.Now.Date);
            activitiesSummary.TimeLog = timeLog;
            timeLog.AddActivity(new Activity("test",DateTime.Parse("5:00:00"),TimeSpan.Parse("0:10:00")));

            timeLog.Data.Rows[0]["Duration"] = TimeSpan.Parse("0:05:00");

            Assert.AreEqual(TimeSpan.Parse("0:05:00"), activitiesSummary.AllActivitiesTime);
        }
コード例 #6
0
        public void SummaryIsUpdatedWhenTimeLogEntryDeleted()
        {
            var timeLog = new TimeLog(DateTime.Now.Date);
            activitiesSummary.TimeLog = timeLog;
            timeLog.AddActivity(new Activity("test", DateTime.Parse("5:00:00"), TimeSpan.Parse("0:10:00")));

            timeLog.Data.Rows[0].Delete();

            Assert.AreEqual(TimeSpan.Zero, activitiesSummary.AllActivitiesTime);
        }
コード例 #7
0
        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");
        }