public async Task <string> Post() { var query = GenerateBrowseTokenQuery.Create(); var browseToken = await _mediator.Send(query); var command = IssueBrowseTokenCommand.Create(browseToken, User.GetUserId()); await _mediator.Send(command); return(browseToken); }
public void GivenSampleToken_ThenTokenHasExpectedValue() { var command = IssueBrowseTokenCommand.Create("AB12ab", SampleUserId); var sut = new IssueBrowseTokenCommandHandler(_authorizationContextMock.Object, _timeProviderMock.Object); sut.Handle(command, CancellationToken.None).Wait(); _addedTokens.Should().Contain(token => token.Id == "AB12ab"); }
public void GivenSampleToken_ThenExpirationTimeIsInTheFuture() { var command = IssueBrowseTokenCommand.Create("AB12ab", SampleUserId); var sut = new IssueBrowseTokenCommandHandler(_authorizationContextMock.Object, _timeProviderMock.Object); sut.Handle(command, CancellationToken.None).Wait(); _addedTokens.Should().OnlyContain(token => token.ExpirationTime > _givenDate); }
public void GivenSampleToken_ThenSingleTokenIsAdded() { var command = IssueBrowseTokenCommand.Create("AB12ab", SampleUserId); var sut = new IssueBrowseTokenCommandHandler(_authorizationContextMock.Object, _timeProviderMock.Object); sut.Handle(command, CancellationToken.None).Wait(); _addedTokens.Count.Should().Be(1); }
public void GivenSampleToken_ThenExpiredTokensAreRemoved() { var expectedRemovedTokens = _givenBrowseTokens.Where(token => token.ExpirationTime <= _givenDate); var command = IssueBrowseTokenCommand.Create("AB12ab", SampleUserId); var sut = new IssueBrowseTokenCommandHandler(_authorizationContextMock.Object, _timeProviderMock.Object); sut.Handle(command, CancellationToken.None).Wait(); _removedTokens.Should().BeEquivalentTo(expectedRemovedTokens); }