public void ConsumeDataKeysTest() { EasyCollaboration target = new EasyCollaboration(context); target.StartCollaboration(); List <byte[]> actual = null; List <byte[]> datakeys = new List <byte[]>(); datakeys.Add(ASCIIEncoding.Default.GetBytes("test")); datakeys.Add(ASCIIEncoding.Default.GetBytes("test1")); datakeys.Add(ASCIIEncoding.Default.GetBytes("test2")); datakeys.Add(ASCIIEncoding.Default.GetBytes("test3")); omg.org.CORBA.TypeCode byteTC = context.ORB.create_octet_tc(); omg.org.CORBA.TypeCode sequenceTC = context.ORB.create_sequence_tc(0, byteTC); try { actual = target.ConsumeDataKeys(); Assert.AreEqual(0, actual.Count); target.ShareDataKeys(datakeys); Thread.Sleep(4000); actual = target.ConsumeDataKeys(); Assert.AreEqual(datakeys.Count, actual.Count); for (int i = 0; i < datakeys.Count; i++) { CollectionAssert.AreEqual(datakeys[i], actual[i]); } } finally { target.ExitCollaboration(); } target = new EasyCollaboration(context, null, null); target.StartCollaboration(); try { actual = target.ConsumeDataKeys(); Assert.AreEqual(0, actual.Count); target.ShareDataKeys(datakeys); Thread.Sleep(2000); actual = target.ConsumeDataKeys(); Assert.AreEqual(0, actual.Count); } finally { target.ExitCollaboration(); } }
private void Receive_click(object sender, EventArgs e) { var datakeys = easy.ConsumeDataKeys(); foreach (byte[] key in datakeys) { this.output.Text += ASCIIEncoding.UTF8.GetString(key) + System.Environment.NewLine; } }