private IEventProcessor[] GetRequestSenders(
            RingBuffer <EventType> ringBuffer,
            ISequenceBarrier sequenceBarrier,
            RequestSenderMode mode)
        {
            var mockExternalService = new MockExternalService <OutgoingRequest, int>();

            AsyncExtensions.FireAndForgetLongRunning(
                () => mockExternalService.Run(),
                (ex) => Assert.Fail(ex.StackTrace)
                );

            var createOrUpdateRequestExecutor = new RequestSender <EventType, OutgoingRequest>(
                (@event) => @event.CreateOrUpdateTodoListRequest, mockExternalService, mode, (ex) => Assert.Fail(ex.StackTrace)
                );
            var deleteRequestExecutor = new RequestSender <EventType, OutgoingRequest>(
                (@event) => @event.DeleteTodoListsRequest, mockExternalService, mode, (ex) => Assert.Fail(ex.StackTrace)
                );
            var removeItemsRequestExecutor = new RequestSender <EventType, OutgoingRequest>(
                (@event) => @event.RemoveLineItemsRequest, mockExternalService, mode, (ex) => Assert.Fail(ex.StackTrace)
                );

            return(new IEventProcessor[] {
                new AsyncEventProcessor <EventType>(
                    ringBuffer, sequenceBarrier, new SpinLock(), createOrUpdateRequestExecutor
                    ),
                new AsyncEventProcessor <EventType>(
                    ringBuffer, sequenceBarrier, new SpinLock(), deleteRequestExecutor
                    ),
                new AsyncEventProcessor <EventType>(
                    ringBuffer, sequenceBarrier, new SpinLock(), removeItemsRequestExecutor
                    ),
            });
        }
Beispiel #2
0
 public RequestSender(
     Func <TEvent, TPayload> getPayload,
     MockExternalService <TPayload, int> mockService,
     RequestSenderMode mode,
     Action <Exception> onException
     )
 {
     _mockService = mockService;
     _getPayload  = getPayload;
     _onException = onException;
     _mode        = mode;
 }