Пример #1
0
 public void SPEED_OF_LIGHT_TEST()
 {
     new Thread(() =>
     {
         // your code
         var p          = new MockPlanning();
         var firstTask  = new MockTask();
         var secondTask = new MockTask();
         p.SetContent(new List <IWeek>
         {
             new IWeek(new List <AbstractDay> {
                 new Day(new List <AbstractTask> {
                     firstTask, new MockTask()
                 }),
                 new Day(),
                 new Day(),
                 new Day(),
                 new Day(),
                 new Day(),
                 new Day(),
             }),
             new IWeek(new List <AbstractDay> {
                 new Day(new List <AbstractTask> {
                     secondTask, new MockTask()
                 }),
                 new Day(),
                 new Day(),
                 new Day(),
                 new Day(),
                 new Day(),
                 new Day(new List <AbstractTask> {
                     new MockTask()
                 }),
             })
         });
         p.SetPreMenu(new MotivatorEngine.PreTask.PreMenu(new List <MotivatorEngine.PreTask.PreMenuChoice> {
             new GiveupChoice()
         }));
         p.StartFirstTime();
     }).Start();
     Thread.Sleep(2000);
 }
        public void SaveTest()
        {
            var p          = new MockPlanning();
            var firstTask  = new MockTask();
            var secondTask = new MockTask();

            p.SetContent(new List <IWeek>
            {
                new IWeek(new List <AbstractDay> {
                    new Day(new List <AbstractTask> {
                        firstTask
                    }),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                }),
                new IWeek(new List <AbstractDay> {
                    new Day(new List <AbstractTask> {
                        secondTask
                    }),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(new List <AbstractTask> {
                        new MockTask()
                    }),
                })
            });

            var rm = new ConsoleRoadmap(p);

            rm.ShowRoadmap();
            string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Test save.json";

            new PlanningLoader().Save(path, p);
            //File.Delete(path);
        }
