public void 到達保証あり逆順受信テスト() { var ctx = new TestChannelContext(); var config = new ReliableChannelConfig { Timeout = TimeSpan.FromSeconds(60), MaxWindowSize = 1000, Ordered = false }; using (var control = new ReliableFlowControl(1, 1, ctx, config)) { List <byte[]> buf = new List <byte[]>(); short id = 1; for (int i = 0; i < 100; i++) { buf.Add(GetRandam(200 + i * 100)); control.Send(GetFragments(buf[buf.Count - 1], id++, Fragment.Size)); } buf.Reverse(); ctx.Reverse(); int count = 0; while (count < buf.Count && ctx.Receive(control, out var output)) { var ret = output.ToBytes(); Assert.IsTrue(Equals(buf[count++], ret), "逆順に届く"); output.RemoveRef(true); } Assert.AreEqual(buf.Count, count, "同じ数読み取れている"); } }
public void 到達保証ありチャンネルパケロステスト() { foreach (var ordered in new bool[] { true, false }) { var ctx = new TestChannelContext(); var config = new ReliableChannelConfig { Ordered = ordered }; using (var control = new ReliableFlowControl(1, 1, ctx, config)) { List <byte[]> buf = new List <byte[]>(); short id = 1; for (int i = 0; i < 10; i++) { buf.Add(GetRandam(200 + i * 100)); control.Send(GetFragments(buf[buf.Count - 1], id++, Fragment.Size)); } for (int i = 0; i < 50; i++) { buf.Add(GetRandam(2000 + (int)(10000 * m_Random.NextDouble()))); control.Send(GetFragments(buf[buf.Count - 1], id++, Fragment.Size)); } ctx.ShuffleSentQueue(); int count = 0; while (count < buf.Count && ctx.Receive(control, out var output, 0.3)) { ctx.ShuffleSentQueue(); var ret = output.ToBytes(); if (ordered) { Assert.IsTrue(Equals(buf[count++], ret), "順番に届く"); } else { count++; } output.RemoveRef(true); } Assert.AreEqual(buf.Count, count, "同じ数読み取れている"); } } }