public void TestActionWithNoScheduleByDefault() { Guid id = Guid.NewGuid(); GtdAction action = new GtdAction(id, "Title", "Description"); Assert.IsNull(action.Schedule); }
public void It_Must_Be_A_ToDo_Action_If_Schedule_Is_Null() { GtdAction a = new GtdAction(); var expected = KindOfGtdAction.Todo; var actual = GtdAction.KindOf(a); Assert.AreEqual<KindOfGtdAction>(expected, actual, "Action must be ToDo because Schedule is null"); }
public void TestChangeActionImportant() { Guid id = Guid.NewGuid(); string title = "Title"; string description = "Description"; bool important = true; var ac = new GtdAction(id, title, description); ac.IsImportant = important; Assert.AreEqual<bool>(important, ac.IsImportant); }
internal void CreateDesignInformation(int number = 10) { for (int i = 0; i < number; i++) { var action = new GtdAction(Guid.NewGuid(), string.Format(TITLE, i), string.Format(DESCRIPTION, i)); action.IsImportant = i % 2 == 0; action.PercentageCompleted = i % 100; action.Schedule = CreateScheduleInfo(i); _rep.Insert(action); } }
public void TestChangeActionDescription() { Guid id = Guid.NewGuid(); string title = "Title"; string description = "Description"; var ac = new GtdAction(id, title, description); description = "New description"; ac.Description= description; Assert.AreEqual<string>(description, ac.Description); }
public void It_Must_Be_A_Today_Action_If_DueDate_Is_Whithin_Today() { GtdAction a = new GtdAction(); DateTime dd = ScheduleInfoTestHelper.CreateForEndOfDay(DateTime.Now); ActionScheduleInfo asi = new ActionScheduleInfo(default(DateTime?), dd); a.Schedule = asi; var expected = KindOfGtdAction.Today; var actual = GtdAction.KindOf(a); Assert.AreEqual<KindOfGtdAction>(expected, actual, "Action must be Today because DueDate is whithin today"); }
public void It_Must_Raise_NotifyProperty_Changed_On_ScheduleInfo() { GtdAction a = new GtdAction(); ActionScheduleInfo asi = new ActionScheduleInfo(); InitializeINotifyPropertyChangeInstance(a); a.Schedule = asi; string expected = "Schedule"; var actual = GetInfoRegardingPropertyName(); Assert.AreEqual<string>(expected, actual, "Property Schedule must change"); }
public void It_Must_Raise_NotifyProperty_Changed_On_PercentageCompleted() { GtdAction a = new GtdAction(); double pc = 100.0; InitializeINotifyPropertyChangeInstance(a); a.PercentageCompleted = pc; string expected = "PercentageCompleted"; var actual = GetInfoRegardingPropertyName(); Assert.AreEqual<string>(expected, actual, "Property PercentageCompleted must change"); }
public void It_Must_Raise_NotifyProperty_Changed_On_IsImportant() { GtdAction a = new GtdAction(); bool important = !a.IsImportant; InitializeINotifyPropertyChangeInstance(a); a.IsImportant = important; string expected = "IsImportant"; var actual = GetInfoRegardingPropertyName(); Assert.AreEqual<string>(expected, actual, "Property IsImportant must change"); }
public void It_Must_Be_A_ToDo_Action_If_DueDate_Is_Null() { GtdAction a = new GtdAction(); DateTime sd = DateTime.Now; var asi = new ActionScheduleInfo(sd, default(DateTime?)); a.Schedule = asi; var expected = KindOfGtdAction.Todo; var actual = GtdAction.KindOf(a); Assert.AreEqual<KindOfGtdAction>(expected, actual, "Action must be ToDo because DueDate is null"); }
public void It_Must_Be_A_ToDo_Action_If_DueDate_Is_In_The_Future_Of_Today() { GtdAction a = new GtdAction(); DateTime dd = DateTime.Now.AddDays(1); var asi = new ActionScheduleInfo(default(DateTime?), dd); a.Schedule = asi; var expected = KindOfGtdAction.Todo; var actual = GtdAction.KindOf(a); Assert.AreEqual<KindOfGtdAction>(expected, actual, "Action must be ToDo because Schedule is null"); }
public void TestChangeActionTitle() { Guid id = Guid.NewGuid(); string title = "Title"; string description = "Description"; var ac = new GtdAction(id, title, description); title = "New title"; ac.Title = title; Assert.AreEqual<string>(title, ac.Title); }
public void It_Must_Be_A_Passed_Action_If_DueDate_Is_Previous_To_Today() { GtdAction a = new GtdAction(); DateTime dd = DateTime.Now.AddDays(-1); ActionScheduleInfo asi = new ActionScheduleInfo(default(DateTime?), dd); a.Schedule = asi; var expected = KindOfGtdAction.Passed; var actual = GtdAction.KindOf(a); Assert.AreEqual<KindOfGtdAction>(expected, actual, "Action must be Passed because DueDate was yesterday"); }
public void TestChangeActionScheduleInfo() { Guid id = Guid.NewGuid(); string title = "Title"; string description = "Description"; DateTime startDate = DateTime.Now; DateTime dueDate = startDate.AddDays(1); ActionScheduleInfo asi = new ActionScheduleInfo(startDate, dueDate); var ac = new GtdAction(id, title, description); ac.Schedule = asi; Assert.IsNotNull(ac.Schedule); Assert.AreEqual<ActionScheduleInfo>(asi, ac.Schedule); }
public static KindOfGtdAction KindOf(GtdAction a) { if (a.Schedule == null) return KindOfGtdAction.Todo; if (!a.Schedule.DueDate.HasValue) return KindOfGtdAction.Todo; DateTime beginOfDayNow = new DateTime (DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0,0,0); DateTime endOfDayNow = beginOfDayNow.AddDays (1); if (a.Schedule.DueDate < beginOfDayNow) return KindOfGtdAction.Passed; if (a.Schedule.DueDate >= beginOfDayNow && a.Schedule.DueDate < endOfDayNow) return KindOfGtdAction.Today; if (a.Schedule.DueDate > endOfDayNow) return KindOfGtdAction.Todo; return KindOfGtdAction.Todo; }
public void InsertTest() { GtdActionRepository repository = new GtdActionRepository(); Guid actionId = Guid.NewGuid(); string title = "Title"; string description = "Description"; GtdAction expectedAction = new GtdAction(actionId, title, description); GtdAction action = null; int cont = 0; repository.Insert(expectedAction); var enumerator = repository.GetEnumerator(); while (enumerator.MoveNext()) { action = enumerator.Current; cont++; } Assert.IsTrue(cont == 1); Assert.IsTrue(action.UniqueId == actionId); }
public void TestDefaultConstructor() { Guid id = Guid.NewGuid(); string title = "Title"; string description = "Description"; var ac = new GtdAction(id, title, description); Assert.AreEqual<Guid>(id, ac.UniqueId); Assert.AreEqual<string>(title, ac.Title); Assert.AreEqual<string>(description, ac.Description); Assert.IsFalse(ac.IsImportant); Assert.IsFalse(ac.PercentageCompleted.HasValue); }
public void TestGuidEquatable() { Guid id = Guid.NewGuid(); GtdAction action = new GtdAction(id, "Title", "Description"); Assert.IsTrue(action.Equals (id)); }
public void InitializeRepository() { _repository = new GtdActionRepository(); var choose = DateTime.Now.Ticks % MAX; for (int i = 0; i < MAX; i++) { GtdAction act = new GtdAction(Guid.NewGuid(), String.Format(TITLE_TEMPLATE, i), String.Format(DESC_TEMPLATE, i)); _repository.Insert(act); if (choose == i) _action2Find = act; } }
public void TestKindOfGtdEntityActionWithNoScheduleByDefaul() { Guid id = Guid.NewGuid(); GtdAction action = new GtdAction(id, "Title", "Description"); Assert.IsNull(action.Schedule); Assert.AreEqual<KindOfGtdEntity>(KindOfGtdEntity.Todo, action.KindOf()); }
public void UpdateNonExistingTest() { GtdAction action = new GtdAction (Guid.NewGuid(), "Title", "Descr"); bool result = _repository.Update(action); Assert.IsFalse(result); }
public void TestKindOfGtdEntityActionWithNotDefinedDueDate() { Guid id = Guid.NewGuid(); GtdAction action = new GtdAction(id, "Title", "Description"); ActionScheduleInfo asi = new ActionScheduleInfo(); asi.StartDate = DateTime.Now; }