public void GetGoalsForItemsFromAView() { var board = new ActivityBoard(); DateTime startDate = new DateTime(2017, 2, 28); DateTime endDate = startDate.AddDays(5); Activity activity1 = Activity.FluentNew("Activity 1") .ActiveDueDate(startDate.AddDays(1)) .Recurrence(ERecurFromType.FromCompletedDate, x => x.Daily(2)) .AddToBoard(board); activity1.SignalCompleted(startDate.AddDays(1)); Activity activity2 = Activity.FluentNew("Activity 2") .ActiveDueDate(startDate.AddDays(2)) .Recurrence(ERecurFromType.FromCompletedDate, x => x.Daily(1)) .AddToBoard(board); activity2.SignalCompleted(startDate.AddDays(3)); Activity activity3 = Activity.FluentNew("Activity 3") .ActiveDueDate(startDate.AddDays(2)) .Recurrence(ERecurFromType.FromCompletedDate, x => x.Daily(1)) .AddToBoard(board); activity3.SignalCompleted(startDate); activity3.SignalCompleted(startDate.AddDays(1)); activity3.SignalCompleted(startDate.AddDays(2)); ActivityGoal goal1 = board.AddNewGoal("Goal 1"); ActivityGoal goal2 = board.AddNewGoal("Goal 2"); board.MoveActivity(activity1).ToGoal(goal1); board.MoveActivity(activity2).ToGoal(goal2); board.MoveActivity(activity3).ToGoal(goal1); board.InBox.ViewModes.CalendarView .DateRange(startDate, endDate) .IncludeHistory() .IncludeFuture() .Enable(); IEnumerable <Activity> activities = board.InBox.ViewItems.Select(vi => vi.Activity); ILookup <ActivityGoal, Activity> goalLookup = board.GetGoalLookupFromActivities(activities); Assert.That(goalLookup, Is.Not.Empty); Assert.That(goalLookup.Count, Is.EqualTo(2)); Assert.That(goalLookup[goal1], Is.Not.Empty); Assert.That(goalLookup[goal1].Count(), Is.EqualTo(2)); Assert.That(goalLookup[goal1], Has.Member(activity1)); Assert.That(goalLookup[goal1], Has.Member(activity3)); Assert.That(goalLookup[goal2], Is.Not.Empty); Assert.That(goalLookup[goal2].Count(), Is.EqualTo(1)); Assert.That(goalLookup[goal2], Has.Member(activity2)); }
public void CanRemoveGoal() { var board = new ActivityBoard(); ActivityGoal goal = board.AddNewGoal("New Goal"); board.RemoveGoal(goal); Assert.That(board.Goals, Is.Empty); }
public void GetGoalFromActivity() { var board = new ActivityBoard(); Activity activity = Activity.FluentNew("An Activity") .AddToBoard(board); ActivityGoal newGoal = board.AddNewGoal("New Goal"); board.MoveActivity(activity).ToGoal(newGoal); ActivityGoal foundGoal = board.GetGoalFromActivity(activity); Assert.That(foundGoal, Is.EqualTo(newGoal)); }
public void CanCreateGoal() { var board = new ActivityBoard(); string goalName = "New Goal"; ActivityGoal goal = board.AddNewGoal(goalName); Assert.That(goal, Is.Not.Null); Assert.That(goal.Name, Is.EqualTo(goalName)); Assert.That(board.Goals, Is.Not.Null); Assert.That(board.Goals.Count(), Is.EqualTo(1)); Assert.That(board.Goals, Has.Member(goal)); }
public void RemovingGoalClearsGoalFromActivities() { var board = new ActivityBoard(); ActivityGoal goal = board.AddNewGoal("New Goal"); Activity activity = Activity.FluentNew("New Activity") .AddToBoard(board); board.MoveActivity(activity) .ToGoal(goal); board.RemoveGoal(goal); Assert.That(activity.GoalGuid, Is.Null); }
public void CanAssignActivityToGoal() { var board = new ActivityBoard(); ActivityGoal goal = board.AddNewGoal("New Goal"); Activity activity = Activity.FluentNew("New Activity") .AddToBoard(board); board.MoveActivity(activity) .ToGoal(goal); Assert.That(activity.GoalGuid, Is.Not.Null); Assert.That(activity.GoalGuid, Is.EqualTo(goal.Guid)); }
public void GetGoalsFromActivitiesConsolidatesActivities() { var board = new ActivityBoard(); Activity activity1 = Activity.FluentNew("Activity 1") .AddToBoard(board); ActivityGoal goal1 = board.AddNewGoal("Goal 1"); board.MoveActivity(activity1).ToGoal(goal1); ILookup <ActivityGoal, Activity> goalLookup = board.GetGoalLookupFromActivities(activity1, activity1); Assert.That(goalLookup, Is.Not.Empty); Assert.That(goalLookup.Count, Is.EqualTo(1)); Assert.That(goalLookup.First().Key, Is.EqualTo(goal1)); Assert.That(goalLookup.First().Count(), Is.EqualTo(1)); Assert.That(goalLookup.First().FirstOrDefault(activity => activity == activity1), Is.Not.Null); }