public void ExecuteTest() { // Create the mock engine MockChessEngine engine = new MockChessEngine(); // Create the 'set option' command string mockOptionName = "OptionName"; string mockOptionValue = "OptionValue"; UciSetOptionCommand command = new UciSetOptionCommand(mockOptionName, mockOptionValue); // Execute against the mock command.Execute(engine); // The command should either be // A) setoption name {name} value {value} // B) setoption name {name} string expected = String.Format("setoption name {0} value {1}", mockOptionName, mockOptionValue); // Verify commands sent Trace.WriteLine(String.Format("Verifying UciSetOptionCommand sends correct command to the engine...")); Assert.AreEqual(engine.CommandString, expected); Assert.AreEqual(engine.ExpectedResponse, String.Empty); command = new UciSetOptionCommand(mockOptionName); // Execute against the mock command.Execute(engine); expected = String.Format("setoption name {0}", mockOptionName); // Verify commands sent Trace.WriteLine(String.Format("Verifying UciSetOptionCommand sends correct command to the engine...")); Assert.AreEqual(engine.CommandString, expected); Assert.AreEqual(engine.ExpectedResponse, String.Empty); }
public void ExecuteTest() { // Mock stream in memory MemoryStream stream = new MockStream(); StreamWriter writer = new StreamWriter(stream); writer.AutoFlush = true; // Create the mock engine MockChessEngine engine = new MockChessEngine(); // Create the 'isready' command UciIsReadyCommand command = new UciIsReadyCommand(ref writer); // Execute against the mock command.Execute(engine); // Now get that string back from the stream stream.Position = 0; StreamReader reader = new StreamReader(stream); string streamString = reader.ReadLine(); // Verify commands sent - in this case the command is written // directly to the stream - so verify it gets there // The engine does not record the expected in this case so it // should remain empty in the mock Trace.WriteLine(String.Format("Verifying UciIsReadyCommand sends correct command to the engine...")); Assert.AreEqual(UCIChessEngine.IsReady, streamString); Assert.AreEqual(String.Empty, engine.ExpectedResponse); }
public void ExecuteTest() { // Create the mock engine MockChessEngine engine = new MockChessEngine(); // Create the 'init uci' command UciInitCommand command = new UciInitCommand(); // Execute against the mock command.Execute(engine); // Verify commands sent Trace.WriteLine(String.Format("Verifying UciInitCommand sends correct command to the engine...")); Assert.AreEqual(engine.CommandString, UCIChessEngine.Uci); Assert.AreEqual(engine.ExpectedResponse, UCIChessEngine.UciOk); }
public void ExecuteTest() { // Create the mock engine MockChessEngine engine = new MockChessEngine(); // Create the 'position' command UciPositionCommand command = new UciPositionCommand(ChessBoard.InitialFENPosition); // Execute against the mock command.Execute(engine); // Verify commands sent Trace.WriteLine(String.Format("Verifying UciPositionCommand sends correct command to the engine...")); string expected = String.Format("position fen {0}", ChessBoard.InitialFENPosition); Assert.AreEqual(engine.CommandString, expected); Assert.AreEqual(engine.ExpectedResponse, String.Empty); }
public void ExecuteTest() { string moveTime = "543210"; // Create the mock engine MockChessEngine engine = new MockChessEngine(); // Create the 'UciGoCommand' command UciGoCommand command = new UciGoCommand(moveTime); // Execute against the mock command.Execute(engine); // Verify commands sent Trace.WriteLine(String.Format("Verifying UciGoCommand sends correct command to the engine...")); string expected = String.Format("go movetime {0}", moveTime); Assert.AreEqual(engine.CommandString, expected); Assert.AreEqual(engine.ExpectedResponse, UCIChessEngine.BestMoveResponse); }
public void ExecuteTest() { // Create the mock engine MockChessEngine engine = new MockChessEngine(); string mockPath = @"x:\foo\bar\mymockengine.exe"; UciLoadEngineCommand command = new UciLoadEngineCommand(mockPath); // Execute against the mock command.Execute(engine); // Verify commands sent Trace.WriteLine(String.Format("Verifying UciLoadEngineCommand sends correct command to the engine...")); // IChessEngine.LoadEngineProces() records this in the mock, and // we're testing that layer correctly gets the path passed in here Assert.AreEqual(engine.ExePath, mockPath); Assert.AreEqual(engine.ExpectedResponse, String.Empty); }