public void UnitTest1(Dictionary <string, string> claims) { var ActualResult = jwtBuilder.GetJWTToken(claims); Assert.NotNull(ActualResult); Assert.NotNull(ActualResult.ErrorList); Assert.Null(ActualResult.TokenDetail); Assert.True(ActualResult.StatusCode == 400); Assert.True(ActualResult.ErrorList.Count > 0); Assert.True(ActualResult.ErrorList.First().Message == "Claims can't be blank"); }
public JwtTokenResponse GetJWTToken(UserInformation userInformation) { JwtTokenResponse jwtTokenResponse = new JwtTokenResponse() { StatusCode = 200 }; if (userInformation == null) { jwtTokenResponse.StatusCode = 400; jwtTokenResponse.ErrorList = new List <JwtValidation>() { new JwtValidation() { FieldName = nameof(userInformation), Message = nameof(userInformation) + " can't be blank." } }; return(jwtTokenResponse); } if (string.IsNullOrWhiteSpace(userInformation.CustomerName)) { jwtTokenResponse.StatusCode = 400; jwtTokenResponse.ErrorList = new List <JwtValidation>() { new JwtValidation() { FieldName = nameof(userInformation.CustomerName), Message = nameof(userInformation.CustomerName) + " can't be blank." } }; return(jwtTokenResponse); } if (userInformation.UserId <= 0) { jwtTokenResponse.StatusCode = 400; jwtTokenResponse.ErrorList = new List <JwtValidation>() { new JwtValidation() { FieldName = nameof(userInformation.UserId), Message = nameof(userInformation.UserId) + " can't less then or equal to 0." } }; return(jwtTokenResponse); } Dictionary <string, string> claimList = new Dictionary <string, string>() { { "UserId", userInformation.UserId.ToString() }, { "UserName", userInformation.CustomerName.ToString() } }; jwtTokenResponse = _jwtBuilder.GetJWTToken(claimList, "Local Customer", null); return(jwtTokenResponse); }