Exemplo n.º 1
0
        IDataProducer AsyncProducer()
        {
            var result = new MockDataProducer(c =>
            {
                Action secondWrite = () =>
                {
                    if (!c.OnData(new ArraySegment<byte>(Encoding.ASCII.GetBytes("some other data")), () => c.OnEnd()))
                        c.OnEnd();
                };

                if (!c.OnData(new ArraySegment<byte>(Encoding.ASCII.GetBytes("some data")), secondWrite))
                    secondWrite();
                return null;
            });
            mockProducers.Add(result);
            return result;
        }
Exemplo n.º 2
0
        IDataProducer SyncProducer(params string[] data)
        {
            var result = new MockDataProducer(c =>
            {
                foreach (var d in data)
                    c.OnData(new ArraySegment<byte>(Encoding.ASCII.GetBytes(d)), null);

                c.OnEnd();
                return null;
            });
            mockProducers.Add(result);
            return result;
        }
Exemplo n.º 3
0
 IDataProducer SyncProducer()
 {
     var result = new MockDataProducer(c =>
     {
         c.OnData(new ArraySegment<byte>(Encoding.ASCII.GetBytes("some data")), null);
         c.OnData(new ArraySegment<byte>(Encoding.ASCII.GetBytes("some other data")), null);
         c.OnEnd();
         return null;
     });
     mockProducers.Add(result);
     return result;
 }
Exemplo n.º 4
0
 IDataProducer AsyncProducer(params string[] data)
 {
     var result = new MockDataProducer(c =>
     {
         RunAsyncProd(c, data.Select(s => new ArraySegment<byte>(Encoding.UTF8.GetBytes(s))).GetEnumerator());
         return null;
     });
     mockProducers.Add(result);
     return result;
 }