Skip to content

Commit

Permalink
Add test of parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
fzzle committed Jan 10, 2024
1 parent 98c5c5f commit d8d037a
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,33 @@ public async Task When_property_name_is_created_by_custom_fun_then_attribute_is_
AssertCompile(output);
}

[Fact]
public async Task When_property_name_is_created_by_custom_fun_then_parameter_name_is_correct_for_record()
{
//// Arrange
var schema = NewtonsoftJsonSchemaGenerator.FromType<Address>();
var schemaData = schema.ToJson();
var settings = new CSharpGeneratorSettings
{
ClassStyle = CSharpClassStyle.Record,
PropertyNameGenerator = new CustomPropertyNameGenerator(),
};
var generator = new CSharpGenerator(schema, settings);

//// Act
var output = generator.GenerateFile("Address");

//// Assert
Assert.DoesNotContain(@"public string Street { get; }", output);
Assert.Contains(@"public string MyCustomStreet { get; }", output);
Assert.Contains(@"this.MyCustomStreet = @myCustomStreet;", output);

Assert.DoesNotContain(@"public Address(string @city, string @street)", output);
Assert.Contains(@"public Address(string @myCustomCity, string @myCustomStreet)", output);

AssertCompile(output);
}

[Fact]
public async Task When_schema_contains_ref_to_definition_that_refs_another_definition_then_result_should_contain_correct_target_ref_type()
{
Expand Down Expand Up @@ -1821,7 +1848,7 @@ public async Task When_class_is_abstract_constructor_is_protected_for_record()
var data = schema.ToJson();
var generator = new CSharpGenerator(schema, new CSharpGeneratorSettings
{
ClassStyle = CSharpClassStyle.Record
ClassStyle = CSharpClassStyle.Record,
});

//// Act
Expand Down

0 comments on commit d8d037a

Please sign in to comment.