예제 #1
0
        public async Task InvokeManyCommands_no_exception_if_commands_is_null()
        {
            IEnumerable <TestCommand> commands = null;

            await BusExtensions.InvokeManyCommands(mockBus.Object, commands);

            mockBus.Verify(p => p.InvokeCommand(It.IsAny <TestCommand>()), Times.Never);
        }
예제 #2
0
        public async Task InvokeManyCommands_forwards_to_IBus()
        {
            var commands = fixture.CreateMany <TestCommand>().ToArray();

            await BusExtensions.InvokeManyCommands(mockBus.Object, commands);

            mockBus.Verify(p => p.InvokeCommand(It.IsAny <TestCommand>()), Times.Exactly(commands.Length));
        }
예제 #3
0
        public async Task RaiseManyEvents_CorrelationId_Bus_is_required()
        {
            var events = fixture.CreateMany <TestEvent>().ToArray();

            var correlationId = fixture.Create <Guid>();

            await BusExtensions.RaiseManyEvents(null, events, correlationId);
        }
예제 #4
0
        public async Task RaiseManyEvents_no_exception_if_commands_is_null()
        {
            IEnumerable <TestEvent> events = null;

            await BusExtensions.RaiseManyEvents(mockBus.Object, events);

            mockBus.Verify(p => p.RaiseEvent(It.IsAny <TestEvent>()), Times.Never);
        }
예제 #5
0
        public async Task InvokeManyCommands_CorrelationId_Bus_is_required()
        {
            var commands = fixture.CreateMany <TestCommand>().ToArray();

            var correlationId = fixture.Create <Guid>();

            await BusExtensions.InvokeManyCommands(null, commands, correlationId);
        }
예제 #6
0
        public async Task RaiseManyEvents_forwards_to_IBus()
        {
            var events = fixture.CreateMany <TestEvent>().ToArray();

            await BusExtensions.RaiseManyEvents(mockBus.Object, events);

            mockBus.Verify(p => p.RaiseEvent(It.IsAny <TestEvent>()), Times.Exactly(events.Length));
        }
예제 #7
0
        public async Task InvokeManyCommands_CorrelationId_no_exception_if_commands_is_null()
        {
            IEnumerable <TestCommand> commands = null;

            var correlationId = fixture.Create <Guid>();

            await BusExtensions.InvokeManyCommands(mockBus.Object, commands, correlationId);

            mockBus.Verify(p => p.InvokeCommand(It.IsAny <TestCommand>()), Times.Never);
        }
예제 #8
0
        public async Task RaiseManyEvents_CorrelationId_no_exception_if_commands_is_null()
        {
            IEnumerable <TestEvent> events = null;

            var correlationId = fixture.Create <Guid>();

            await BusExtensions.RaiseManyEvents(mockBus.Object, events, correlationId);

            mockBus.Verify(p => p.RaiseEvent(It.IsAny <TestEvent>(), It.IsAny <Guid>()), Times.Never);
        }
예제 #9
0
        public static IDisposable SubscribeToAndUpdate <TMessage, TEntity>(this ObservableMessageBus source, Action <TEntity, TMessage> onNext, IEventRepository repo)
            where TMessage : class, IMessage <IEventSourcedEntityCommand>
            where TEntity : class, IEventSourcedEntity
        {
            async Task a(TMessage obj)
            {
                var ent = await repo.GetAsync <TEntity>(obj.Body.Id);

                onNext(ent, obj);

                await repo.SaveAsync(ent);
            }

            return(BusExtensions.SubscribeTo <TMessage>(source)
                   .Select(x => Observable.FromAsync(() => a(x)))
                   .Concat()
                   .Subscribe());
        }
예제 #10
0
 public void InvokeCommandAsync_requires_bus(FirstTestCommand testCommand, Guid correlationId)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => BusExtensions.InvokeCommandAsync(null, testCommand, correlationId));
 }
예제 #11
0
        public async Task RaiseManyEventsAsync_handles_null_event_list(IBus bus, Guid correlationId, IDictionary <string, string> headers)
        {
            await BusExtensions.RaiseManyEventsAsync <FirstTestEvent>(bus, null, correlationId, headers);

            Mock.Get(bus).Verify(p => p.RaiseEventAsync(It.IsAny <FirstTestEvent>(), It.IsAny <Guid>(), headers), Times.Never);
        }
예제 #12
0
        public async Task InvokeCommandAsync_forwards_to_bus(IBus bus, FirstTestCommand testCommand, IDictionary <string, string> headers)
        {
            await BusExtensions.InvokeCommandAsync(bus, testCommand, headers);

            Mock.Get(bus).Verify(p => p.InvokeCommandAsync(testCommand, It.IsAny <Guid>(), headers));
        }
