Skip to content

Commit a3a0af7

Browse files
authored
[C#][netcore] Add test for AdditionalProperties in both child and parent (#7921)
* add test for ap in both child and parent * add cat test to net47
1 parent e725c4e commit a3a0af7

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/CatTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ public void Dispose()
5151
[Fact]
5252
public void CatInstanceTest()
5353
{
54-
// TODO uncomment below to test "IsType" Cat
55-
//Assert.IsType<Cat>(instance);
54+
// test to ensure both Cat and Animal (parent) can have "AdditionalProperties", which result in warnings
55+
Cat c = JsonConvert.DeserializeObject<Cat>("{\"className\":\"cat\",\"bar\":\"from json bar\"}");
56+
Assert.Equal("from json bar", c.AdditionalProperties["bar"]);
5657
}
5758

5859

samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/JSONComposedSchemaTests.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,22 @@ public void TestFruit()
100100
/// ReadOnly property tests
101101
/// </summary>
102102
[Fact]
103-
public void ReadOnlyFruit()
103+
public void TestReadOnlyFruit()
104104
{
105105
ReadOnlyFirst r = JsonConvert.DeserializeObject<ReadOnlyFirst>("{\"baz\":\"from json gaz\",\"bar\":\"from json bar\"}");
106106
Assert.Equal("from json bar", r.Bar);
107107
Assert.Equal("{\"baz\":\"from json gaz\"}", JsonConvert.SerializeObject(r));
108108
}
109+
110+
/// <summary>
111+
/// Cat property tests
112+
/// </summary>
113+
[Fact]
114+
public void TestCat()
115+
{
116+
// test to ensure both Cat and Animal (parent) can have "AdditionalProperties", which result in warnings
117+
Cat c = JsonConvert.DeserializeObject<Cat>("{\"className\":\"cat\",\"bar\":\"from json bar\"}");
118+
Assert.Equal("from json bar", c.AdditionalProperties["bar"]);
119+
}
109120
}
110121
}

0 commit comments

Comments
 (0)