예제 #1
0
        public void TestReadBool()
        {
            Task server = Task.Run(() =>
            {
                pipe.WaitForConnection();
                Assert.AreEqual(true, protocol.ReadBool());
                Assert.AreEqual(false, protocol.ReadBool());
            });

            using (Stream client = CreateClient())
            {
                foreach (bool target in new[] { true, false })
                {
                    PipeUtilities.SendBoolToPipe(client, target);
                }
            }

            server.Wait();
        }
예제 #2
0
        public void TestReadBool()
        {
            Task server = Task.Run(() =>
            {
                pipe.WaitForConnection();
                Assert.AreEqual(true, protocol.ReadBool());
                Assert.AreEqual(false, protocol.ReadBool());
            });
            Socket client = CreateClient();

            foreach (bool target in new[] { true, false })
            {
                byte[] buf = BitConverter.GetBytes(target);
                client.Send(BitConverter.GetBytes(buf.Length).Take(4).ToArray());
                // sock.Send(new byte[1] { 1 }); // = true
                // sock.Send(new byte[1] { 0 }); // = false
                client.Send(buf);
            }
            client.Disconnect(false);

            server.Wait();
        }