public void TryJoinTableThatDoesNotExist() { var server = new BluffinServer(42084, GetType().Assembly.FullName); var tokenServer = new CancellationTokenSource(); Task.Factory.StartNew(server.Start, tokenServer.Token); var client = new ClientForTesting(); var tokenClient = new CancellationTokenSource(); Task.Factory.StartNew(client.Connect, tokenClient.Token); var c = client.ObtainTcpEntity(); IdentifyAs(c, "Player"); JoinUnjoinableTable(c, 1); tokenClient.Cancel(); tokenServer.Cancel(); }
public void BigUglyTest() { StringWriter sw = new StringWriter(); Logger.MessageLogged += (sender, e) => sw.WriteLine("[{0}] {1}", GetCaller(sender), e.Info); var server = new BluffinServer(42084, GetType().Assembly.FullName); var tokenServer = new CancellationTokenSource(); Task.Factory.StartNew(server.Start, tokenServer.Token); var client1 = new ClientForTesting(); var tokenClient1 = new CancellationTokenSource(); Task.Factory.StartNew(client1.Connect, tokenClient1.Token); var c1 = client1.ObtainTcpEntity(); IdentifyAs(c1, "P1"); int idTable = CreateTable(c1); JoinTable(c1, idTable); var client2 = new ClientForTesting(); var tokenClient2 = new CancellationTokenSource(); Task.Factory.StartNew(client2.Connect, tokenClient2.Token); var c2 = client2.ObtainTcpEntity(); IdentifyAs(c2, "P2"); JoinTable(c2, idTable); BeAwareOfOtherPlayerJoined(c1, c2); int s1 = SitInSeat(c1, idTable, 1); BeAwareOfOtherPlayerSatIn(c2, idTable, c1, 1); int s2 = SitInSeat(c2, idTable, 2); BeAwareOfOtherPlayerSatIn(c1, idTable, c2, 2); //GameIsStarting !!! int b1 = GameIsStarting(c1); int b2 = GameIsStarting(c2); PlayMoney(c1, idTable, b1); BeAwareOfMoneyPlayed(c1, idTable, s1); BeAwareOfMoneyPlayed(c2, idTable, s1); PlayMoney(c2, idTable, b2); BeAwareOfMoneyPlayed(c1, idTable, s2); BeAwareOfMoneyPlayed(c2, idTable, s2); BeAwareOfHoleCardDistribution(c1, idTable, s1, s2); BeAwareOfHoleCardDistribution(c2, idTable, s1, s2); BeAwareOfBettingRoundStarted(c1, idTable, 1); BeAwareOfBettingRoundStarted(c2, idTable, 1); BeAwareOfWhoItIsToPlay(c1, idTable, s1); BeAwareOfWhoItIsToPlay(c2, idTable, s1); PlayMoney(c1, idTable, 5); BeAwareOfMoneyPlayed(c1, idTable, s1); BeAwareOfMoneyPlayed(c2, idTable, s1); BeAwareOfWhoItIsToPlay(c1, idTable, s2); BeAwareOfWhoItIsToPlay(c2, idTable, s2); //SitOut(c2, idTable, s2); Thread.Sleep(250); c1.ReceivedCommands.CompleteAdding(); c2.ReceivedCommands.CompleteAdding(); Assert.AreEqual(string.Empty, string.Join(",", c1.ReceivedCommands.GetConsumingEnumerable().Select(x => x.ToString())), sw.ToString()); Assert.AreEqual(string.Empty, string.Join(",", c2.ReceivedCommands.GetConsumingEnumerable().Select(x => x.ToString())), sw.ToString()); tokenClient2.Cancel(); tokenClient1.Cancel(); tokenServer.Cancel(); }