Exemplo n.º 1
0
        public async Task Consume(ConsumeContext <TransactionCheckCommand> context)
        {
            _logger.LogDebug($"Received new TransactionCreatedEvent for {context.Message.Id}");
            var result = await _billingsManager.EvaluateTransactionAsync(context.Message);

            if (result == null)
            {
                throw new Exception($"Could not process an event {context.Message.Id}");
            }
        }
        public async void Should_EvaluateTransactionAsync_Valid()
        {
            var transactionCheckCommand = new TransactionCheckCommand
            {
                Id        = 1.ToGuid().ToString(),
                AccountId = 1.ToGuid().ToString(),
                ProfileId = "awesome",
                Amount    = 1,
                Info      = "info",
                Timestamp = DateTime.Now.ToString(CultureInfo.InvariantCulture),
                Version   = 0
            };

            transactionCheckCommand.SetPending();
            var transactionIsCheckedEvent = await _manager.EvaluateTransactionAsync(
                transactionCheckCommand
                );

            Assert.NotNull(transactionIsCheckedEvent);
            Assert.True(transactionIsCheckedEvent.IsApproved());
        }