diff --git a/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/Payload/Xml/XmlTests.cs b/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/Payload/Xml/XmlTests.cs index 9a3976b4932..08d127442eb 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/Payload/Xml/XmlTests.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/Payload/Xml/XmlTests.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System; +using System.ClientModel; using System.Collections.Generic; using System.Threading.Tasks; using NUnit.Framework; @@ -388,5 +389,14 @@ public Task GetModelWithDatetime() => Test(async (host) => Assert.AreEqual(DateTimeOffset.Parse("2022-08-26T18:38:00Z"), model.Rfc3339); Assert.AreEqual(DateTimeOffset.Parse("Fri, 26 Aug 2022 14:38:00 GMT"), model.Rfc7231); }); + + [SpectorTest] + public Task GetXmlErrorValue() => Test((host) => + { + var exception = Assert.ThrowsAsync( + async () => await new XmlClient(host, null).GetXmlErrorValueClient().GetAsync()); + Assert.AreEqual(400, exception!.Status); + return Task.CompletedTask; + }); } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/SpecialWords/SpecialWordsTests.Models.cs b/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/SpecialWords/SpecialWordsTests.Models.cs index f6623d5bfc7..1027d52e8ee 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/SpecialWords/SpecialWordsTests.Models.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/SpecialWords/SpecialWordsTests.Models.cs @@ -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); + }); } } diff --git a/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/_Type/Property/AdditionalProperties/AdditionalPropertiesTests.cs b/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/_Type/Property/AdditionalProperties/AdditionalPropertiesTests.cs index 0550b638447..926d1cd492f 100644 --- a/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/_Type/Property/AdditionalProperties/AdditionalPropertiesTests.cs +++ b/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/_Type/Property/AdditionalProperties/AdditionalPropertiesTests.cs @@ -841,6 +841,45 @@ public Task SpreadRecordNonDiscriminatedUnion2Put() => Test(async host => Assert.AreEqual(204, response.GetRawResponse().Status); }); + [SpectorTest] + public Task SpreadRecordNonDiscriminatedUnion3Get() => Test(async host => + { + var response = await new AdditionalPropertiesClient(host, null).GetSpreadRecordNonDiscriminatedUnion3Client().GetAsync(); + Assert.AreEqual(200, response.GetRawResponse().Status); + Assert.AreEqual("abc", response.Value.Name); + Assert.AreEqual(2, response.Value.AdditionalProperties.Count); + using var jsonDoc = System.Text.Json.JsonDocument.Parse(response.Value.AdditionalProperties["prop1"].ToMemory()); + var prop1Items = jsonDoc.RootElement.EnumerateArray() + .Select(e => ModelReaderWriter.Read(BinaryData.FromString(e.GetRawText()))) + .ToList(); + Assert.AreEqual(2, prop1Items.Count); + Assert.AreEqual("2021-01-01T00:00:00Z", prop1Items[0]!.Start); + Assert.AreEqual("2021-01-01T00:00:00Z", prop1Items[1]!.Start); + var prop2 = ModelReaderWriter.Read(response.Value.AdditionalProperties["prop2"]); + Assert.AreEqual(new DateTimeOffset(2021, 1, 1, 0, 0, 0, TimeSpan.Zero), prop2!.Start); + Assert.AreEqual(new DateTimeOffset(2021, 1, 2, 0, 0, 0, TimeSpan.Zero), prop2.End); + }); + + [SpectorTest] + public Task SpreadRecordNonDiscriminatedUnion3Put() => Test(async host => + { + var prop1BinaryData = BinaryData.FromString( + "[{\"kind\":\"kind1\",\"start\":\"2021-01-01T00:00:00Z\"},{\"kind\":\"kind1\",\"start\":\"2021-01-01T00:00:00Z\"}]"); + var value = new SpreadRecordForNonDiscriminatedUnion3("abc") + { + AdditionalProperties = + { + ["prop1"] = prop1BinaryData, + ["prop2"] = ModelReaderWriter.Write(new WidgetData1(new DateTimeOffset(2021, 1, 1, 0, 0, 0, TimeSpan.Zero)) + { + End = new DateTimeOffset(2021, 1, 2, 0, 0, 0, TimeSpan.Zero) + }) + } + }; + var response = await new AdditionalPropertiesClient(host, null).GetSpreadRecordNonDiscriminatedUnion3Client().PutAsync(value); + Assert.AreEqual(204, response.GetRawResponse().Status); + }); + [SpectorTest] public Task SpreadRecordUnionGet() => Test(async host => {