public async Task ValidateAsync_Successful(string audience, TokenModel tokenModel, TokenValidationResult tokenValidationResult, TokenValidationRequest validationRequest, TokenValidationResponse tokenValidationResponse) { // Arrange _tokenValidationService .Setup(x => x.ValidateAsync(audience, tokenModel, It.IsAny <CancellationToken>())) .ReturnsAsync(tokenValidationResult); _mapper.Setup(x => x.Map <TokenModel>(It.Is <TokenValidationRequest>(p => p.Token == validationRequest.Token))).Returns(tokenModel); _mapper.Setup(x => x.Map <TokenValidationResponse>(tokenValidationResult)).Returns(tokenValidationResponse); // Act var result = await _client.PostAsync(string.Format(ValidationRequestPath, audience), new JsonContent(validationRequest)); // Assert result.StatusCode.Should().Be(StatusCodes.Status200OK); var resultValue = await result.Content.ReadAsAsync <TokenValidationResponse>(); resultValue.Should().BeEquivalentTo(tokenValidationResponse); _mapper.VerifyAll(); _tokenValidationService.VerifyAll(); }
public async Task ValidateAsync_Successful(string audience, TokenModel tokenModel, TokenValidationRequest validationRequest, TokenValidationResult tokenValidationResult, TokenValidationResponse tokenValidationResponse) { // Arrange _tokenValidationService .Setup(x => x.ValidateAsync(audience, tokenModel, CancellationToken.None)) .ReturnsAsync(tokenValidationResult); _mapper.Setup(x => x.Map <TokenValidationResponse>(tokenValidationResult)).Returns(tokenValidationResponse); _mapper.Setup(x => x.Map <TokenModel>(It.Is <TokenValidationRequest>(p => p.Token == validationRequest.Token))).Returns(tokenModel); // Act var result = await _controller.ValidateAsync(audience, validationRequest, CancellationToken.None); // Assert var okObjectResult = result.Should().BeOfType <OkObjectResult>(); okObjectResult.Subject.Value.Should().Be(tokenValidationResponse); _mapper.VerifyAll(); _tokenValidationService.VerifyAll(); }