Example #1
0
        public async Task OnHandle_should_callEventBus_()
        {
            _eventBusMock.Invocations.Clear();

            var clientName = "teste_client";
            var handler    = new InsertClientCommandHandler(_storageMock.Object, _eventBusMock.Object);
            await handler.Handle(new CQRSService.Domain.Commands.InsertClientCommand(clientName), CancellationToken.None);

            _eventBusMock.Verify(a => a.Publish(It.Is <IEvent[]>(c => c.Length == 1 && c[0].GetType() == typeof(ClientCreated))), Times.Once);
        }
Example #2
0
        public async Task OnHandle_should_callStorage_with_name()
        {
            _storageMock.Invocations.Clear();

            var clientName = "teste_client";
            var handler    = new InsertClientCommandHandler(_storageMock.Object, _eventBusMock.Object);
            await handler.Handle(new CQRSService.Domain.Commands.InsertClientCommand(clientName), CancellationToken.None);

            _storageMock.Verify(a => a.Add(It.Is <Client>(c => c.Name == clientName)), Times.Once);
        }