コード例 #1
0
        public void TestHandShakeWithoutMock()
        {
            var transport     = new TcpTransport(9011);
            var gameTransport = new OnlineProtocol(transport);

            gameTransport.HandShake("player");
            var setup = gameTransport.ReadSetup();

            Console.WriteLine(setup.punter);
        }
コード例 #2
0
        public void TestReadSetup()
        {
            var transport     = A.Fake <ITransport>();
            var gameTransport = new OnlineProtocol(transport);
            var setup         = new In
            {
                punter = 1
            };

            A.CallTo(() => transport.Read <In>(A <int?> .Ignored)).Returns(setup);
            gameTransport.ReadSetup();
            A.CallTo(() => transport.Read <In>(A <int?> .Ignored)).MustHaveHappened();
        }
コード例 #3
0
        public void TestHandShake()
        {
            var transport     = A.Fake <ITransport>();
            var gameTransport = new OnlineProtocol(transport);

            A.CallTo(() => transport.Read <HandshakeIn>(A <int> .Ignored)).Returns(new HandshakeIn {
                you = "player"
            });

            gameTransport.HandShake("player");

            A.CallTo(() => transport.Write(A <HandshakeOut> .That.Matches(o => o.me == "player"))).MustHaveHappened();
        }
コード例 #4
0
 public OnlineInteraction(int port, string botName = null)
 {
     this.botName = botName;
     connection   = new OnlineProtocol(new TcpTransport(port));
 }