private void Setup() { OpenBusContext context = ORBInitializer.Context; if (context.GetDefaultConnection() == null) { Connection conn = context.CreateConnection(Settings.Default.host, Settings.Default.port); context.SetDefaultConnection(conn); conn.LoginByPassword(Settings.Default.username, ASCIIEncoding.Default.GetBytes(Settings.Default.password)); } easy = new EasyCollaboration(context); // it will use default consumer of EasyCollaboration }
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(); } }
public void ConsumeAnysTest() { omg.org.CORBA.TypeCode long_tc = context.ORB.create_long_tc(); EasyCollaboration target = new EasyCollaboration(context); target.StartCollaboration(); List <object> actual = null; try { actual = target.ConsumeAnys(); Assert.AreEqual(0, actual.Count); target.Share(new omg.org.CORBA.Any(11, long_tc)); target.Share(new omg.org.CORBA.Any(12, long_tc)); target.Share(new omg.org.CORBA.Any(21, long_tc)); target.Share(new omg.org.CORBA.Any(22, long_tc)); Thread.Sleep(4000); actual = target.ConsumeAnys(); Assert.AreEqual(4, actual.Count); Assert.AreEqual(11, actual[0]); Assert.AreEqual(12, actual[1]); Assert.AreEqual(21, actual[2]); Assert.AreEqual(22, actual[3]); } finally { target.ExitCollaboration(); } target = new EasyCollaboration(context, null, null); target.StartCollaboration(); try { actual = target.ConsumeAnys(); Assert.AreEqual(0, actual.Count); target.Share(new omg.org.CORBA.Any(11, long_tc)); target.Share(new omg.org.CORBA.Any(12, long_tc)); target.Share(new omg.org.CORBA.Any(21, long_tc)); target.Share(new omg.org.CORBA.Any(22, long_tc)); Thread.Sleep(2000); actual = target.ConsumeAnys(); Assert.AreEqual(0, actual.Count); } finally { target.ExitCollaboration(); } }
private void Setup() { OpenBusContext context = ORBInitializer.Context; if (context.GetDefaultConnection() == null) { Connection conn = context.CreateConnection(Settings.Default.host, Settings.Default.port); context.SetDefaultConnection(conn); conn.LoginByPassword(Settings.Default.username, ASCIIEncoding.Default.GetBytes(Settings.Default.password)); } // it will force EasyCollaboration to use only our custom consumer and no observer easy = new EasyCollaboration(context, new Consumer(this), null); }
public void MultipleExitCalls() { EasyCollaboration target = new EasyCollaboration(context); CollaborationSession session = target.StartCollaboration(); Assert.IsNotNull(session); target.ExitCollaboration(); target.ExitCollaboration(); target.ExitCollaboration(); target.ExitCollaboration(); target = new EasyCollaboration(context, null, null); session = target.StartCollaboration(); Assert.IsNotNull(session); target.ExitCollaboration(); target.ExitCollaboration(); target.ExitCollaboration(); target.ExitCollaboration(); }