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 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; }
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); }
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); }
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); }
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); }
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"); }