Ejemplo n.º 1
0
        public void Test_TaskMan_SplitsOutputMessagesIntoLines()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommand("add " + "ABCDE ".Replicate(10000));

            Assert.That(tester.Output.Split('\n').HasAtLeastTwoElements());
        }
Ejemplo n.º 2
0
        public void Test_SilentFlag_MakesTaskAddingSilent()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommand("add --silent Remember the milk");

            Assert.That(string.IsNullOrWhiteSpace(tester.Output));
        }
Ejemplo n.º 3
0
        public void Test_Delete_DeletesTasks()
        {
            TaskManTester tester = new TaskManTester();

            tester.AddThreeTasks();
            tester.RunWithCommand("delete --all");

            Assert.IsEmpty(tester.SavedTasks);
        }
Ejemplo n.º 4
0
        public void Test_TaskMan_DoesNotPrintStackTrace_When_NoVerboseFlag()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommand("self-destruct");

            Assert.That(
                !tester.Errors.ContainsFormat(Messages.ExceptionStackTrace));
        }
Ejemplo n.º 5
0
        public void Test_VerboseFlag_IncreasesErrorVerbosity()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommand("self-destruct --verbose");

            Assert.That(
                tester.Errors.ContainsFormat(Messages.ExceptionStackTrace));
        }
Ejemplo n.º 6
0
        public void Test_TaskMan_OutputsSimilarCommandOnTypo()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommand("shom");

            Assert.That(tester.Errors.ContainsFormat(Messages.DidYouMean));
            Assert.That(tester.Errors, Does.Contain("show").IgnoreCase);
        }
Ejemplo n.º 7
0
        public void Test_TaskMan_OutputsPossibleCommandsOnAmbiguity()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommand("s");

            Assert.That(
                tester.Errors.ContainsFormat(Messages.MoreThanOneCommandMatchesInput));
        }
Ejemplo n.º 8
0
        public void Test_FormatFlag_WorksWithXMLFormat()
        {
            TaskManTester tester = new TaskManTester();

            tester.AddThreeTasks();
            tester.RunWithCommand("show --format xml");

            Assert.That(true);
        }
Ejemplo n.º 9
0
        public void Test_PriorityFlag_SetsPriority_When_AddingNewTask()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommand("add -p Critical first");

            Assert.That(
                tester.SavedTasks.Single().Priority,
                Is.EqualTo(Priority.Critical));
        }
Ejemplo n.º 10
0
        public void Test_Add_AddsTask()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommand("add Remember the milk");

            Assert.IsNotEmpty(tester.SavedTasks);
            Assert.That(
                tester.SavedTasks.First().Description,
                Is.EqualTo("Remember the milk"));
        }
Ejemplo n.º 11
0
        public void Test_Update_UpdatesPriority()
        {
            TaskManTester tester = new TaskManTester();

            tester.AddThreeTasks();
            tester.RunWithCommands("update --all priority Important");

            Assert.That(
                tester.SavedTasks,
                Is.All.Matches <Task>(task => task.Priority == Priority.Important));
        }
Ejemplo n.º 12
0
        public void Test_Update_UpdatesFinished()
        {
            TaskManTester tester = new TaskManTester();

            tester.AddThreeTasks();
            tester.RunWithCommands("update --all finished true");

            Assert.That(
                tester.SavedTasks,
                Is.All.Matches <Task>(task => task.IsFinished));
        }
Ejemplo n.º 13
0
        public void Test_Update_UpdatesDescription()
        {
            TaskManTester tester = new TaskManTester();

            tester.AddThreeTasks();
            tester.RunWithCommand("update --all description NEW");

            Assert.That(
                tester.SavedTasks,
                Is.All.Matches <Task>(task => task.Description == "NEW"));
        }
Ejemplo n.º 14
0
        public void Test_InteractiveFlag_AllowsTheUserToConfirmOperation()
        {
            TaskManTester tester = new TaskManTester();

            tester.AddThreeTasks();
            tester.Input = "yes";

            tester.RunWithCommand("delete --all --interactive");

            Assert.That(tester.SavedTasks, Is.Empty);
        }
