private Collection4 CommitCapturingUpdatedObjects(IExtObjectContainer container)
 {
     var updated = new Collection4();
     EventRegistryFor(container).Updated += new _IEventListener4_51(updated).OnEvent;
     container.Commit();
     return updated;
 }
			public _IRunnable_23(DynamicVariableTestCase _enclosing, DynamicVariable variable
				, Collection4 failures)
			{
				this._enclosing = _enclosing;
				this.variable = variable;
				this.failures = failures;
			}
Exemple #3
0
 public virtual void TestContainsAll()
 {
     var a = new Item(42);
     var b = new Item(a.id + 1);
     var c = new Item(b.id + 1);
     var a_ = new Item(a.id);
     var needle = new Collection4();
     var haystack = new Collection4();
     haystack.Add(a);
     needle.Add(a);
     needle.Add(b);
     Assert.IsFalse(haystack.ContainsAll(needle));
     needle.Remove(b);
     Assert.IsTrue(haystack.ContainsAll(needle));
     needle.Add(b);
     haystack.Add(b);
     Assert.IsTrue(haystack.ContainsAll(needle));
     needle.Add(a_);
     Assert.IsTrue(haystack.ContainsAll(needle));
     needle.Add(c);
     Assert.IsFalse(haystack.ContainsAll(needle));
     needle.Clear();
     Assert.IsTrue(haystack.ContainsAll(needle));
     haystack.Clear();
     Assert.IsTrue(haystack.ContainsAll(needle));
 }
Exemple #4
0
		internal virtual void Process(ClassMetadata newClassMetadata)
		{
			if (_pending.Contains(newClassMetadata))
			{
				return;
			}
			ClassMetadata ancestor = newClassMetadata.GetAncestor();
			if (ancestor != null)
			{
				Process(ancestor);
			}
			_pending.Add(newClassMetadata);
			_members.Add(newClassMetadata);
			if (_running)
			{
				return;
			}
			_running = true;
			try
			{
				CheckInits();
				_pending = new Collection4();
			}
			finally
			{
				_running = false;
			}
		}
		public virtual void Test()
		{
			Collection4 expected = new Collection4(new object[] { "PING", true, 42 });
			MessagingTestCaseBase.MessageCollector recipient = new MessagingTestCaseBase.MessageCollector
				();
			IObjectServer server = OpenServerWith(recipient);
			try
			{
				IObjectContainer client = OpenClient("client", server);
				try
				{
					IMessageSender sender = MessageSender(client);
					SendAll(expected, sender);
				}
				finally
				{
					client.Close();
				}
			}
			finally
			{
				server.Close();
			}
			Assert.AreEqual(expected.ToString(), recipient.messages.ToString());
		}
Exemple #6
0
		public virtual void AddListener(IDiagnosticListener listener)
		{
			if (_listeners == null)
			{
				_listeners = new Collection4();
			}
			_listeners.Add(listener);
		}
		internal virtual void CacheDirty(Collection4 col)
		{
			if (!BitIsTrue(Const4.CachedDirty))
			{
				BitTrue(Const4.CachedDirty);
				col.Add(this);
			}
		}
		private void CollectKnownClasses(Collection4 collector, IEnumerator knownClasses)
		{
			while (knownClasses.MoveNext())
			{
				IReflectClass clazz = (IReflectClass)knownClasses.Current;
				CollectKnownClass(collector, clazz);
			}
		}
		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());
		}
		private Collection4 CommitCapturingUpdatedObjects(IExtObjectContainer container)
		{
			Collection4 updated = new Collection4();
			EventRegistryFor(container).Updated += new System.EventHandler<Db4objects.Db4o.Events.ObjectInfoEventArgs>
				(new _IEventListener4_51(updated).OnEvent);
			container.Commit();
			return updated;
		}