Пример #3
0
        public async Task DeleteUnreferencedProjectsInInaccessibleWorkspace()
        {
            var workspace = new MockWorkspace(2000, isInaccessible: true);

            var project1 = new MockProject(101, workspace, syncStatus: SyncStatus.InSync);
            var project2 = new MockProject(102, workspace, syncStatus: SyncStatus.RefetchingNeeded);
            var project3 = new MockProject(103, workspace, syncStatus: SyncStatus.InSync);
            var project4 = new MockProject(104, workspace, syncStatus: SyncStatus.SyncNeeded);
            var project5 = new MockProject(105, workspace, syncStatus: SyncStatus.InSync);
            var project6 = new MockProject(106, workspace, syncStatus: SyncStatus.InSync);
            var project7 = new MockProject(107, workspace, syncStatus: SyncStatus.InSync);
            var project8 = new MockProject(108, workspace, syncStatus: SyncStatus.InSync);

            var task1 = new MockTask(1001, workspace, project1, SyncStatus.InSync);
            var task2 = new MockTask(1002, workspace, project2, SyncStatus.RefetchingNeeded);
            var task3 = new MockTask(1003, workspace, project3, SyncStatus.SyncNeeded);
            var task4 = new MockTask(1004, workspace, project3, SyncStatus.InSync);
            var task5 = new MockTask(1005, workspace, project6, SyncStatus.InSync);

            var te1 = new MockTimeEntry(10001, workspace, project: project1, task: task1, syncStatus: SyncStatus.InSync);
            var te2 = new MockTimeEntry(10002, workspace, project: project2, task: task2, syncStatus: SyncStatus.SyncNeeded);
            var te3 = new MockTimeEntry(20001, workspace, project: project3, task: task3, syncStatus: SyncStatus.InSync);
            var te4 = new MockTimeEntry(20002, workspace, project: project4, task: task4, syncStatus: SyncStatus.SyncNeeded);
            var te5 = new MockTimeEntry(20003, workspace, project: project4, syncStatus: SyncStatus.SyncFailed);
            var te6 = new MockTimeEntry(20004, workspace, project: project5, syncStatus: SyncStatus.InSync);

            var projects    = new[] { project1, project2, project3, project4, project5, project6, project7, project8 };
            var tasks       = new[] { task1, task2, task3, task4, task5 };
            var timeEntries = new[] { te1, te2, te3, te4, te5, te6 };

            var unreferencedProjects = new[] { project7, project8 };
            var neededProjects       = projects.Where(project => !unreferencedProjects.Contains(project));

            configureDataSource(projects, tasks, timeEntries);

            await state.Start().SingleAsync();

            projectsDataSource.Received().DeleteAll(Arg.Is <IEnumerable <IThreadSafeProject> >(arg =>
                                                                                               arg.All(project => unreferencedProjects.Contains(project)) &&
                                                                                               arg.None(project => neededProjects.Contains(project))));
        }
        public async Task DeleteUnreferencedTasksInInaccessibleWorkspace()
        {
            var accessibleWorkspace   = new MockWorkspace(1000);
            var inaccessibleWorkspace = new MockWorkspace(2000, isInaccessible: true);

            var project1 = new MockProject(101, accessibleWorkspace);
            var project2 = new MockProject(102, accessibleWorkspace, syncStatus: SyncStatus.RefetchingNeeded);
            var project3 = new MockProject(201, inaccessibleWorkspace, syncStatus: SyncStatus.SyncFailed);
            var project4 = new MockProject(202, inaccessibleWorkspace, syncStatus: SyncStatus.SyncNeeded);

            var task1 = new MockTask(1001, accessibleWorkspace, project1);
            var task2 = new MockTask(1002, accessibleWorkspace, project2, SyncStatus.RefetchingNeeded);
            var task3 = new MockTask(1003, accessibleWorkspace, project2, SyncStatus.SyncNeeded);
            var task4 = new MockTask(2001, inaccessibleWorkspace, project3);
            var task5 = new MockTask(2002, inaccessibleWorkspace, project4, SyncStatus.RefetchingNeeded);
            var task6 = new MockTask(2003, inaccessibleWorkspace, project3, SyncStatus.SyncNeeded);
            var task7 = new MockTask(2003, inaccessibleWorkspace, project4);
            var task8 = new MockTask(2004, inaccessibleWorkspace, project4);

            var te1 = new MockTimeEntry(10001, accessibleWorkspace, project: project1, task: task1);
            var te2 = new MockTimeEntry(10002, accessibleWorkspace, project: project1, task: task2);
            var te3 = new MockTimeEntry(20001, inaccessibleWorkspace, project: project3, task: task4);
            var te4 = new MockTimeEntry(20002, inaccessibleWorkspace, project: project4, task: task5);
            var te5 = new MockTimeEntry(20002, inaccessibleWorkspace, project: project4);
            var te6 = new MockTimeEntry(20002, inaccessibleWorkspace);

            var tasks       = new[] { task1, task2, task3, task4, task5, task6, task7, task8 };
            var timeEntries = new[] { te1, te2, te3, te4, te5, te6 };

            var unreferencedTasks = new[] { task7, task8 };
            var neededTasks       = tasks.Where(task => !unreferencedTasks.Contains(task));

            configureDataSource(tasks, timeEntries);

            await state.Start().SingleAsync();

            tasksDataSource.Received().DeleteAll(Arg.Is <IEnumerable <IThreadSafeTask> >(arg =>
                                                                                         arg.All(task => unreferencedTasks.Contains(task)) &&
                                                                                         arg.None(task => neededTasks.Contains(task))));
        }
Пример #5
0
        public void PrintGetRoadmapTest()
        {
            var p          = new MockPlanning();
            var firstTask  = new MockTask();
            var secondTask = new MockTask();

            p.SetContent(new List <IWeek>
            {
                new IWeek(new List <AbstractDay> {
                    new Day(new List <AbstractTask> {
                        firstTask
                    }),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                }),
                new IWeek(new List <AbstractDay> {
                    new Day(new List <AbstractTask> {
                        secondTask, new MockTask()
                    }),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(new List <AbstractTask> {
                        new MockTask()
                    }),
                })
            });
            p.currentDayIndex = 13;
            var r    = new ConsoleRoadmap(p);
            var text = r.GetRoadmapText();

            Assert.IsNotNull(text);
            Console.WriteLine(text);
        }
Пример #6
0
        public void DecalWeekSaveTest()
        {
            var p          = new MockPlanning();
            var firstTask  = new MockTask();
            var secondTask = new MockTask();
            var dayToDecal = new Day(new List <AbstractTask> {
                firstTask
            });

            p.SetContent(new List <IWeek>
            {
                new IWeek(new List <AbstractDay> {
                    dayToDecal,
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                }),
                new IWeek(new List <AbstractDay> {
                    new Day(new List <AbstractTask> {
                        secondTask, new MockTask()
                    }),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(new List <AbstractTask> {
                        new MockTask()
                    }),
                })
            });
            Console.WriteLine("Before decal\n" + p);
            p.Save();
            p.DecalWeek(dayToDecal);
            p.Save();
            Console.WriteLine("After decal\n" + p);
        }
