Skip to content

Commit

Permalink
Add Spread And Multipart Test (#5081)
Browse files Browse the repository at this point in the history
* Update parameters-spread.cs

* Update payload-multipart.cs
  • Loading branch information
mcgallan authored Sep 27, 2024
1 parent 5eb669d commit 52f9cda
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/CadlRanchProjects.Tests/parameters-spread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,34 @@ public Task Parameters_Spread_Model_spreadAsRequestBody() => Test(async (host) =
Assert.AreEqual(204, response.Status);
});

[Test]
public Task Parameters_Spread_Model_spreadCompositeRequest() => Test(async (host) =>
{
Response response = await new SpreadClient(host, null).GetModelClient().SpreadCompositeRequestAsync("foo", "bar", new BodyParameter("foo"));
Assert.AreEqual(204, response.Status);
});

[Test]
public Task Parameters_Spread_Model_spreadCompositeRequestMix() => Test(async (host) =>
{
Response response = await new SpreadClient(host, null).GetModelClient().SpreadCompositeRequestMixAsync("foo", "bar", "foo");
Assert.AreEqual(204, response.Status);
});

[Test]
public Task Parameters_Spread_Model_spreadCompositeRequestOnlyWithBody() => Test(async (host) =>
{
Response response = await new SpreadClient(host, null).GetModelClient().SpreadCompositeRequestOnlyWithBodyAsync(new BodyParameter("foo"));
Assert.AreEqual(204, response.Status);
});

[Test]
public Task Parameters_Spread_Model_spreadCompositeRequestOnlyWithoutBody() => Test(async (host) =>
{
Response response = await new SpreadClient(host, null).GetModelClient().SpreadCompositeRequestWithoutBodyAsync("foo", "bar");
Assert.AreEqual(204, response.Status);
});

[Test]
public Task Parameters_Spread_Alias_spreadAsRequestBody() => Test(async (host) =>
{
Expand Down
31 changes: 31 additions & 0 deletions test/CadlRanchProjects.Tests/payload-multipart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,37 @@ public Task Payload_Multipart_FormData_BinaryArrayParts() => Test(async (host) =
Assert.AreEqual(204, response.Status);
});

[Test]
public Task Payload_Multipart_FormData_CheckFileNameAndContentType() => Test(async (host) =>
{
Address addressX = new Address("X");
var profileImage = System.IO.File.OpenRead(SampleJpgPath);
var pictures = new Stream[]
{
System.IO.File.OpenRead(SamplePngPath),
System.IO.File.OpenRead(SamplePngPath)
};
ComplexPartsRequest data = new ComplexPartsRequest("123", addressX, profileImage, pictures);
var response = await new MultiPartClient(host, null).GetFormDataClient().FileArrayAndBasicAsync(data);
Assert.AreEqual(204, response.Status);
});

[Test]
public Task Payload_Multipart_FormData_FileArrayAndBasic() => Test(async (host) =>
{
Address addressX = new Address("X");
var profileImage = System.IO.File.OpenRead(SampleJpgPath);
var pictures = new Stream[]
{
System.IO.File.OpenRead(SamplePngPath),
System.IO.File.OpenRead(SamplePngPath)
};
ComplexPartsRequest data = new ComplexPartsRequest("123", addressX, profileImage, pictures);
var response = await new MultiPartClient(host, null).GetFormDataClient().FileArrayAndBasicAsync(data);
Assert.AreEqual(204, response.Status);
});


[Test]
public Task Payload_Multipart_FormData_Anonymous_Model() => Test(async (host) =>
{
Expand Down

0 comments on commit 52f9cda

Please sign in to comment.