public PostCommandTests() { _myCommand.Value = "Hello World"; _fakeOutboxSync = new FakeOutboxSync(); _fakeMessageProducerWithPublishConfirmation = new FakeMessageProducerWithPublishConfirmation(); const string topic = "MyCommand"; _message = new Message( new MessageHeader(_myCommand.Id, topic, MessageType.MT_COMMAND), new MessageBody(JsonSerializer.Serialize(_myCommand, JsonSerialisationOptions.Options)) ); var messageMapperRegistry = new MessageMapperRegistry(new SimpleMessageMapperFactory((_) => new MyCommandMessageMapper())); messageMapperRegistry.Register <MyCommand, MyCommandMessageMapper>(); _commandProcessor = CommandProcessorBuilder.With() .Handlers(new HandlerConfiguration(new SubscriberRegistry(), new EmptyHandlerFactorySync())) .DefaultPolicy() .ExternalBus(new ExternalBusConfiguration( new ProducerRegistry(new Dictionary <string, IAmAMessageProducer>() { { topic, _fakeMessageProducerWithPublishConfirmation }, }), messageMapperRegistry), _fakeOutboxSync) .RequestContextFactory(new InMemoryRequestContextFactory()) .Build(); }
public CommandProcessorPostBoxBulkClearAsyncTests() { var myCommand = new MyCommand { Value = "Hello World" }; var myCommand2 = new MyCommand { Value = "Hello World 2" }; _fakeOutboxSync = new FakeOutboxSync(); _fakeMessageProducerWithPublishConfirmation = new FakeMessageProducerWithPublishConfirmation(); var topic = "MyCommand"; var topic2 = "MyCommand2"; _message = new Message( new MessageHeader(myCommand.Id, topic, MessageType.MT_COMMAND), new MessageBody(JsonSerializer.Serialize(myCommand, JsonSerialisationOptions.Options)) ); _message2 = new Message( new MessageHeader(myCommand.Id, topic2, MessageType.MT_COMMAND), new MessageBody(JsonSerializer.Serialize(myCommand2, JsonSerialisationOptions.Options)) ); var messageMapperRegistry = new MessageMapperRegistry(new SimpleMessageMapperFactory((_) => new MyCommandMessageMapper())); messageMapperRegistry.Register <MyCommand, MyCommandMessageMapper>(); var retryPolicy = Policy .Handle <Exception>() .RetryAsync(); var circuitBreakerPolicy = Policy .Handle <Exception>() .CircuitBreakerAsync(1, TimeSpan.FromMilliseconds(1)); _commandProcessor = new CommandProcessor( new InMemoryRequestContextFactory(), new PolicyRegistry { { CommandProcessor.RETRYPOLICYASYNC, retryPolicy }, { CommandProcessor.CIRCUITBREAKERASYNC, circuitBreakerPolicy } }, messageMapperRegistry, _fakeOutboxSync, new ProducerRegistry(new Dictionary <string, IAmAMessageProducer>() { { topic, _fakeMessageProducerWithPublishConfirmation }, { topic2, _fakeMessageProducerWithPublishConfirmation } })); }
public ControlBusSenderPostMessageTests() { _myCommand.Value = "Hello World"; _fakeOutbox = new FakeOutboxSync(); _fakeMessageProducer = new FakeMessageProducer(); const string topic = "MyCommand"; _message = new Message( new MessageHeader(_myCommand.Id, topic, MessageType.MT_COMMAND), new MessageBody(JsonSerializer.Serialize(_myCommand, JsonSerialisationOptions.Options)) ); var messageMapperRegistry = new MessageMapperRegistry(new SimpleMessageMapperFactory((_) => new MyCommandMessageMapper())); messageMapperRegistry.Register <MyCommand, MyCommandMessageMapper>(); var retryPolicy = Policy .Handle <Exception>() .Retry(); var circuitBreakerPolicy = Policy .Handle <Exception>() .CircuitBreaker(1, TimeSpan.FromMilliseconds(1)); _commandProcessor = new CommandProcessor( new InMemoryRequestContextFactory(), new PolicyRegistry { { CommandProcessor.RETRYPOLICY, retryPolicy }, { CommandProcessor.CIRCUITBREAKER, circuitBreakerPolicy } }, messageMapperRegistry, _fakeOutbox, new ProducerRegistry(new Dictionary <string, IAmAMessageProducer>() { { topic, _fakeMessageProducer }, })); _controlBusSender = new ControlBusSender(_commandProcessor); }
public CommandProcessorPostMissingMessageProducerTests() { _myCommand.Value = "Hello World"; _fakeOutboxSync = new FakeOutboxSync(); _message = new Message( new MessageHeader(_myCommand.Id, "MyCommand", MessageType.MT_COMMAND), new MessageBody(JsonSerializer.Serialize(_myCommand, JsonSerialisationOptions.Options)) ); _messageMapperRegistry = new MessageMapperRegistry(new SimpleMessageMapperFactory((_) => new MyCommandMessageMapper())); _messageMapperRegistry.Register <MyCommand, MyCommandMessageMapper>(); _retryPolicy = Policy .Handle <Exception>() .Retry(); _circuitBreakerPolicy = Policy .Handle <Exception>() .CircuitBreaker(1, TimeSpan.FromMilliseconds(1)); }