Пример #7
0
        public void PrintRoadmapTest()
        {
            var p          = new MockPlanning();
            var firstTask  = new MockTask();
            var secondTask = new MockTask();

            p.SetContent(new List <IWeek>
            {
                new IWeek(new List <AbstractDay> {
                    new Day(new List <AbstractTask> {
                        firstTask
                    }),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                }),
                new IWeek(new List <AbstractDay> {
                    new Day(new List <AbstractTask> {
                        secondTask
                    }),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(new List <AbstractTask> {
                        new MockTask()
                    }),
                })
            });
            var rm = new ConsoleRoadmap(p);

            rm.ShowRoadmap();
            p.currentDayIndex = 13;
            rm.ShowRoadmap();
        }
Пример #8
0
        public void GetWeekCountTest()
        {
            var p          = new MockPlanning();
            var firstTask  = new MockTask();
            var secondTask = new MockTask();

            p.SetContent(new List <IWeek>
            {
                new IWeek(new List <AbstractDay> {
                    new Day(new List <AbstractTask> {
                        firstTask
                    }),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                }),
                new IWeek(new List <AbstractDay> {
                    new Day(new List <AbstractTask> {
                        secondTask
                    }),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(new List <AbstractTask> {
                        new MockTask()
                    }),
                })
            });

            Assert.AreEqual(2, p.GetWeekCount());
            p.AddDay(new Day());
            Assert.AreEqual(15, p.GetDays().Count);
            Assert.AreEqual(3, p.GetWeekCount());
        }
        public async Task DeleteInaccessibleWorkspacesNotReferencedByTasks()
        {
            var accessibleReferenced     = new MockWorkspace(1, false, SyncStatus.InSync);
            var accessibleUnreferenced   = new MockWorkspace(2, false, SyncStatus.InSync);
            var inaccessibleReferenced   = new MockWorkspace(3, true, SyncStatus.InSync);
            var inaccessibleUnreferenced = new MockWorkspace(4, true, SyncStatus.InSync);

            var project1 = new MockProject(11, accessibleReferenced, syncStatus: SyncStatus.InSync);
            var project2 = new MockProject(22, inaccessibleReferenced, syncStatus: SyncStatus.InSync);

            var task1 = new MockTask(11, accessibleReferenced, project1, syncStatus: SyncStatus.InSync);
            var task2 = new MockTask(22, inaccessibleReferenced, project2, syncStatus: SyncStatus.InSync);

            var workspaces = new[] { accessibleReferenced, accessibleUnreferenced, inaccessibleReferenced, inaccessibleUnreferenced };
            var tasks      = new[] { task1, task2 };

            configureDataSources(workspaces, tasks: tasks);

            await state.Start().SingleAsync();

            workspacesDataSource.Received().DeleteAll(Arg.Is <IEnumerable <IThreadSafeWorkspace> >(
                                                          arg => arg.All(ws => ws == inaccessibleUnreferenced)));
        }
Пример #10
0
        public void should_intercept_the_invocation_and_notify_subscribers_if_the_invocation_method_is_Execute()
        {
            // Arrange
            var task = new InterceptTaskExecution();

            var mockInvocation = new Mock <IInvocation>();
            var mockTask       = new MockTask();

            mockInvocation.Setup(invocation => invocation.Method.Name).Returns("Execute");
            mockInvocation.Setup(invocation => invocation.InvocationTarget).Returns(mockTask);
            task.Invocation = mockInvocation.Object;

            var mockNotifySubscribers = new Mock <NotifySubscribersOfTaskExecution>();

            task.NotifySubscribersOfTaskExecution = mockNotifySubscribers.Object;

            // Act
            task.Execute();

            // Assert
            mockNotifySubscribers.VerifySet(notifySubscribers => notifySubscribers.ExecutingTask = mockTask);
            mockNotifySubscribers.Verify(notifySubscribers => notifySubscribers.Execute(), Times.Once());
        }
