-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from bonsai-rx/feature-dev
Generate ToString override with member formatting
- Loading branch information
Showing
2 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using NJsonSchema; | ||
using System.Threading.Tasks; | ||
|
||
namespace Bonsai.Sgen.Tests | ||
{ | ||
[TestClass] | ||
public class ToStringGenerationTests | ||
{ | ||
private static Task<JsonSchema> CreateTestSchema() | ||
{ | ||
return JsonSchema.FromJsonAsync(@" | ||
{ | ||
""$schema"": ""http://json-schema.org/draft-04/schema#"", | ||
""type"": ""object"", | ||
""title"": ""Container"", | ||
""properties"": { | ||
""BaseType"": { | ||
""oneOf"": [ | ||
{ | ||
""$ref"": ""#/definitions/BaseType"" | ||
}, | ||
{ | ||
""type"": ""null"" | ||
} | ||
] | ||
} | ||
}, | ||
""definitions"": { | ||
""DerivedType"": { | ||
""type"": ""object"", | ||
""properties"": { | ||
""Bar"": { | ||
""type"": [ | ||
""null"", | ||
""string"" | ||
] | ||
}, | ||
""Baz"": { | ||
""type"": [ | ||
""null"", | ||
""integer"" | ||
] | ||
} | ||
}, | ||
""allOf"": [ | ||
{ | ||
""$ref"": ""#/definitions/BaseType"" | ||
} | ||
] | ||
}, | ||
""EmptyDerivedType"": { | ||
""type"": ""object"", | ||
""allOf"": [ | ||
{ | ||
""$ref"": ""#/definitions/BaseType"" | ||
} | ||
] | ||
}, | ||
""BaseType"": { | ||
""type"": ""object"" | ||
} | ||
} | ||
} | ||
"); | ||
} | ||
|
||
[TestMethod] | ||
public async Task GenerateToStringOverride_FormatMultipleProperties() | ||
{ | ||
var schema = await CreateTestSchema(); | ||
var generator = TestHelper.CreateGenerator(schema); | ||
var code = generator.GenerateFile(); | ||
CompilerTestHelper.CompileFromSource(code); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters