Skip to content

Commit

Permalink
- Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nwithan8 committed Oct 30, 2024
1 parent 3097448 commit 7c2581c
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions EasyPost.Tests/HttpTests/RequestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,28 @@ public class RequestTest
[Fact]
public void TestRequestDisposal()
{
Request request = new("https://google.com", "not_a_real_endpoint", Method.Get, ApiVersion.V2, new Dictionary<string, object> { { "key", "value" } }, new Dictionary<string, string> { { "header_key", "header_value" } });
Request request = new("https://example.com", "not_a_real_endpoint", Method.Get, ApiVersion.V2, new Dictionary<string, object> { { "key", "value" } }, new Dictionary<string, string> { { "header_key", "header_value" } });
CustomAssertions.DoesNotThrow(() => request.Dispose());
}

[Fact]
public void TestQueryParameterList()
{
const string key = "key";
var value = new List<string>
{
"value1",
"value2"
};
const string key2 = "key2";
const string value2 = "value3";
var parameters = new Dictionary<string, object>
{
{ key, value },
{ key2, value2 }
{ "key1", new List<string> { "value1", "value2" } },
{ "key2", "value3" }
};

Request request = new("https://google.com", "not_a_real_endpoint", Method.Get, ApiVersion.V2, parameters, new Dictionary<string, string> { { "header_key", "header_value" } });
Request request = new("https://example.com", "not_a_real_endpoint", Method.Get, ApiVersion.V2, parameters, new Dictionary<string, string> { { "header_key", "header_value" } });

HttpRequestMessage httpRequestMessage = request.AsHttpRequestMessage();

string queryString = httpRequestMessage.RequestUri?.Query;

string keyWithArray = $"{key}[]";

foreach (string item in value)
{
Assert.Contains($"{keyWithArray}={item}", queryString); // Does not account for URL encoding
}
Assert.Contains($"{key2}={value2}", queryString); // Does not account for URL encoding
Assert.Contains("key1[]=value1", queryString); // Does not account for URL encoding
Assert.Contains("key1[]=value2", queryString); // Does not account for URL encoding
Assert.Contains("key2=value3", queryString); // Does not account for URL encoding
}

#endregion
Expand Down

0 comments on commit 7c2581c

Please sign in to comment.