public static void ReturnsEmptyStringForNewInstance() { var opts = new CdnJsApiRequestOptions(); var query = opts.ToQueryString(); Assert.Equal(string.Empty, query, StringComparer.Ordinal); }
public static void OutputQueryParameterIfTrue() { var opts = new CdnJsApiRequestOptions() { HumanReadableOutput = true }; string query = opts.ToQueryString(); Assert.Contains("output=", query, StringComparison.OrdinalIgnoreCase); }
public static void NoFieldsQueryParameterIfEmpty() { var opts = new CdnJsApiRequestOptions() { Fields = { } }; string query = opts.ToQueryString(); var param = HttpUtility.ParseQueryString(query); Assert.DoesNotContain("fields", param.Keys.Cast <string>()); }
public static void SupportsMultipleQueryParameters() { var opts = new CdnJsApiRequestOptions { HumanReadableOutput = true, Fields = { nameof(CdnJsLibraryMetadata.Name) } }; var query = opts.ToQueryString(); var param = HttpUtility.ParseQueryString(query); Assert.Equal(2, param.Count); }
public static void FieldsQueryParameterIfContainsJsonName(string json) { var opts = new CdnJsApiRequestOptions() { Fields = { json } }; string query = opts.ToQueryString(); var param = HttpUtility.ParseQueryString(query); Assert.Contains("fields", param.Keys.Cast <string>()); string value = param["fields"]; Assert.Equal(json, value, StringComparer.OrdinalIgnoreCase); }
public static void FieldsQueryParameterIfContainsPropertyName(string property) { var opts = new CdnJsApiRequestOptions() { Fields = { property } }; string query = opts.ToQueryString(); var param = HttpUtility.ParseQueryString(query); Assert.Contains("fields", param.Keys.Cast <string>()); string value = param["fields"]; Assert.NotEmpty(value); }
public static void MultipleFieldsSeparatedByCommaInQueryParameter() { var opts = new CdnJsApiRequestOptions() { Fields = { nameof(CdnJsLibraryMetadata.Name), nameof(CdnJsLibraryMetadata.Versions) } }; string query = opts.ToQueryString(); var param = HttpUtility.ParseQueryString(query); Assert.Contains("fields", param.Keys.Cast <string>()); string value = param["fields"]; Assert.NotEmpty(value); string[] items = value.Split(','); Assert.Equal(2, items.Length); }
public static void IsEmptyInNewInstance() { var opts = new CdnJsApiRequestOptions(); Assert.Empty(opts.Fields); }
public static void IsFalseInNewInstance() { var opts = new CdnJsApiRequestOptions(); Assert.False(opts.HumanReadableOutput); }