Пример #1
0
        public void Send()
        {
            var task = StartServerSingleRead(_buffToSend.Length);

            using (var transport = new NamedPipeTransport(_pipeName))
            {
                Assert.True(transport.Send(_buffToSend, _buffToSend.Length));
            }

            CollectionAssert.AreEqual(task.Result, _buffToSend);
        }
Пример #2
0
 public void Reconnection()
 {
     using (var transport = new NamedPipeTransport(_pipeName))
     {
         for (int i = 0; i < 3; i++)
         {
             var task = StartServerSingleRead(_buffToSend.Length);
             Assert.True(transport.Send(_buffToSend, _buffToSend.Length));
             CollectionAssert.AreEqual(task.Result, _buffToSend);
         }
     }
 }
Пример #3
0
        public void NoTimeout()
        {
            var task = StartServerMultipleReads(4, _serverBufferSize, TimeSpan.FromSeconds(1));

            using (var transport = new NamedPipeTransport(_pipeName, TimeSpan.FromSeconds(2)))
            {
                var buff = new byte[_serverBufferSize];
                for (int i = 0; i < 4; ++i)
                {
                    Assert.True(transport.Send(buff, buff.Length));
                }
            }

            task.Wait();
        }
Пример #4
0
        public void Timeout()
        {
            var task = StartServerMultipleReads(4, _serverBufferSize, TimeSpan.FromSeconds(1));

            using (var transport = new NamedPipeTransport(_pipeName, TimeSpan.FromMilliseconds(100)))
            {
                var  buff       = new byte[_serverBufferSize];
                bool bufferSent = true;
                for (int i = 0; i < 4; ++i)
                {
                    bufferSent = bufferSent && transport.Send(buff, buff.Length);
                }

                Assert.False(bufferSent);
            }

            task.Wait();
        }