Пример #1
0
        public async Task AuthorizeAccountCommandHandler_Handle_InvalidCredentialsFail()
        {
            await _accountRepository.AddAsync(new Account("*****@*****.**", "secret"), CancellationToken.None);

            await _accountRepository.UnitOfWork.SaveEntitiesAsync(CancellationToken.None);

            await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                var authorizeAccountCommandHandler = new AuthorizeAccountCommandHandler(_authorizationService);
                var unused = await authorizeAccountCommandHandler.Handle(
                    new AuthorizeAccountCommand("*****@*****.**", "asdfg"),
                    CancellationToken.None);
            });
        }
Пример #2
0
        public async Task AuthorizeAccountCommandHandler_Handle_AccountAuthorized()
        {
            await _accountRepository.AddAsync(new Account("*****@*****.**", "secret"), CancellationToken.None);

            await _accountRepository.UnitOfWork.SaveEntitiesAsync(CancellationToken.None);

            var authorizeAccountCommandHandler = new AuthorizeAccountCommandHandler(_authorizationService);
            var token = await authorizeAccountCommandHandler.Handle(
                new AuthorizeAccountCommand("*****@*****.**", "secret"),
                CancellationToken.None);

            Assert.NotNull(token);
            Assert.True(token.Token.Length > 0);
            Assert.True(token.ExpiresAt > DateTime.UtcNow);
        }