Exemple #11
0
 public ExcludingReflector(Type[] excludedClasses)
 {
     _excludedClasses = new Collection4();
     for (var claxxIndex = 0; claxxIndex < excludedClasses.Length; ++claxxIndex)
     {
         var claxx = excludedClasses[claxxIndex];
         _excludedClasses.Add(claxx.FullName);
     }
 }
		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());
		}
Exemple #13
0
		public ExcludingReflector(ByRef loaderClass, Type[] excludedClasses)
		{
			_excludedClasses = new Collection4();
			for (int claxxIndex = 0; claxxIndex < excludedClasses.Length; ++claxxIndex)
			{
				Type claxx = excludedClasses[claxxIndex];
				_excludedClasses.Add(claxx.FullName);
			}
		}
 private Collection4 Range(int end)
 {
     var range = new Collection4();
     for (var i = 0; i < end; ++i)
     {
         range.Add(i);
     }
     return range;
 }
		public virtual void Run()
		{
			dontRemove = true;
			Collection4 copy = new Collection4(_containers);
			IEnumerator i = copy.GetEnumerator();
			while (i.MoveNext())
			{
				((ObjectContainerBase)i.Current).ShutdownHook();
			}
		}
		private Thread[] CreateThreads(DynamicVariable variable, Collection4 failures)
		{
			Thread[] threads = new Thread[5];
			for (int i = 0; i < threads.Length; i++)
			{
				threads[i] = new Thread(new _IRunnable_56(this, variable, failures), "DynamicVariableTestCase.checkVariableBehavior Thread["
					 + i + "]");
			}
			return threads;
		}
 public virtual void TestDrainTo()
 {
     var queue = new BlockingQueue();
     queue.Add(new object());
     queue.Add(new object());
     var list = new Collection4();
     Assert.AreEqual(2, queue.DrainTo(list));
     Assert.AreEqual(2, list.Size());
     Assert.IsFalse(queue.HasNext());
 }
Exemple #18
0
		public virtual void TraverseMutable(IVisitor4 visitor)
		{
			Collection4 currentContent = new Collection4();
			TraverseLocked(new _IVisitor4_51(currentContent));
			IEnumerator i = currentContent.GetEnumerator();
			while (i.MoveNext())
			{
				visitor.Visit(i.Current);
			}
		}
		private IEnumerator Ids(IEnumerable<PartialCollectionReplicationTestCase.Data> data
			)
		{
			Collection4 ids = new Collection4();
			foreach (PartialCollectionReplicationTestCase.Data d in data)
			{
				ids.Add(d.Id());
			}
			return ids.GetEnumerator();
		}
		private Collection4 Copy(IEnumerable subject)
		{
			Collection4 result = new Collection4();
			IEnumerator it = subject.GetEnumerator();
			while (it.MoveNext())
			{
				result.Add(it.Current);
			}
			return result;
		}
		public virtual void TestSeries()
		{
			Collection4 calls = new Collection4();
			IEnumerator series = Iterators.Series(string.Empty, new _IFunction4_11(calls)).GetEnumerator
				();
			Assert.IsTrue(series.MoveNext());
			Assert.IsTrue(series.MoveNext());
			Iterator4Assert.AreEqual(new object[] { string.Empty, "*" }, calls.GetEnumerator(
				));
		}
Exemple #22
0
		private IEnumerator CollectChildIdsFor(int id)
		{
			Collection4 references = ((Collection4)referenceCache[id]);
			if (null == references)
			{
				references = new Collection4(_referenceCollector.ReferencesFrom(id));
				referenceCache[id] = references;
			}
			return references.GetEnumerator();
		}
		private CompositeIterator4 NewIterator()
		{
			Collection4 iterators = new Collection4();
			iterators.Add(IntArrays4.NewIterator(new int[] { 1, 2, 3 }));
			iterators.Add(IntArrays4.NewIterator(new int[] {  }));
			iterators.Add(IntArrays4.NewIterator(new int[] { 4 }));
			iterators.Add(IntArrays4.NewIterator(new int[] { 5, 6 }));
			CompositeIterator4 iterator = new CompositeIterator4(iterators.GetEnumerator());
			return iterator;
		}
