public void WhenHasEmptyKey_ThenUseEmptyName() { var result = UriQueryConverter.ToNameValueCollection("=value"); Assert.That(result.AllKeys.Length, Is.EqualTo(1)); Assert.That(result[string.Empty], Is.EqualTo("value")); }
public void WhenValueContainsEquals_ThenReturnNameValues() { var result = UriQueryConverter.ToNameValueCollection("?key1=value=1&key2=value2=="); Assert.That(result.AllKeys.Length, Is.EqualTo(2)); Assert.That(result["key1"], Is.EqualTo("value=1")); Assert.That(result["key2"], Is.EqualTo("value2==")); }
public void WhenParamNameAndValueContainsEncodableChars_ThenDecodeNamesAndValues() { var result = UriQueryConverter.ToNameValueCollection("?key1=value1&key+2=value+2&key%2f3=value%2f3"); Assert.That(result["key1"], Is.EqualTo("value1")); Assert.That(result["key 2"], Is.EqualTo("value 2")); Assert.That(result["key/3"], Is.EqualTo("value/3")); }
public void WhenWithQuestionMark_ThenReturnNameValues() { var result = UriQueryConverter.ToNameValueCollection("?key1=value1&key2=value2"); Assert.That(result.AllKeys.Length, Is.EqualTo(2)); Assert.That(result["key1"], Is.EqualTo("value1")); Assert.That(result["key2"], Is.EqualTo("value2")); }
public void WhenQueryNoValue_ThenReturnNameValues() { var result = UriQueryConverter.ToNameValueCollection("?key1&key2&key3=value3"); Assert.That(result.AllKeys.Length, Is.EqualTo(3)); Assert.That(result["key1"], Is.Null); Assert.That(result["key2"], Is.Null); Assert.That(result["key3"], Is.EqualTo("value3")); }
public void WhenIsNullOrEmptyOrQuestionMark_ThenReturnEmpty(string query) { var result = UriQueryConverter.ToNameValueCollection(query); Assert.That(result, Is.Empty); }