Beispiel #1
0
            public override bool Equals(Object o)
            {
                if (o.GetType() != GetType())
                    return false;

                BasicObj to = (BasicObj) o;

                return (A == ((BasicObj) to).A);
            }
Beispiel #2
0
        public void TestEncodedDefaultRequestReplyThreadSafety()
        {
            using (NATSServer.CreateFastAndVerify(Context.Server1.Port))
            {
                using (IEncodedConnection c = DefaultEncodedConnection)
                {
                    using (c.SubscribeAsync("replier", (obj, args) =>
                    {
                        try
                        {
                            c.Publish(args.Reply, new BasicObj(((BasicObj) args.ReceivedObject).A));
                        }
                        catch (Exception ex)
                        {
                            Assert.True(false, "Replier Exception: " + ex.Message);
                        }

                        c.Flush();
                    }))
                    {
                        c.Flush();

                        using (IEncodedConnection c2 = DefaultEncodedConnection)
                        {
                            System.Threading.Tasks.Parallel.For(0, 20, i =>
                            {
                                try
                                {
                                    var bo = new BasicObj(i);
                                    Assert.True(bo.Equals(c2.Request("replier", bo, 30000)), "Objects did not equal");
                                }
                                catch (Exception ex)
                                {
                                    Assert.True(false, "Exception: " + ex.Message);
                                }
                            });
                        }
                    }
                }
            }
        }