public void CancelTests() { var adjudicator = new Mock <IAdjudicator>(); var blackBot = new Mock <IGoBot>(); var whiteBot = new Mock <IGoBot>(); int count = 0; adjudicator.Setup(s => s.Dispose()).Callback(() => count++); blackBot.Setup(s => s.Dispose()).Callback(() => count++); whiteBot.Setup(s => s.Dispose()).Callback(() => count++); blackBot.Setup(s => s.Name).Returns(() => "Alice"); whiteBot.Setup(s => s.Name).Returns(() => "Tony"); IBotRunner botRunner = new BotRunner(adjudicator.Object, blackBot.Object, whiteBot.Object); Assert.Equal(0, count); botRunner.Cancel(); Assert.Equal(3, count); adjudicator.VerifyAll(); blackBot.VerifyAll(); whiteBot.VerifyAll(); }
private static async Task DoTest(BenchmarkSettings settings) { Console.WriteLine("____________________________________"); Console.WriteLine("Board size: {0}, bot #1 strength : {1}, bot #2 strength: {2}", settings.BoardSize, settings.FirstBotLevel, settings.SecondBotLevel); tcs = new TaskCompletionSource <bool>(); Watch.Restart(); var botWhite = botFactory.CreateBotInstance(botKind, "WhiteBot"); botWhite.BoardSize = settings.BoardSize; botWhite.Level = settings.FirstBotLevel; var botBlack = botFactory.CreateBotInstance(new BotKind { BinaryPath = botKind.BinaryPath, FullClassName = botKind.FullClassName }, "BlackBot"); botBlack.BoardSize = settings.BoardSize; botBlack.Level = settings.SecondBotLevel; var judge = new Adjudicator( Bootstrap(), new Duel { BoardSize = settings.BoardSize, BlackBot = "BlackBot", WhiteBot = "WhiteBot", Name = "Benchmarking" }) { SaveGameResults = true, GenerateLastBoard = true }; var runner = new BotRunner(judge, botBlack, botWhite) { EndGame = OnTestFinised }; await tcs.Task; runner.Cancel(); }