public void AuthRequest() { _server.Start(); var channel = new Channel(_target, ChannelCredentials.Insecure); Assert.Equal(ChannelState.Idle, channel.State); var client = new GameServerService.GameServerServiceClient(channel); Assert.Equal(ChannelState.Idle, channel.State); var reply1 = client.Authentication(new AuthRequest { AccountName = "Test", AccountPsw = string.Empty }); Assert.True(reply1.RequestState); Assert.Equal(10000, reply1.SessionId); var reply2 = client.Authentication(new AuthRequest { AccountName = "Test", AccountPsw = string.Empty }); Assert.False(reply2.RequestState); _server.Stop(); }
public async void GameQueueRequest() { _server.Start(); var channel1 = new Channel(_target, ChannelCredentials.Insecure); Assert.Equal(ChannelState.Idle, channel1.State); var client1 = new GameServerService.GameServerServiceClient(channel1); Assert.Equal(ChannelState.Idle, channel1.State); var reply1 = client1.Authentication(new AuthRequest { AccountName = "Test", AccountPsw = string.Empty }); Assert.True(reply1.RequestState); Assert.Equal(10000, reply1.SessionId); // Initialisation using (var call = client1.GameServerChannel(headers: new Metadata { new Metadata.Entry("token", reply1.SessionToken) })) { await call.RequestStream.WriteAsync(new GameServerStream { MessageType = MsgType.Initialisation, Message = string.Empty }); Assert.True(await call.ResponseStream.MoveNext()); Assert.Equal(MsgType.Initialisation, call.ResponseStream.Current.MessageType); Assert.True(call.ResponseStream.Current.MessageState); } // GameQueue var reply2 = client1.GameQueue( new QueueRequest { GameType = GameType.Normal, DeckType = DeckType.Random, DeckData = string.Empty }, new Metadata { new Metadata.Entry("token", reply1.SessionToken) }); Assert.True(reply2.RequestState); _server.Stop(); }
public void PingRequest() { _server.Start(); var channel = new Channel(_target, ChannelCredentials.Insecure); Assert.Equal(ChannelState.Idle, channel.State); var client = new GameServerService.GameServerServiceClient(channel); Assert.Equal(ChannelState.Idle, channel.State); var reply = client.Ping(new PingRequest { Message = string.Empty }); Assert.True(reply.RequestState); Assert.Equal("Ping", reply.RequestMessage); _server.Stop(); }
public async void MatchMakerTest() { _server.Start(); var channel1 = new Channel(_target, ChannelCredentials.Insecure); Assert.Equal(ChannelState.Idle, channel1.State); var client1 = new GameServerService.GameServerServiceClient(channel1); Assert.Equal(ChannelState.Idle, channel1.State); var reply11 = client1.Authentication(new AuthRequest { AccountName = "Test1", AccountPsw = string.Empty }); Assert.True(reply11.RequestState); Assert.Equal(10000, reply11.SessionId); // init client1 using (var call = client1.GameServerChannel(headers: new Metadata { new Metadata.Entry("token", reply11.SessionToken) })) { await call.RequestStream.WriteAsync(new GameServerStream { MessageType = MsgType.Initialisation, Message = string.Empty }); Assert.True(await call.ResponseStream.MoveNext()); Assert.Equal(MsgType.Initialisation, call.ResponseStream.Current.MessageType); Assert.True(call.ResponseStream.Current.MessageState); } // queue client1 var reply12 = client1.GameQueue( new QueueRequest { GameType = GameType.Normal, DeckType = DeckType.Random, DeckData = string.Empty }, new Metadata { new Metadata.Entry("token", reply11.SessionToken) }); Assert.True(reply12.RequestState); var channel2 = new Channel(_target, ChannelCredentials.Insecure); Assert.Equal(ChannelState.Idle, channel2.State); var client2 = new GameServerService.GameServerServiceClient(channel2); Assert.Equal(ChannelState.Idle, channel2.State); var reply21 = client2.Authentication(new AuthRequest { AccountName = "Test2", AccountPsw = string.Empty }); Assert.True(reply21.RequestState); Assert.Equal(10001, reply21.SessionId); // init client2 using (var call = client2.GameServerChannel(headers: new Metadata { new Metadata.Entry("token", reply21.SessionToken) })) { await call.RequestStream.WriteAsync(new GameServerStream { MessageType = MsgType.Initialisation, Message = string.Empty }); Assert.True(await call.ResponseStream.MoveNext()); Assert.Equal(MsgType.Initialisation, call.ResponseStream.Current.MessageType); Assert.True(call.ResponseStream.Current.MessageState); } // queue client2 var reply22 = client2.GameQueue( new QueueRequest { GameType = GameType.Normal, DeckType = DeckType.Random, DeckData = string.Empty }, new Metadata { new Metadata.Entry("token", reply21.SessionToken) }); Assert.True(reply22.RequestState); var matchMaker = _server.GetMatchMakerService(); Assert.Equal(0, matchMaker.MatchGames.Count); matchMaker.Start(1); Thread.Sleep(2000); Assert.Equal(1, matchMaker.MatchGames.Count); _server.Stop(); }