Skip to content

Commit

Permalink
Add regression testing for snake case
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed Jan 18, 2024
1 parent 5fa58d2 commit 898efe9
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Bonsai.Sgen.Tests/CasingGenerationTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NJsonSchema;

namespace Bonsai.Sgen.Tests
{
[TestClass]
public class CasingGenerationTests
{
private static Task<JsonSchema> CreateTestSchema()
{
return JsonSchema.FromJsonAsync(@"
{
""$schema"": ""http://json-schema.org/draft-04/schema#"",
""type"": ""object"",
""title"": ""Container"",
""properties"": {
""base_type"": {
""oneOf"": [
{
""$ref"": ""#/definitions/thing_container""
},
{
""type"": ""null""
}
]
}
},
""definitions"": {
""thing_container"": {
""type"": ""object"",
""properties"": {
""bar"": {
""type"": [
""null"",
""string""
]
}
}
}
}
}
");
}

[TestMethod]
public async Task GenerateFromSnakeCase_GeneratePascalCaseNames()
{
var schema = await CreateTestSchema();
var generator = TestHelper.CreateGenerator(schema);
var code = generator.GenerateFile();
Assert.IsTrue(code.Contains("public ThingContainer BaseType"), "Incorrect casing for property name.");
CompilerTestHelper.CompileFromSource(code);
}
}
}

0 comments on commit 898efe9

Please sign in to comment.