public void TestCommandFailingSupersedingBecauseFirstCannotBeInterrupted()
        {
            ASubsystem subsystem = new ASubsystem();

            MockCommand command1 = new MockCommand("Num1");
            command1.AddRequires(subsystem);
            command1.SetInterruptable(false);

            MockCommand command2 = new MockCommand("Num2");
            command2.AddRequires(subsystem);

            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            command1.Start();
            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 1, 1, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 2, 2, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 3, 3, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            command2.Start();
            AssertCommandState(command1, 1, 3, 3, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 4, 4, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
        }
예제 #2
0
        public void TestDefaultCommandWhereTheInterruptingCommandEndsItself()
        {
            ASubsystem subsystem = new ASubsystem();

            MockCommand defaultCommand = new MockCommand();

            defaultCommand.AddRequires(subsystem);

            MockCommand anotherCommand = new MockCommand();

            anotherCommand.AddRequires(subsystem);

            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            subsystem.Init(defaultCommand);

            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);

            anotherCommand.Start();
            AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);
            AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
            anotherCommand.SetHasFinished(true);
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 3, 3, 1, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 2, 4, 4, 0, 1);
            AssertCommandState(anotherCommand, 1, 3, 3, 1, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 2, 5, 5, 0, 1);
            AssertCommandState(anotherCommand, 1, 3, 3, 1, 0);
        }
예제 #3
0
        public void TestDefaultCommandInterruptingCommandCanceled()
        {
            ASubsystem subsystem = new ASubsystem();

            MockCommand defaultCommand = new MockCommand();

            defaultCommand.AddRequires(subsystem);

            MockCommand anotherCommand = new MockCommand();

            anotherCommand.AddRequires(subsystem);

            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            subsystem.Init(defaultCommand);
            subsystem.PublicInitDefaultCommand();
            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);

            anotherCommand.Start();
            AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);
            AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
            anotherCommand.Cancel();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 1);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 2, 4, 4, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 1);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 2, 5, 5, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 1);
        }
예제 #4
0
        public void TestDefaultCommandWhereTheInterruptingCommandEndsItself()
        {
            ASubsystem subsystem = new ASubsystem();

            MockCommand defaultCommand = new MockCommand();
            defaultCommand.AddRequires(subsystem);

            MockCommand anotherCommand = new MockCommand();
            anotherCommand.AddRequires(subsystem);

            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            subsystem.Init(defaultCommand);

            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);

            anotherCommand.Start();
            AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);
            AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
            anotherCommand.SetHasFinished(true);
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 3, 3, 1, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 2, 4, 4, 0, 1);
            AssertCommandState(anotherCommand, 1, 3, 3, 1, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 2, 5, 5, 0, 1);
            AssertCommandState(anotherCommand, 1, 3, 3, 1, 0);
        }
예제 #5
0
        public void TestDefaultCommandInterruptingCommandCanceled()
        {
            ASubsystem subsystem = new ASubsystem();

            MockCommand defaultCommand = new MockCommand();
            defaultCommand.AddRequires(subsystem);

            MockCommand anotherCommand = new MockCommand();
            anotherCommand.AddRequires(subsystem);

            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            subsystem.Init(defaultCommand);
            subsystem.PublicInitDefaultCommand();
            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);

            anotherCommand.Start();
            AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);
            AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
            anotherCommand.Cancel();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 1);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 2, 4, 4, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 1);
            Scheduler.Instance.Run();
            AssertCommandState(defaultCommand, 2, 5, 5, 0, 1);
            AssertCommandState(anotherCommand, 1, 2, 2, 0, 1);
        }
예제 #6
0
        public void TestOneCommandSupersedingAnotherBecauseOfDependencies()
        {
            ASubsystem subsystem = new ASubsystem();

            MockCommand command1 = new MockCommand("Num1");

            command1.AddRequires(subsystem);

            MockCommand command2 = new MockCommand("Num2");

            command2.AddRequires(subsystem);

            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            command1.Start();
            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 1, 1, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 2, 2, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 3, 3, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            command2.Start();
            AssertCommandState(command1, 1, 3, 3, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 4, 4, 0, 1);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 4, 4, 0, 1);
            AssertCommandState(command2, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 4, 4, 0, 1);
            AssertCommandState(command2, 1, 2, 2, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 4, 4, 0, 1);
            AssertCommandState(command2, 1, 3, 3, 0, 0);
        }
