Exemplo n.º 1
0
        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 CanMoveActivityBackToInBox()
        {
            var      board    = new ActivityBoard();
            Activity activity = Activity.FluentNew("An Activity")
                                .ActiveDueDate(new DateTime(2017, 2, 28))
                                .DailyLeadTime(3)
                                .Recurrence(ERecurFromType.FromActiveDueDate, x => x.Daily(14))
                                .AddToBoard(board)
                                .ToActivity;
            ActivityList list = board.AddNewList("Doing");

            board.MoveActivity(activity).ToList(list);
            board.MoveActivity(activity).ToList(board.InBox);
            Assert.That(list.Activities, Has.No.Member(activity));
            Assert.That(board.InBox.Activities, Has.Member(activity));
        }
        public void CannotMoveActivityToGoalNotBelongingToBoard()
        {
            var      board    = new ActivityBoard();
            Activity activity = Activity.FluentNew("An Activity")
                                .AddToBoard(board);
            ActivityGoal goal = new ActivityGoal("Bad Goal");

            Assert.That(() => board.MoveActivity(activity).ToGoal(goal), Throws.TypeOf <ArgumentException>());
        }
        public void GetGoalsFromActivities()
        {
            var      board     = new ActivityBoard();
            Activity activity1 = Activity.FluentNew("Activity 1")
                                 .AddToBoard(board);
            Activity activity2 = Activity.FluentNew("Activity 2")
                                 .AddToBoard(board);
            ActivityGoal goal1 = board.AddNewGoal("Goal 1");

            board.MoveActivity(activity1).ToGoal(goal1);
            board.MoveActivity(activity2).ToGoal(goal1);
            ILookup <ActivityGoal, Activity> goalLookup = board.GetGoalLookupFromActivities(activity1, activity2);

            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(2));
            Assert.That(goalLookup.First().FirstOrDefault(activity => activity == activity1), Is.Not.Null);
            Assert.That(goalLookup.First().FirstOrDefault(activity => activity == activity2), Is.Not.Null);
        }
        public void RemovingActivityListMovesRelatedActivitiesToInBox()
        {
            var          board            = new ActivityBoard();
            string       activityListName = "Doing";
            ActivityList list             = board.AddNewList(activityListName);
            Activity     activity         = Activity.FluentNew("New Activity").AddToBoard(board);

            board.MoveActivity(activity).ToList(list);
            board.RemoveList(list);
            Assert.That(board.InBox.Activities, Is.Not.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 CannotMoveActivityNotBelongingToBoard()
        {
            var      board    = new ActivityBoard();
            Activity activity = Activity.FluentNew("An Activity")
                                .ActiveDueDate(new DateTime(2017, 2, 28))
                                .DailyLeadTime(3)
                                .Recurrence(ERecurFromType.FromActiveDueDate, x => x.Daily(14))
                                .ToActivity;
            ActivityList list = board.AddNewList("Doing");

            Assert.That(() => board.MoveActivity(activity).ToList(list), Throws.TypeOf <ArgumentException>());
        }
        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));
        }