Skip to content

Commit

Permalink
feat(*): use pascal case for generated c# code (#21)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Stone <[email protected]>

Signed-off-by: Simon Stone <[email protected]>
  • Loading branch information
Simon Stone authored Sep 14, 2022
1 parent e18d991 commit d5a2dad
Show file tree
Hide file tree
Showing 6 changed files with 496 additions and 431 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public void SimpleObject_Succeeds()

employee.ShouldEqual(new Employee()
{
firstName = "Matt",
lastName = "Roberts",
email = "[email protected]",
_identifier = "[email protected]",
department = Department.ENGINEERING,
employeeId = "123"
FirstName = "Matt",
LastName = "Roberts",
Email = "[email protected]",
_Identifier = "[email protected]",
Department = Department.ENGINEERING,
EmployeeId = "123"
});
}

Expand All @@ -66,13 +66,13 @@ public void SimpleObject_DeserializeToSuperType_Succeeds()

employee.ToExpectedObject().ShouldEqual(new Manager()
{
firstName = "Matt",
lastName = "Roberts",
email = "[email protected]",
_identifier = "[email protected]",
department = Department.ENGINEERING,
employeeId = "123",
budget = 1
FirstName = "Matt",
LastName = "Roberts",
Email = "[email protected]",
_Identifier = "[email protected]",
Department = Department.ENGINEERING,
EmployeeId = "123",
Budget = 1
});

// Should not throw
Expand Down Expand Up @@ -144,18 +144,18 @@ public void PolymorphicObject_Succeeds()