Exemple #24
0
		public virtual void TestContains()
		{
			object a = new object();
			Collection4 c = new Collection4();
			c.Add(new object());
			Assert.IsFalse(c.Contains(a));
			c.Add(a);
			Assert.IsTrue(c.Contains(a));
			c.Remove(a);
			Assert.IsFalse(c.Contains(a));
		}
		protected override void Free(IFreespaceManager freespaceManager, Slot slot)
		{
			if (slot.IsNull())
			{
				return;
			}
			if (_freed == null)
			{
				_freed = new Collection4();
			}
			_freed.Add(slot);
		}
		private void CollectKnownClasses(Collection4 classes)
		{
			IListener4 collectingListener = NewCollectingClassListener(classes);
			_repository.AddListener(collectingListener);
			try
			{
				CollectKnownClasses(classes, Iterators.Copy(_repository.Classes()));
			}
			finally
			{
				_repository.RemoveListener(collectingListener);
			}
		}
Exemple #27
0
 public virtual void TestReplace()
 {
     var c = new Collection4();
     c.Replace("one", "two");
     c.Add("one");
     c.Add("two");
     c.Add("three");
     c.Replace("two", "two.half");
     AssertCollection(new[] {"one", "two.half", "three"}, c);
     c.Replace("two.half", "one");
     c.Replace("one", "half");
     AssertCollection(new[] {"half", "one", "three"}, c);
 }
Exemple #28
0
		public virtual IEnumerator IteratorFor(object collection)
		{
			IDictionary map = (IDictionary)collection;
			Collection4 result = new Collection4();
			IEnumerator it = map.GetEnumerator();
			while (it.MoveNext())
			{
				DictionaryEntry entry = (DictionaryEntry)it.Current;
				result.Add(entry.Key);
				result.Add(entry.Value);
			}
			return result.GetEnumerator();
		}
Exemple #29
0
		private void AddConstraint(Collection4 col, object obj)
		{
			if (AttachToExistingConstraints(col, obj, true))
			{
				return;
			}
			if (AttachToExistingConstraints(col, obj, false))
			{
				return;
			}
			QConObject newConstraint = new QConObject(_trans, null, null, obj);
			AddConstraint(newConstraint);
			col.Add(newConstraint);
		}
Exemple #30
0
 public static void SameContent(IEnumerator expected, IEnumerator actual)
 {
     var allExpected = new Collection4(expected);
     while (actual.MoveNext())
     {
         var current = actual.Current;
         var removed = allExpected.Remove(current);
         if (!removed)
         {
             Unexpected(current);
         }
     }
     Assert.IsTrue(allExpected.IsEmpty(), "Still missing: " + allExpected);
 }
Exemple #31
0
        public virtual object DeepClone(object newParent)
        {
            Db4objects.Db4o.Foundation.Collection4 col = new Db4objects.Db4o.Foundation.Collection4
                                                             ();
            object      element = null;
            IEnumerator i       = InternalIterator();

            while (i.MoveNext())
            {
                element = i.Current;
                if (element is IDeepClone)
                {
                    col.Add(((IDeepClone)element).DeepClone(newParent));
                }
                else
                {
                    col.Add(element);
                }
            }
            return(col);
        }
Exemple #32
0
        public static object[] ToArray(IEnumerator tests, IArrayFactory factory)
        {
            Collection4 elements = new Collection4(tests);

            return(elements.ToArray(factory.NewArray(elements.Size())));
        }
Exemple #33
0
 public _IClosure4_54(BlockingQueue _enclosing, Collection4 target)
 {
     this._enclosing = _enclosing;
     this.target     = target;
 }
Exemple #34
0
 public virtual int DrainTo(Collection4 target)
 {
     return(((int)_lock.Run(new _IClosure4_54(this, target))));
 }
 public virtual int DrainTo(Collection4 list)
 {
     return(queue.DrainTo(list));
 }