Ejemplo n.º 1
0
 public void WriteMsg(Msg msg, bool flush)
 {
     if (_config.BatchMessages())
     {
         if (flush && _batchedMessages.IsEmpty())
         {
             // if there's nothing batched, just send this message directly
             WriteMessageToSocket(msg);
         }
         else
         {
             AddToBatch(msg);
             if (flush || _batchedQueueLength > _config.MaxBatchQueueSize())
             {
                 WriteBatchedMessages();
             }
         }
     }
     else
     {
         if (!_batchedMessages.IsEmpty())
         {
             AddToBatch(msg);
             WriteBatchedMessages();
         }
         else
         {
             WriteMessageToSocket(msg);
         }
     }
 }
        public virtual void TestMultiThread()
        {
            DynamicVariable variable = new DynamicVariable();
            Collection4     failures = new Collection4();

            variable.With("mine", new _IRunnable_23(this, variable, failures));
            Assert.IsNull(variable.Value);
            Assert.IsTrue(failures.IsEmpty(), failures.ToString());
        }
        public virtual void TestFieldTraversal()
        {
            Collection4 expectedNames = new Collection4(new ArrayIterator4(new string[] { "_id"
                                                                                          , "_name", "_age" }));
            ClassMetadata classMetadata = ClassMetadataFor(typeof(ClassMetadataIntegrationTestCase.SubClazz
                                                                  ));

            classMetadata.TraverseAllAspects(new _TraverseFieldCommand_31(expectedNames));
            Assert.IsTrue(expectedNames.IsEmpty());
        }
Ejemplo n.º 4
0
        private void AssertIterator(Hashtable4 table, object[] keys)
        {
            IEnumerator iter     = table.Iterator();
            Collection4 expected = new Collection4(keys);

            while (iter.MoveNext())
            {
                IEntry4 entry     = (IEntry4)iter.Current;
                bool    removedOK = expected.Remove(entry.Key());
                Assert.IsTrue(removedOK);
            }
            Assert.IsTrue(expected.IsEmpty(), expected.ToString());
        }
Ejemplo n.º 5
0
        public static void SameContent(IEnumerator expected, IEnumerator actual)
        {
            Collection4 allExpected = new Collection4(expected);

            while (actual.MoveNext())
            {
                object current = actual.Current;
                bool   removed = allExpected.Remove(current);
                if (!removed)
                {
                    Unexpected(current);
                }
            }
            Assert.IsTrue(allExpected.IsEmpty(), "Still missing: " + allExpected.ToString());
        }
            private bool Expect(IObjectContainer container, string[] names)
            {
                Collection4 expected = new Collection4(names);
                IObjectSet  actual   = container.Query(typeof(CrashSimulatingTestSuite.CrashData));

                while (actual.HasNext())
                {
                    CrashSimulatingTestSuite.CrashData current = (CrashSimulatingTestSuite.CrashData)
                                                                 actual.Next();
                    if (!expected.Remove(current._name))
                    {
                        return(false);
                    }
                }
                return(expected.IsEmpty());
            }
Ejemplo n.º 7
0
        private void AssertEntries(PersistentEntry[] expected, IEnumerator actual)
        {
            Collection4 checklist = new Collection4(actual);

            Assert.AreEqual(expected.Length, checklist.Size());
            for (int i = 0; i < expected.Length; ++i)
            {
                PersistentEntry e = expected[i];
                PersistentEntry a = EntryByUid(checklist.GetEnumerator(), e.uid);
                if (a != null)
                {
                    AssertEqualEntries(e, a);
                    checklist.Remove(a);
                }
            }
            Assert.IsTrue(checklist.IsEmpty(), checklist.ToString());
        }
Ejemplo n.º 8
0
        public static void SameContent(IEnumerator expected, IEnumerator actual)
        {
            var allExpected = new Collection4();

            while (expected.MoveNext())
            {
                allExpected.Add(expected.Current);
            }
            while (actual.MoveNext())
            {
                var current = actual.Current;
                var removed = allExpected.Remove(current);
                if (!removed)
                {
                    Unexpected(current);
                }
            }
            Assert.IsTrue(allExpected.IsEmpty(), allExpected.ToString());
        }
Ejemplo n.º 9
0
        private IConstraint AddClassConstraint(IReflectClass claxx)
        {
            if (IsTheObjectClass(claxx))
            {
                return(null);
            }
            if (claxx.IsInterface())
            {
                return(AddInterfaceConstraint(claxx));
            }
            Collection4 newConstraints = IntroduceClassConstrain(claxx);

            if (newConstraints.IsEmpty())
            {
                QConClass qcc = new QConClass(_trans, claxx);
                AddConstraint(qcc);
                return(qcc);
            }
            return(ToConstraint(newConstraints));
        }