private void AddEventToCollection(TransactionEventWireModel transactionEvent) { if (transactionEvent.IsSynthetics && _syntheticsTransactionEvents.Count < SyntheticsHeader.MaxEventCount) { _syntheticsTransactionEvents.Add(transactionEvent); } else { _transactionEvents.Add(new PrioritizedNode <TransactionEventWireModel>(transactionEvent)); } }
private static void ExerciseFullApi(IResizableCappedCollection <PrioritizedNode <TestModel> > concurrentPriorityQueue, PrioritizedNode <TestModel>[] eventsToAdd, int countOfThreads) { // Add the new events foreach (var evt in eventsToAdd) { concurrentPriorityQueue.Add(evt); } //make sure each of the new events can be found (tests equality op) foreach (var ev in eventsToAdd) { Assert.That(concurrentPriorityQueue, Contains.Item(ev)); } //copy the CPQ to an array var destinationArray = new PrioritizedNode <TestModel> [eventsToAdd.Count() * countOfThreads]; concurrentPriorityQueue.CopyTo(destinationArray, 0); //check that the copied contents contains our events foreach (var ev in eventsToAdd) { Assert.That(destinationArray, Contains.Item(ev)); } //count how many are actually in the destinationArray var nonnullCount = 0; while (nonnullCount < destinationArray.Length && null != destinationArray[nonnullCount]) { ++nonnullCount; } //make sure the array is sorted properly for (var index = 1; index < nonnullCount; ++index) { Assert.That(destinationArray[index - 1].Data.Priority, Is.GreaterThanOrEqualTo(destinationArray[index].Data.Priority)); } //make sure that remove is not supported Assert.That(() => concurrentPriorityQueue.Remove(eventsToAdd[0]), Throws.TypeOf <NotSupportedException>()); }