Skip to content

Commit

Permalink
[http-client-csharp] test: add more additional properties cadl ranch …
Browse files Browse the repository at this point in the history
…tests (#5115)

fixes: #5098
  • Loading branch information
jorgerangel-msft authored Nov 14, 2024
1 parent 9f9f5f7 commit e23ab9b
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,40 @@ public Task ExtendsModelArrayGet() => Test(async (host) =>
Assert.AreEqual("ok", prop[1]!.State);
});

[CadlRanchTest]
public Task ExtendsModelArrayPut() => Test(async (host) =>
{
var value = new ExtendsModelArrayAdditionalProperties([new ModelForRecord("ok"), new ModelForRecord("ok")])
{
AdditionalProperties =
{
["prop"] =
[
ModelReaderWriter.Write(new ModelForRecord("ok")),
ModelReaderWriter.Write(new ModelForRecord("ok"))
]
}
};
var response = await new AdditionalPropertiesClient(host, null).GetExtendsModelArrayClient().PutAsync(value);
Assert.AreEqual(204, response.GetRawResponse().Status);
});

[CadlRanchTest]
public Task IsModelArrayGet() => Test(async (host) =>
{
var response = await new AdditionalPropertiesClient(host, null).GetIsModelArrayClient().GetAsync();
Assert.AreEqual(200, response.GetRawResponse().Status);
var value = response.Value;
Assert.AreEqual(1, value.AdditionalProperties.Count);
Assert.IsTrue(value.AdditionalProperties.ContainsKey("prop"));
var prop = value.AdditionalProperties["prop"].Select(item => ModelReaderWriter.Read<ModelForRecord>(item)).ToList();
Assert.AreEqual(2, prop.Count);
Assert.AreEqual("ok", prop[0]!.State);
Assert.AreEqual("ok", prop[1]!.State);
});

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

0 comments on commit e23ab9b

Please sign in to comment.