public async Task Should_Generate_Jwt_Token() { // Arrange User user = FakeUsers.Performer; _arpaContext.SaveChangesAsync(Arg.Any <CancellationToken>()).Returns(1); // Act var token = await _jwtGenerator.CreateTokensAsync(user, "127.0.0.1"); // Assert JwtSecurityToken decryptedToken = new JwtSecurityTokenHandler().ReadJwtToken(token); decryptedToken.Claims.First(c => c.Type == "nameid").Value.Should().Be(user.UserName); decryptedToken.Claims.First(c => c.Type == "name").Value.Should().Be(user.DisplayName); decryptedToken.Claims.First(c => c.Type == "sub").Value.Should().Be(user.Id.ToString()); decryptedToken.Claims.First(c => c.Type == "issuer/person_id").Value.Should().Be(user.PersonId.ToString()); decryptedToken.Claims.First(c => c.Type == "role").Value.Should().BeEquivalentTo(RoleSeedData.Performer.Name); decryptedToken.Issuer.Should().Be(_configuration.Issuer); decryptedToken.Audiences.First().Should().Be(_configuration.Audience); }