public void TestSend() { var fp = FragPipe.Instance; var head_c = new HeaderChop(new PType("frag").ToMemBlock()); fp.Subscribe(head_c, null); var fh = new FragmentingHandler(1000); head_c.Subscribe(fh, null); var th = new TestHandler(); fh.Subscribe(th, null); head_c.WithoutHeader.Subscribe(th, null); var fs = new FragmentingSender(100, fp); var r = new System.Random(); for (int length = 1; length < 10000; length++) { var buf = new byte[length]; r.NextBytes(buf); var dat = MemBlock.Reference(buf); fs.Send(dat); //This will do the assert. Assert.AreEqual(dat, th.LastData, "Data was received"); } }
public void EqTest() { var fp = FragPipe.Instance; //Get some sender var fs1 = new FragmentingSender(100, fp); var fs2 = new FragmentingSender(100, fp); Assert.AreEqual(fs1, fs2); Assert.AreEqual(fs1.GetHashCode(), fs2.GetHashCode()); //urlencode sender:pipe Assert.AreEqual(fs1.ToUri(), "sender:frag?max=100&wrap=sender%3apipe"); Assert.AreEqual(fs1, SenderFactory.CreateInstance(null, fs1.ToUri()), "uri RT"); }
public void TestSend() { var fp = FragPipe.Instance; var head_c = new HeaderChop(new PType("frag").ToMemBlock()); fp.Subscribe(head_c, null); var fh = new FragmentingHandler(1000); head_c.Subscribe(fh, null); var th = new TestHandler(); fh.Subscribe(th, null); head_c.WithoutHeader.Subscribe(th, null); var fs = new FragmentingSender(100, fp); var r = new System.Random(); for(int length = 1; length < 10000; length++) { var buf = new byte[length]; r.NextBytes(buf); var dat = MemBlock.Reference(buf); fs.Send(dat); //This will do the assert. Assert.AreEqual(dat, th.LastData, "Data was received"); } }