employee.ShouldEqual(new Employee()
{
firstName = "Matt",
lastName = "Roberts",
email = "[email protected]",
_identifier = "[email protected]",
department = Department.ENGINEERING,
employeeId = "123",
manager = new Employee(){
email = "[email protected]",
_identifier = "[email protected]",
employeeId = "456",
firstName = "Martin",
lastName = "Halford",
FirstName = "Matt",
LastName = "Roberts",
Email = "[email protected]",
_Identifier = "[email protected]",
Department = Department.ENGINEERING,
EmployeeId = "123",
Manager = new Employee(){
Email = "[email protected]",
_Identifier = "[email protected]",
EmployeeId = "456",
FirstName = "Martin",
LastName = "Halford",
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ public void Roundtrip()
{
var carVIN = new StringProperty()
{
name = "vin"
Name = "vin"
};

var carConcept = new ConceptDeclaration()
{
name = "Car",
isAbstract = false,
properties = new StringProperty[1] { carVIN }
Name = "Car",
IsAbstract = false,
Properties = new StringProperty[1] { carVIN }
};

var carModel = new Model()
{
_namespace = "org.acme",
declarations = new ConceptDeclaration[1] { carConcept },
Namespace = "org.acme",
Declarations = new ConceptDeclaration[1] { carConcept },
};

var jsonString = JsonConvert.SerializeObject(carModel);
Model model2 = JsonConvert.DeserializeObject<Model>(jsonString);
ConceptDeclaration car2 = (ConceptDeclaration) model2.declarations[0];
StringProperty prop = (StringProperty)((ConceptDeclaration)car2).properties[0];
Assert.Equal(prop._class,"[email protected]");
ConceptDeclaration car2 = (ConceptDeclaration) model2.Declarations[0];
StringProperty prop = (StringProperty)((ConceptDeclaration)car2).Properties[0];
Assert.Equal(prop._Class,"[email protected]");
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public void SimpleObject()
{
Employee employee = new Employee()
{
firstName = "Matt",
lastName = "Roberts",
email = "[email protected]",
_identifier = "[email protected]",
department = Department.ENGINEERING,
employeeId = "123"
FirstName = "Matt",
LastName = "Roberts",
Email = "[email protected]",
_Identifier = "[email protected]",
Department = Department.ENGINEERING,
EmployeeId = "123"
};

string jsonString = JsonConvert.SerializeObject(employee);
Expand All @@ -53,17 +53,17 @@ public void ComplexObject()
{
Employee employee = new Employee()
{
firstName = "Matt",
lastName = "Roberts",
email = "[email protected]",
_identifier = "[email protected]",
department = Department.ENGINEERING,
employeeId = "123",
manager = new Employee(){
email = "[email protected]",
employeeId = "456",
firstName = "Martin",
lastName = "Halford",
FirstName = "Matt",
LastName = "Roberts",
Email = "[email protected]",
_Identifier = "[email protected]",
Department = Department.ENGINEERING,
EmployeeId = "123",
Manager = new Employee(){
Email = "[email protected]",
EmployeeId = "456",
FirstName = "Martin",
LastName = "Halford",
}
};

Expand Down Expand Up @@ -94,18 +94,18 @@ public void PolymorphicObject()
{
Employee employee = new Employee()
{
firstName = "Matt",
lastName = "Roberts",
email = "[email protected]",
_identifier = "[email protected]",
department = Department.ENGINEERING,
employeeId = "123",
manager = new Manager(){
email = "[email protected]",
employeeId = "456",
firstName = "Martin",
lastName = "Halford",
budget = 500000
FirstName = "Matt",
LastName = "Roberts",
Email = "[email protected]",
_Identifier = "[email protected]",
Department = Department.ENGINEERING,
EmployeeId = "123",
Manager = new Manager(){
Email = "[email protected]",
EmployeeId = "456",
FirstName = "Martin",
LastName = "Halford",
Budget = 500000
}
};

Expand Down
67 changes: 36 additions & 31 deletions AccordProject.Concerto.Tests/TestTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,44 @@
* limitations under the License.
*/

namespace AccordProject.Concerto.Tests {
using AccordProject.Concerto;
[AccordProject.Concerto.Type(Namespace = "org.accordproject.concerto.test", Version = "1.2.3", Name = "Person")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public abstract class Person : Participant {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _class { get; } = "[email protected]";
public string email { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
}
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public enum Department {
namespace AccordProject.Concerto.Tests;
using AccordProject.Concerto;
[AccordProject.Concerto.Type(Namespace = "org.accordproject.concerto.test", Version = "1.2.3", Name = "Person")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public abstract class Person : Participant {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("email")]
public string Email { get; set; }
[Newtonsoft.Json.JsonProperty("firstName")]
public string FirstName { get; set; }
[Newtonsoft.Json.JsonProperty("lastName")]
public string LastName { get; set; }
}
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public enum Department {
MARKETING,
SALES,
ENGINEERING,
OPERATIONS,
}

[AccordProject.Concerto.Type(Namespace = "org.accordproject.concerto.test", Version = "1.2.3", Name = "Employee")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class Employee : Person {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _class { get; } = "[email protected]";
public Department? department { get; set; }
public Employee manager { get; set; }
public string employeeId { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "org.accordproject.concerto.test", Version = "1.2.3", Name = "Manager")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class Manager : Employee {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _class { get; } = "[email protected]";
public float budget { get; set; }
}
}
[AccordProject.Concerto.Type(Namespace = "org.accordproject.concerto.test", Version = "1.2.3", Name = "Employee")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class Employee : Person {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("department")]
public Department? Department { get; set; }
[Newtonsoft.Json.JsonProperty("manager")]
public Employee Manager { get; set; }
[Newtonsoft.Json.JsonProperty("employeeId")]
public string EmployeeId { get; set; }
}
[AccordProject.Concerto.Type(Namespace = "org.accordproject.concerto.test", Version = "1.2.3", Name = "Manager")]
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
public class Manager : Employee {
[Newtonsoft.Json.JsonProperty("$class")]
public override string _Class { get; } = "[email protected]";
[Newtonsoft.Json.JsonProperty("budget")]
public float Budget { get; set; }
}
Loading

0 comments on commit d5a2dad

Please sign in to comment.