public AwaitableCommandInfo(AppToUCICommand command) : base(command) { if (ExpectedResponses.Length != 1) { throw new ArgumentException("Awaitable Command must have one expected response."); } ExpectedResponse = ExpectedResponses[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); }
public InterruptCommand(AppToUCICommand command) : base(command) { }
public static int GetExpectedArgCount(AppToUCICommand command) { var countStr = command.AsString(ArgumentCountFormat); return(int.Parse(countStr)); }
//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))); }
public static string[] GetExpectedResponse(AppToUCICommand command) { var str = command.AsString(UCIResponseFormat); return(str.Split('|')); }
public static string GetCommandString(AppToUCICommand command) { return(command.AsString(UciCommandFormat)); }
public static bool IsInterruptCommand(this AppToUCICommand command) { return(new[] { AppToUCICommand.Stop, AppToUCICommand.Quit }.Contains(command)); }