public static void Assert_EnqueueSingleProducerBounded(IEventQueueStorageStrategy <TestEvent> strategy, int maxEventCount) { /* PRECONDITION */ Debug.Assert(strategy != null); Debug.Assert(maxEventCount >= 0); Debug.Assert(strategy.IsClosed); /* GIVEN */ var expectedEventCount = (maxEventCount < maxEvents) ? maxEventCount : maxEvents; var producer = new TestProducer(strategy); var consumer = new TestConsumer(strategy); using var produceEvent = new ManualResetEvent(false); using var consumeEvent = new ManualResetEvent(false); /* WHEN */ strategy.Open(); Assert.IsTrue(!strategy.IsClosed); consumer.Consume((@event, num) => num < expectedEventCount, result => result.EventSuccess(consumeEvent)); producer.Produce(num => num < maxEvents, result => result.EventSuccess(produceEvent)); /* THEN */ Assert.IsTrue(produceEvent.WaitOne(maxWaitTime), "Producer did not complete successfully"); Assert.IsTrue(consumeEvent.WaitOne(maxWaitTime), "Consumer did not complete successfully"); }
public static void Assert_EnqueueSingleProducerUnbounded(IEventQueueStorageStrategy <TestEvent> strategy) { /* PRECONDITION */ Debug.Assert(strategy != null); Debug.Assert(strategy.IsClosed); /* GIVEN */ strategy.Open(); var producer = new TestProducer(strategy); var consumer = new TestConsumer(strategy); using var produceEvent = new ManualResetEvent(false); using var consumeEvent = new ManualResetEvent(false); /* WHEN */ consumer.Consume((@event, num) => num < maxEvents, result => result.EventSuccess(consumeEvent)); producer.Produce(num => num < maxEvents, result => result.EventSuccess(produceEvent)); /* THEN */ Assert.IsTrue(produceEvent.WaitOne(maxWaitTime), "Producer did not finish in time"); Assert.IsTrue(consumeEvent.WaitOne(maxWaitTime), "Consumer did not receive events in time"); }
protected EventQueue(IEventQueueStorageStrategy <TEvent> storageStrategy) => this.storageStrategy = storageStrategy;
/// <summary> /// Instantiates a new TestConsumer which should interact with the given strategy. /// </summary> /// <param name="strategy">The strategy to interact with while consuming.</param> public TestConsumer(IEventQueueStorageStrategy <TestEvent> strategy) { this.strategy = strategy; }
public EventQueueImp(IEventQueueStorageStrategy <TestEvent> storageStrategy) : base(storageStrategy) { }
public SupportDeserializationEventQueueImp(IEventQueueStorageStrategy <TestEvent> storageStrategy) : base(storageStrategy) { }
protected SupportDeserializationEventQueue(IEventQueueStorageStrategy <T> storageStrategy) : base(storageStrategy) { }
/// <summary> /// Instantiates a new TestProducer for the given EventQueueStorageStrategy. /// </summary> /// <param name="strategy">The strategy to be interacted with by this producer.</param> public TestProducer(IEventQueueStorageStrategy <TestEvent> strategy) { this.strategy = strategy; }