Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,83 @@ private Task MultiBinaryParts(bool hasPicture) => Test(async (host) =>
.MultiBinaryPartsAsync(content, content.ContentType, null);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task WithWireName() => Test(async (host) =>
{
using MultiPartFormDataBinaryContent content = new MultiPartFormDataBinaryContent();
content.Add("123", "id");
await using var imageStream = File.OpenRead(SampleJpgPath);
content.Add(imageStream, "profileImage", "profileImage", "application/octet-stream");

var response = await new MultiPartClient(host, null).GetFormDataClient()
.WithWireNameAsync(content, content.ContentType, null);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task OptionalParts() => Test(async (host) =>
{
var client = new MultiPartClient(host, null).GetFormDataClient();

using MultiPartFormDataBinaryContent contentIdOnly = new MultiPartFormDataBinaryContent();
contentIdOnly.Add("123", "id");
var response1 = await client.OptionalPartsAsync(contentIdOnly, contentIdOnly.ContentType, null);
Assert.AreEqual(204, response1.GetRawResponse().Status);

await using var imageStream1 = File.OpenRead(SampleJpgPath);
using MultiPartFormDataBinaryContent contentImageOnly = new MultiPartFormDataBinaryContent();
contentImageOnly.Add(imageStream1, "profileImage", "profileImage", "application/octet-stream");
var response2 = await client.OptionalPartsAsync(contentImageOnly, contentImageOnly.ContentType, null);
Assert.AreEqual(204, response2.GetRawResponse().Status);

await using var imageStream2 = File.OpenRead(SampleJpgPath);
using MultiPartFormDataBinaryContent contentBoth = new MultiPartFormDataBinaryContent();
contentBoth.Add("123", "id");
contentBoth.Add(imageStream2, "profileImage", "profileImage", "application/octet-stream");
var response3 = await client.OptionalPartsAsync(contentBoth, contentBoth.ContentType, null);
Assert.AreEqual(204, response3.GetRawResponse().Status);
});

[SpectorTest]
public Task FileUploadFileSpecificContentType() => Test(async (host) =>
{
using MultiPartFormDataBinaryContent content = new MultiPartFormDataBinaryContent();
await using var imageStream = File.OpenRead(SamplePngPath);
content.Add(imageStream, "file", "image.png", "image/png");

var response = await new MultiPartClient(host, null).GetFormDataClient()
.GetFormDataFileClient()
.UploadFileSpecificContentTypeAsync(content, content.ContentType, null);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task FileUploadFileRequiredFilename() => Test(async (host) =>
{
using MultiPartFormDataBinaryContent content = new MultiPartFormDataBinaryContent();
await using var imageStream = File.OpenRead(SamplePngPath);
content.Add(imageStream, "file", "image.png", "image/png");

var response = await new MultiPartClient(host, null).GetFormDataClient()
.GetFormDataFileClient()
.UploadFileRequiredFilenameAsync(content, content.ContentType, null);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task FileUploadFileArray() => Test(async (host) =>
{
using MultiPartFormDataBinaryContent content = new MultiPartFormDataBinaryContent();
await using var imageStream1 = File.OpenRead(SamplePngPath);
content.Add(imageStream1, "files", "image1.png", "image/png");
await using var imageStream2 = File.OpenRead(SamplePngPath);
content.Add(imageStream2, "files", "image2.png", "image/png");

var response = await new MultiPartClient(host, null).GetFormDataClient()
.GetFormDataFileClient()
.UploadFileArrayAsync(content, content.ContentType, null);
Assert.AreEqual(204, response.GetRawResponse().Status);
});
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.ClientModel;
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
Expand Down Expand Up @@ -352,5 +353,14 @@ public Task PutModelWithEncodedNames() => Test(async (host) =>

Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task GetXmlErrorValue() => Test((host) =>
{
var exception = Assert.ThrowsAsync<ClientResultException>(
async () => await new XmlClient(host, null).GetXmlErrorValueClient().GetAsync());
Assert.AreEqual(400, exception!.Status);
return Task.CompletedTask;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,185 @@ public Task LabelExpansionRecord() => Test(async (host) =>
.RecordAsync(new Dictionary<string, int> {{"a", 1}, {"b", 2}});
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task SimpleExpansionPrimitive() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersSimpleExpansionClient()
.GetPathParametersSimpleExpansionStandardClient()
.PrimitiveAsync("a");
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task SimpleExpansionArray() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersSimpleExpansionClient()
.GetPathParametersSimpleExpansionStandardClient()
.ArrayAsync(["a", "b"]);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task SimpleExpansionRecord() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersSimpleExpansionClient()
.GetPathParametersSimpleExpansionStandardClient()
.RecordAsync(new Dictionary<string, int> {{"a", 1}, {"b", 2}});
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task SimpleExpansionExplodePrimitive() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersSimpleExpansionClient()
.GetPathParametersSimpleExpansionExplodeClient()
.PrimitiveAsync("a");
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task SimpleExpansionExplodeArray() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersSimpleExpansionClient()
.GetPathParametersSimpleExpansionExplodeClient()
.ArrayAsync(["a", "b"]);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task SimpleExpansionExplodeRecord() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersSimpleExpansionClient()
.GetPathParametersSimpleExpansionExplodeClient()
.RecordAsync(new Dictionary<string, int> {{"a", 1}, {"b", 2}});
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task PathExpansionPrimitive() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersPathExpansionClient()
.GetPathParametersPathExpansionStandardClient()
.PrimitiveAsync("a");
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task PathExpansionArray() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersPathExpansionClient()
.GetPathParametersPathExpansionStandardClient()
.ArrayAsync(["a", "b"]);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task PathExpansionRecord() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersPathExpansionClient()
.GetPathParametersPathExpansionStandardClient()
.RecordAsync(new Dictionary<string, int> {{"a", 1}, {"b", 2}});
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task PathExpansionExplodePrimitive() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersPathExpansionClient()
.GetPathParametersPathExpansionExplodeClient()
.PrimitiveAsync("a");
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task PathExpansionExplodeArray() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersPathExpansionClient()
.GetPathParametersPathExpansionExplodeClient()
.ArrayAsync(["a", "b"]);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task PathExpansionExplodeRecord() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersPathExpansionClient()
.GetPathParametersPathExpansionExplodeClient()
.RecordAsync(new Dictionary<string, int> {{"a", 1}, {"b", 2}});
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task MatrixExpansionPrimitive() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersMatrixExpansionClient()
.GetPathParametersMatrixExpansionStandardClient()
.PrimitiveAsync("a");
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task MatrixExpansionArray() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersMatrixExpansionClient()
.GetPathParametersMatrixExpansionStandardClient()
.ArrayAsync(["a", "b"]);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task MatrixExpansionRecord() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersMatrixExpansionClient()
.GetPathParametersMatrixExpansionStandardClient()
.RecordAsync(new Dictionary<string, int> {{"a", 1}, {"b", 2}});
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task MatrixExpansionExplodePrimitive() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersMatrixExpansionClient()
.GetPathParametersMatrixExpansionExplodeClient()
.PrimitiveAsync("a");
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task MatrixExpansionExplodeArray() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersMatrixExpansionClient()
.GetPathParametersMatrixExpansionExplodeClient()
.ArrayAsync(["a", "b"]);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task MatrixExpansionExplodeRecord() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetPathParametersClient()
.GetPathParametersMatrixExpansionClient()
.GetPathParametersMatrixExpansionExplodeClient()
.RecordAsync(new Dictionary<string, int> {{"a", 1}, {"b", 2}});
Assert.AreEqual(204, response.GetRawResponse().Status);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,38 @@ public Task QueryContinuationRecord() => Test(async (host) =>
.RecordAsync(new Dictionary<string, int> {{"a", 1}, {"b", 2}});
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
[Ignore("https://github.com/microsoft/typespec/issues/5139")]
public Task QueryContinuationExplodePrimitive() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetQueryParametersClient()
.GetQueryParametersQueryContinuationClient()
.GetQueryParametersQueryContinuationExplodeClient()
.PrimitiveAsync("a");
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
[Ignore("https://github.com/microsoft/typespec/issues/5139")]
public Task QueryContinuationExplodeArray() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetQueryParametersClient()
.GetQueryParametersQueryContinuationClient()
.GetQueryParametersQueryContinuationExplodeClient()
.ArrayAsync(["a", "b"]);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
[Ignore("https://github.com/microsoft/typespec/issues/5139")]
public Task QueryContinuationExplodeRecord() => Test(async (host) =>
{
var response = await new RoutesClient(host, null).GetQueryParametersClient()
.GetQueryParametersQueryContinuationClient()
.GetQueryParametersQueryContinuationExplodeClient()
.RecordAsync(new Dictionary<string, int> {{"a", 1}, {"b", 2}});
Assert.AreEqual(204, response.GetRawResponse().Status);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,23 @@ public Task ModelProperties_SameAsModelAsync() => Test(async (host) =>
var response = await client.SameAsModelAsync(body);
NUnit.Framework.Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task ModelProperties_DictMethodsAsync() => Test(async (host) =>
{
DictMethods body = new DictMethods("ok", "ok", "ok", "ok", "ok", "ok", "ok", "ok", "ok", "ok");
var client = new SpecialWordsClient(host, null).GetModelPropertiesClient();
var response = await client.DictMethodsAsync(body);
NUnit.Framework.Assert.AreEqual(204, response.GetRawResponse().Status);
});

[SpectorTest]
public Task ModelProperties_WithListAsync() => Test(async (host) =>
{
ModelWithList body = new ModelWithList("ok");
var client = new SpecialWordsClient(host, null).GetModelPropertiesClient();
var response = await client.WithListAsync(body);
NUnit.Framework.Assert.AreEqual(204, response.GetRawResponse().Status);
});
}
}
Loading
Loading