Пример #11
0
        public async Task DeleteProjectsUnreferencedByTasksInInaccessibleWorkspace()
        {
            var accessibleWorkspace   = new MockWorkspace(1000, isInaccessible: false);
            var inaccessibleWorkspace = new MockWorkspace(2000, isInaccessible: true);

            var project1 = new MockProject(101, accessibleWorkspace, syncStatus: SyncStatus.InSync);
            var project2 = new MockProject(102, accessibleWorkspace, syncStatus: SyncStatus.RefetchingNeeded);
            var project3 = new MockProject(201, inaccessibleWorkspace, syncStatus: SyncStatus.InSync);
            var project4 = new MockProject(202, inaccessibleWorkspace, syncStatus: SyncStatus.SyncNeeded);
            var project5 = new MockProject(203, inaccessibleWorkspace, syncStatus: SyncStatus.SyncNeeded);
            var project6 = new MockProject(204, inaccessibleWorkspace, syncStatus: SyncStatus.InSync);
            var project7 = new MockProject(205, inaccessibleWorkspace, syncStatus: SyncStatus.InSync);

            var task1 = new MockTask(1001, accessibleWorkspace, project1, SyncStatus.InSync);
            var task2 = new MockTask(1002, accessibleWorkspace, project2, SyncStatus.RefetchingNeeded);
            var task3 = new MockTask(1003, accessibleWorkspace, project2, SyncStatus.SyncNeeded);
            var task4 = new MockTask(2001, inaccessibleWorkspace, project3, SyncStatus.InSync);
            var task5 = new MockTask(2002, inaccessibleWorkspace, project4, SyncStatus.RefetchingNeeded);
            var task6 = new MockTask(2003, inaccessibleWorkspace, project3, SyncStatus.SyncNeeded);
            var task7 = new MockTask(2004, inaccessibleWorkspace, project4, SyncStatus.InSync);
            var task8 = new MockTask(2005, inaccessibleWorkspace, project4, SyncStatus.InSync);

            var projects    = new[] { project1, project2, project3, project4, project5, project6, project7 };
            var tasks       = new[] { task1, task2, task3, task4, task5, task6, task7, task8 };
            var timeEntries = new IThreadSafeTimeEntry[] { };

            var unreferencedProjects = new[] { project6, project7 };
            var neededProjects       = projects.Where(project => !unreferencedProjects.Contains(project));

            configureDataSource(projects, tasks, timeEntries);

            await state.Start().SingleAsync();

            projectsDataSource.Received().DeleteAll(Arg.Is <IEnumerable <IThreadSafeProject> >(arg =>
                                                                                               arg.All(project => unreferencedProjects.Contains(project)) &&
                                                                                               arg.None(project => neededProjects.Contains(project))));
        }
Пример #12
0
 public void RunMockApp() {
 	var viewManager = new FakeViewDeck();
 	var task = new MockTask();
     RunMockAppHelper(task, viewManager);
 }
        public void LoadConsoleTest()
        {
            var p          = new ConsolePlanning();
            var firstTask  = new MockTask();
            var secondTask = new MockTask();
            int index      = 10;

            p.currentDayIndex = index;
            p.SetContent(new List <IWeek>
            {
                new IWeek(new List <AbstractDay> {
                    new Day(new List <AbstractTask> {
                        firstTask
                    }),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                }),
                new IWeek(new List <AbstractDay> {
                    new Day(new List <AbstractTask> {
                        secondTask
                    }),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(),
                    new Day(new List <AbstractTask> {
                        new MockTask()
                    }),
                })
            });

            p.SetPreMenu(new PreMenu(new List <PreMenuChoice>
            {
                new ShortPauseChoice()
            }));
            var rm = new ConsoleRoadmap(p);

            rm.ShowRoadmap();
            var loader = new PlanningLoader();
            var json   = loader.GetJson(p);
            AbstractPlanning loadedPlanningMemory = loader.LoadFromJson(json, typeof(ConsolePlanning));

            Assert.IsNotNull(loadedPlanningMemory);
            Assert.IsNotNull(loadedPlanningMemory.GetDays());
            Assert.IsNotNull(loadedPlanningMemory.preMenu.availableChoices);
            string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Loaded planning test.json";

            loader.Save(path, loadedPlanningMemory);
            AbstractPlanning loadedPlanningWithFile = loader.Load(path, typeof(ConsolePlanning));

            Assert.IsNotNull(loadedPlanningWithFile);
            Assert.IsNotNull(loadedPlanningMemory.GetDays());
            Assert.IsTrue(loadedPlanningMemory.GetDays().Count > 0);
            Assert.IsNotNull(loadedPlanningMemory.preMenu.availableChoices);
            File.Delete(path);

            Assert.AreEqual(index, p.currentDayIndex);
        }