Example #1
0
        public AwaitableCommandInfo(AppToUCICommand command) : base(command)
        {
            if (ExpectedResponses.Length != 1)
            {
                throw new ArgumentException("Awaitable Command must have one expected response.");
            }

            ExpectedResponse = ExpectedResponses[0];
        }
Example #2
0
 public CommandInfo(AppToUCICommand command)
 {
     ArgumentCount = CommandAttribute.GetExpectedArgCount(command);
     CommandSent   = command;
     CommandText   = CommandAttribute.GetCommandString(command);
     // ExpectedResponseFlags = command.
     ExpectedResponses = CommandAttribute.GetExpectedResponse(command);
     ExactMatch        = CommandAttribute.GetExactMatch(command);
     CommandArguments  = new string[] { };
 }
        public void TestEnqueueInterruptCommand_ClearsExistingCommands(AppToUCICommand interruptCommand)
        {
            var expectedSize = 5;

            for (var i = 0; i < expectedSize; i++)
            {
                q.Enqueue(new CommandInfo(AppToUCICommand.IsReady));
            }

            Assert.AreEqual(expectedSize, q.Count());
            q.Enqueue(new InterruptCommand(interruptCommand));
            Assert.AreEqual(1, q.Count());
        }
        public void TestEnqueueInterruptCommand_SendsAppropriateEvent(AppToUCICommand interruptCommand,
                                                                      bool shouldReceiveInterruptEvent)
        {
            var expectedSize       = 5;
            var timeout            = 100;
            var expectedWaitHandle = shouldReceiveInterruptEvent ? 0 : WaitHandle.WaitTimeout;

            for (var i = 0; i < expectedSize; i++)
            {
                q.Enqueue(new CommandInfo(AppToUCICommand.IsReady));
            }

            Assert.AreEqual(expectedSize, q.Count());
            q.Enqueue(new InterruptCommand(interruptCommand));
            var waitHandle = WaitHandle.WaitAny(new[] { q.InterruptIssued }, timeout);

            Assert.AreEqual(expectedWaitHandle, waitHandle);
        }
Example #5
0
 public InterruptCommand(AppToUCICommand command) : base(command)
 {
 }
Example #6
0
        public static int GetExpectedArgCount(AppToUCICommand command)
        {
            var countStr = command.AsString(ArgumentCountFormat);

            return(int.Parse(countStr));
        }
Example #7
0
        //public static UCIToAppCommand GetExpectedResponseFlags(AppToUCICommand command)
        //{
        //    return Enum.Parse(typeof(UCIToAppCommand), command.AsString(uciResponseFlagsFormat));
        //}

        public static bool GetExactMatch(AppToUCICommand command)
        {
            return(bool.Parse(command.AsString(UCIExactMatchFormat)));
        }
Example #8
0
        public static string[] GetExpectedResponse(AppToUCICommand command)
        {
            var str = command.AsString(UCIResponseFormat);

            return(str.Split('|'));
        }
Example #9
0
 public static string GetCommandString(AppToUCICommand command)
 {
     return(command.AsString(UciCommandFormat));
 }
Example #10
0
 public static bool IsInterruptCommand(this AppToUCICommand command)
 {
     return(new[] { AppToUCICommand.Stop, AppToUCICommand.Quit }.Contains(command));
 }