Ejemplo n.º 15
0
        public void Test_Complete_CompletesTasks()
        {
            TaskManTester tester = new TaskManTester();

            tester.AddThreeTasks();
            tester.RunWithCommand("complete --all");

            Assert.That(
                tester.SavedTasks,
                Is.All.Matches <Task>(task => task.IsFinished));
        }
Ejemplo n.º 16
0
        public void Test_InteractiveFlag_AllowsTheUserToAbortOperation()
        {
            TaskManTester tester = new TaskManTester();

            tester.AddThreeTasks();
            tester.Input = "no";

            tester.RunWithCommand("delete --all --interactive");

            Assert.That(() => tester.Output.ContainsFormat(Messages.Cancelled));
            Assert.That(tester.SavedTasks.Count, Is.EqualTo(3));
        }
Ejemplo n.º 17
0
        public void Test_VersionFlag_OutputsVersion()
        {
            TaskManTester tester = new TaskManTester();

            const string expectedSubstring = "version";

            tester.RunWithCommand("--version");

            Assert.That(
                tester.Output,
                Contains.Substring(expectedSubstring));
        }
Ejemplo n.º 18
0
        public void Test_LicenseFlag_OutputsLicense()
        {
            TaskManTester tester = new TaskManTester();

            const string expectedSubstring = "GNU GENERAL PUBLIC LICENSE";

            tester.RunWithCommand("--license");

            Assert.That(
                tester.Output,
                Contains.Substring(expectedSubstring));
        }
Ejemplo n.º 19
0
        public void Test_TaskMan_RequiresExplicitFilteringOnDelete()
        {
            TaskManTester tester = new TaskManTester();

            tester.AddThreeTasks();

            tester.RunWithCommand("delete");

            Assert.That(tester.SavedTasks.Any());
            Assert.That(
                tester.Errors.ContainsFormat(Messages.NoFilterConditionsUseAllIfIntended));
        }
Ejemplo n.º 20
0
        public void Test_New_IsTheSameAsAdd()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommands(
                "add Remember the milk",
                "new Remember the milk");

            Assert.That(tester.SavedTasks.Count(), Is.EqualTo(2));
            Assert.That(
                tester.SavedTasks.First().Description,
                Is.EqualTo(tester.SavedTasks.Last().Description));
        }
Ejemplo n.º 21
0
        public void Test_LimitFlag_HasLowerPriorityThanSkipFlag()
        {
            TaskManTester tester = new TaskManTester();

            tester.AddThreeTasks();
            tester.RunWithCommand("show --limit 1 --skip 2");

            Assert.That(
                tester.Output,
                Does.Not.Contain("first")
                .And.Not.Contain("second")
                .And.Contains("third"));
        }
Ejemplo n.º 22
0
        public void Test_PriorityFlag_FiltersByPriority()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommands(
                "add first",
                "add second -p Important",
                "add third",
                "delete -p Normal");

            Assert.That(
                tester.SavedTasks.Single().Priority,
                Does.Not.EqualTo(Priority.Normal));
        }
Ejemplo n.º 23
0
        public void Test_DescriptionRegexFlag_FiltersTasksByDescription()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommands(
                "add mario --silent",
                "add wario --silent",
                "add princess --silent",
                "add bowser --silent",
                "show --like ario");

            Assert.That(
                tester.Output,
                Does.Contain("mario")
                .And.Contain("wario")
                .And.Not.Contain("princess")
                .And.Not.Contain("bowser"));
        }
Ejemplo n.º 24
0
        public void Test_Renumber_RenumbersTasksInGivenOrder()
        {
            TaskManTester tester = new TaskManTester();

            tester.RunWithCommands(
                "add 1",
                "add 2",
                "add 3");

            Assert.That(
                tester.SavedTasks.Select(t => t.Description),
                Is.EquivalentTo(new[] { "1", "2", "3" }));

            tester.RunWithCommand("renumber --orderby id-");

            Assert.That(
                tester.SavedTasks.Select(t => t.Description),
                Is.EquivalentTo(new[] { "3", "2", "1" }));
        }