public Task Handle(
            ContratoQueryEvent notification,
            CancellationToken cancellationToken)
        {
            var queue = _configuration.GetQueue(notification.GetKeyQueues);

            if (!string.IsNullOrEmpty(queue))
            {
                _rabbitMQBus.Publisher(FactoryPublishable.Get(notification.AggregateId,
                                                              queue,
                                                              notification));
            }

            return(Task.CompletedTask);
        }
        public void HandleSucesso()
        {
            var mock = Substitute.For <IContratoRepository>();

            mock.InsiraNovoContrato(Arg.Any <ContratoBusModel>(),
                                    Arg.Any <Func <ContratoBusModel, Contrato> >());
            var mockConfiguration = Substitute.For <ICodeiziConfiguration>();

            var bus         = new NovoContratoServicoBus(mock, mockConfiguration);
            var contrato    = CenarioContratoBusModel.CrieContrato;
            var publishable = FactoryPublishable.Get(contrato.IdColaborador, "add-contrato", contrato);
            var result      = bus.Handle(publishable);

            result.ConfigureAwait(false);
            Assert.Null(result.Exception);
            Assert.Equal(TaskStatus.RanToCompletion, result.Status);
        }
        public Task Handle(
            ColaboradorEventSource notification,
            CancellationToken cancellationToken)
        {
            if (!notification.MessageType.Equals("DomainNotification"))
            {
                var queue = _configuration.GetQueue(notification.GetKeyQueues);
                if (!string.IsNullOrEmpty(queue))
                {
                    _rabbitMQBus.Publisher(FactoryPublishable.Get(notification.AggregateId,
                                                                  queue,
                                                                  notification));
                }

                return(Task.CompletedTask);
            }

            return(Task.CompletedTask);
        }
        public async void HandleAdmitido()
        {
            var mock = Substitute.For <IRabbitMQBus>();
            var colaboradorAdmitido = new NovoColaboradorParaCalculoEvent(Guid.NewGuid(),
                                                                          Guid.NewGuid(),
                                                                          DateTime.Now,
                                                                          null,
                                                                          1000);

            var p = FactoryPublishable.Get(colaboradorAdmitido.AggregateId,
                                           "add-contrato",
                                           colaboradorAdmitido);
            var json = JsonConvert.SerializeObject(p);
            var p2   = JsonConvert.DeserializeObject <Publishable>(json);
            var c    = p2.ToObject <NovoColaboradorParaCalculoEvent>();

            Assert.Equal(colaboradorAdmitido.AggregateId, c.AggregateId);
            var mockICodeiziConfiguration = Substitute.For <ICodeiziConfiguration>();

            var eventHandler = new ColaboradorEventHandler(mock, mockICodeiziConfiguration);
            await eventHandler.Handle(colaboradorAdmitido, CancellationToken.None);

            Assert.True(true);
        }