예제 #7
0
 public void RunTestAndTerminate()
 {
     MockCommand command = new MockCommand();
     command.Start();
     AssertCommandState(command, 0, 0, 0, 0, 0);
     Scheduler.Instance.Run();
     AssertCommandState(command, 0, 0, 0, 0, 0);
     Scheduler.Instance.Run();
     AssertCommandState(command, 1, 1, 1, 0, 0);
     Scheduler.Instance.Run();
     AssertCommandState(command, 1, 2, 2, 0, 0);
     command.SetHasFinished(true);
     AssertCommandState(command, 1, 2, 2, 0, 0);
     Scheduler.Instance.Run();
     AssertCommandState(command, 1, 3, 3, 1, 0);
     Scheduler.Instance.Run();
     AssertCommandState(command, 1, 3, 3, 1, 0);
 }
        public void TestOneCommandSupersedingAnotherBecauseOfDependencies()
        {
            ASubsystem subsystem = new ASubsystem();

            MockCommand command1 = new MockCommand("Num1");
            command1.AddRequires(subsystem);

            MockCommand command2 = new MockCommand("Num2");
            command2.AddRequires(subsystem);

            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            command1.Start();
            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 1, 1, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 2, 2, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 3, 3, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            command2.Start();
            AssertCommandState(command1, 1, 3, 3, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 4, 4, 0, 1);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 4, 4, 0, 1);
            AssertCommandState(command2, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 4, 4, 0, 1);
            AssertCommandState(command2, 1, 2, 2, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 4, 4, 0, 1);
            AssertCommandState(command2, 1, 3, 3, 0, 0);
        }
예제 #9
0
        public void RunTestAndTerminate()
        {
            MockCommand command = new MockCommand();

            command.Start();
            AssertCommandState(command, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command, 1, 2, 2, 0, 0);
            command.SetHasFinished(true);
            AssertCommandState(command, 1, 2, 2, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command, 1, 3, 3, 1, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command, 1, 3, 3, 1, 0);
        }
예제 #10
0
 public void TestRunAndCancel()
 {
     MockCommand command = new MockCommand();
     command.Start();
     AssertCommandState(command, 0, 0, 0, 0, 0);
     Scheduler.Instance.Run();
     AssertCommandState(command, 0, 0, 0, 0, 0);
     Scheduler.Instance.Run();
     AssertCommandState(command, 1, 1, 1, 0, 0);
     Scheduler.Instance.Run();
     AssertCommandState(command, 1, 2, 2, 0, 0);
     Scheduler.Instance.Run();
     AssertCommandState(command, 1, 3, 3, 0, 0);
     command.Cancel();
     AssertCommandState(command, 1, 3, 3, 0, 0);
     Scheduler.Instance.Run();
     AssertCommandState(command, 1, 3, 3, 0, 1);
     Scheduler.Instance.Run();
     AssertCommandState(command, 1, 3, 3, 0, 1);
 }
예제 #11
0
        public void TestRunAndCancel()
        {
            MockCommand command = new MockCommand();

            command.Start();
            AssertCommandState(command, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command, 1, 1, 1, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command, 1, 2, 2, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command, 1, 3, 3, 0, 0);
            command.Cancel();
            AssertCommandState(command, 1, 3, 3, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command, 1, 3, 3, 0, 1);
            Scheduler.Instance.Run();
            AssertCommandState(command, 1, 3, 3, 0, 1);
        }
예제 #12
0
        public void TestCommandFailingSupersedingBecauseFirstCannotBeInterrupted()
        {
            ASubsystem subsystem = new ASubsystem();

            MockCommand command1 = new MockCommand("Num1");

            command1.AddRequires(subsystem);
            command1.SetInterruptable(false);

            MockCommand command2 = new MockCommand("Num2");

            command2.AddRequires(subsystem);

            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            command1.Start();
            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 0, 0, 0, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 1, 1, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 2, 2, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 3, 3, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            command2.Start();
            AssertCommandState(command1, 1, 3, 3, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
            Scheduler.Instance.Run();
            AssertCommandState(command1, 1, 4, 4, 0, 0);
            AssertCommandState(command2, 0, 0, 0, 0, 0);
        }