Пример #1
0
        public async Task <IHttpActionResult> Redeem(
            ODataActionParameters parameters,
            ODataQueryOptions <Token> options,
            CancellationToken cancellationToken,
            [FromHeader] Guid?clientRequestId = null)
        {
            var expectedVersion = options.ETagValue(t => t.Version);
            var fiveByFive      = (string)parameters["code"];
            var tokenHash       = HashFiveByFiveWithoutFormatting(fiveByFive);

            using (var circuitBreaker = this.NewCircuitBreaker(cancellationToken))
            {
                var token = await repository.GetSingleAsync(t => t.Hash == tokenHash, circuitBreaker.Token);

                var accountId = await accounts.FindConsumerAccount(User, circuitBreaker.Token);

                var redeem = new RedeemToken(token.Id, expectedVersion, accountId)
                {
                    CorrelationId = clientRequestId?.ToString()
                };

                await bus.Send(redeem, circuitBreaker.Token);
            }

            return(Ok());
        }
Пример #2
0
        public async Task then_the_token_should_transition_state()
        {
            // arrange
            var token  = Tokens.First();
            var redeem = new RedeemToken(token.Id, token.Version, accountId: "*****@*****.**")
            {
                CorrelationId = ScenarioCorrelationId
            };

            // act
            await Bus.Send(redeem);

            await Bus.Flush();

            // assert
            token.State.Should().Be(Redeemed);
        }