예제 #13
0
        public async Task InvokeCommandAsync_forwards_to_bus(IBus bus, FirstTestCommand testCommand, Guid correlationId)
        {
            await BusExtensions.InvokeCommandAsync(bus, testCommand, correlationId);

            Mock.Get(bus).Verify(p => p.InvokeCommandAsync(testCommand, correlationId, It.IsAny <IDictionary <string, string> >()));
        }
예제 #14
0
 public void RaiseManyEventsAsync_requires_bus(FirstTestEvent[] testEvents, Guid correlationId, IDictionary <string, string> headers)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => BusExtensions.RaiseManyEventsAsync(null, testEvents, correlationId, headers));
 }
예제 #15
0
        public async Task RaiseManyEventsAsync_forwards_all_to_bus(IBus bus, FirstTestEvent[] testEvents, Guid correlationId, IDictionary <string, string> headers)
        {
            await BusExtensions.RaiseManyEventsAsync(bus, testEvents, correlationId, headers);

            Mock.Get(bus).Verify(p => p.RaiseEventAsync(It.IsAny <FirstTestEvent>(), correlationId, headers), Times.Exactly(testEvents.Length));
        }
예제 #16
0
 public void RaiseManyEventsAsync_requires_bus(FirstTestEvent[] testEvents)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => BusExtensions.RaiseManyEventsAsync(null, testEvents));
 }
예제 #17
0
        public async Task RaiseManyEvents_Bus_is_required()
        {
            var events = fixture.CreateMany <TestEvent>().ToArray();

            await BusExtensions.RaiseManyEvents(null, events);
        }
예제 #18
0
 public void RaiseEventAsync_requires_bus(FirstTestEvent testEvent, IDictionary <string, string> headers)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => BusExtensions.RaiseEventAsync(null, testEvent, headers));
 }
예제 #19
0
        public async Task RaiseEventAsync_forwards_to_bus(IBus bus, FirstTestEvent testEvent, IDictionary <string, string> headers)
        {
            await BusExtensions.RaiseEventAsync(bus, testEvent, headers);

            Mock.Get(bus).Verify(p => p.RaiseEventAsync(testEvent, It.IsAny <Guid>(), headers));
        }
예제 #20
0
 public void InvokeCommandAsync_requires_bus(FirstTestCommand testCommand, IDictionary <string, string> headers)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => BusExtensions.InvokeCommandAsync(null, testCommand, headers));
 }
예제 #21
0
        public async Task InvokeManyCommands_Bus_is_required()
        {
            var commands = fixture.CreateMany <TestCommand>().ToArray();

            await BusExtensions.InvokeManyCommands(null, commands);
        }
예제 #22
0
        public async Task RaiseEventAsync_forwards_to_bus(IBus bus, FirstTestEvent testEvent, Guid correlationId)
        {
            await BusExtensions.RaiseEventAsync(bus, testEvent, correlationId);

            Mock.Get(bus).Verify(p => p.RaiseEventAsync(testEvent, correlationId, It.IsAny <IDictionary <string, string> >()));
        }
예제 #23
0
 public void InvokeManyCommandsAsync_requires_bus(FirstTestCommand[] testCommands)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => BusExtensions.InvokeManyCommandsAsync(null, testCommands));
 }
예제 #24
0
 public void RaiseEventAsync_requires_bus(FirstTestEvent testEvent, Guid correlationId)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => BusExtensions.RaiseEventAsync(null, testEvent, correlationId));
 }
예제 #25
0
 public void InvokeManyCommandsAsync_requires_bus(FirstTestCommand[] testCommands, Guid correlationId, IDictionary <string, string> headers)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => BusExtensions.InvokeManyCommandsAsync(null, testCommands, correlationId, headers));
 }
예제 #26
0
        public async Task InvokeManyCommandsAsync_forwards_all_to_bus(IBus bus, FirstTestCommand[] testCommands)
        {
            await BusExtensions.InvokeManyCommandsAsync(bus, testCommands);

            Mock.Get(bus).Verify(p => p.InvokeCommandAsync(It.IsAny <FirstTestCommand>(), It.IsAny <Guid>(), It.IsAny <IDictionary <string, string> >()), Times.Exactly(testCommands.Length));
        }
예제 #27
0
        public async Task InvokeManyCommandsAsync_handles_null_command_list(IBus bus, Guid correlationId, IDictionary <string, string> headers)
        {
            await BusExtensions.InvokeManyCommandsAsync <FirstTestCommand>(bus, null, correlationId, headers);

            Mock.Get(bus).Verify(p => p.InvokeCommandAsync(It.IsAny <FirstTestCommand>(), It.IsAny <Guid>(), It.IsAny <IDictionary <string, string> >()), Times.Never);
        }