forked from loafle/openapi-generator-original
[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
This commit is contained in:
parent
e725c4e56f
commit
a3a0af7c84
@ -51,8 +51,9 @@ namespace Org.OpenAPITools.Test.Model
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void CatInstanceTest()
|
public void CatInstanceTest()
|
||||||
{
|
{
|
||||||
// TODO uncomment below to test "IsType" Cat
|
// test to ensure both Cat and Animal (parent) can have "AdditionalProperties", which result in warnings
|
||||||
//Assert.IsType<Cat>(instance);
|
Cat c = JsonConvert.DeserializeObject<Cat>("{\"className\":\"cat\",\"bar\":\"from json bar\"}");
|
||||||
|
Assert.Equal("from json bar", c.AdditionalProperties["bar"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,11 +100,22 @@ namespace Org.OpenAPITools.Test
|
|||||||
/// ReadOnly property tests
|
/// ReadOnly property tests
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ReadOnlyFruit()
|
public void TestReadOnlyFruit()
|
||||||
{
|
{
|
||||||
ReadOnlyFirst r = JsonConvert.DeserializeObject<ReadOnlyFirst>("{\"baz\":\"from json gaz\",\"bar\":\"from json bar\"}");
|
ReadOnlyFirst r = JsonConvert.DeserializeObject<ReadOnlyFirst>("{\"baz\":\"from json gaz\",\"bar\":\"from json bar\"}");
|
||||||
Assert.Equal("from json bar", r.Bar);
|
Assert.Equal("from json bar", r.Bar);
|
||||||
Assert.Equal("{\"baz\":\"from json gaz\"}", JsonConvert.SerializeObject(r));
|
Assert.Equal("{\"baz\":\"from json gaz\"}", JsonConvert.SerializeObject(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cat property tests
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void TestCat()
|
||||||
|
{
|
||||||
|
// test to ensure both Cat and Animal (parent) can have "AdditionalProperties", which result in warnings
|
||||||
|
Cat c = JsonConvert.DeserializeObject<Cat>("{\"className\":\"cat\",\"bar\":\"from json bar\"}");
|
||||||
|
Assert.Equal("from json bar", c.AdditionalProperties["bar"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user