public void CreateHexString_ReturnRandomValue() { var pool = Enumerable.Range(0, 15).Select(e => RandomUtils.CreateHexString(15)).ToArray(); pool.Should().OnlyHaveUniqueItems(); pool.Select(e => e.Length).Should().AllBeEquivalentTo(44); }
/// <inheritdoc/> public Uri GetLoginUri() { var queryParams = new NameValueCollection { ["response_type"] = "code id_token", ["client_id"] = _authSetting.ClientId, ["redirect_uri"] = _authSetting.RedirectUri, ["state"] = RandomUtils.CreateHexString(15), ["scope"] = _authSetting.Scope, ["response_mode"] = "form_post" }; var uriBuilder = new UriBuilder(AppleAuthAuthorizeEndpoint) { Query = string.Join("&", ( from key in queryParams.AllKeys from value in queryParams.GetValues(key) select $"{HttpUtility.UrlEncode(key)}={HttpUtility.UrlEncode(value)}" ).ToArray()) }; return(uriBuilder.Uri); }
public void CreateHexString_InvalidParams_ThrowArgumentException() { FluentActions.Invoking(() => RandomUtils.CreateHexString(-1)).Should().Throw <ArgumentException>(); }