Skip to content

Commit

Permalink
Update to ToPascalCase and Tests corrections. TestNetex is failing.
Browse files Browse the repository at this point in the history
  • Loading branch information
filippobottega committed Sep 4, 2023
1 parent 46b2dc3 commit b6278be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions XmlSchemaClassGenerator.Tests/XmlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,8 @@ public void TestXbrl()

var testFiles = new Dictionary<string, string>
{
{ "Schaltbau.xhtml", "XhtmlPeriodHtmlPeriodType" },
{ "GLEIF Annual Accounts.html", "XhtmlPeriodHtmlPeriodType" },
{ "Schaltbau.xhtml", "XhtmlHtmlType" },
{ "GLEIF Annual Accounts.html", "XhtmlHtmlType" },
};

foreach (var testFile in testFiles)
Expand Down Expand Up @@ -767,7 +767,7 @@ public void TestCustomNamespaces()
{
{ bpmnXsd, "TDefinitions" },
{ semantXsd, "TActivity" },
{ bpmndiXsd, "BPMNDiagram" },
{ bpmndiXsd, "BpmnDiagram" },
{ dcXsd, "Font" },
{ diXsd, "DiagramElement" }
};
Expand Down Expand Up @@ -1139,7 +1139,7 @@ namespace Test
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(""group-name"", Namespace="""")]
[System.ComponentModel.DesignerCategoryAttribute(""code"")]
public partial class Group_Name
public partial class GroupName
{
/// <summary>
Expand Down Expand Up @@ -1743,11 +1743,11 @@ public void EnumWithNonUniqueEntriesTest()
var durationEnumType = assembly.GetType("Test.TestEnum");
Assert.NotNull(durationEnumType);

var expectedEnumValues = new[] {"Test_Case", "Test_Case1", "Test_Case2", "Test_Case3"};
var expectedEnumValues = new[] {"TestCase", "TestCase1", "TestCase2", "TestCase3"};
var enumValues = durationEnumType.GetEnumNames().OrderBy(n => n).ToList();
Assert.Equal(expectedEnumValues, enumValues);

var mEnumValue = durationEnumType.GetMembers().First(mi => mi.Name == "Test_Case1");
var mEnumValue = durationEnumType.GetMembers().First(mi => mi.Name == "TestCase1");
var xmlEnumAttribute = mEnumValue.GetCustomAttributes<XmlEnumAttribute>().FirstOrDefault();
Assert.NotNull(xmlEnumAttribute);
Assert.Equal("test_Case", xmlEnumAttribute.Name);
Expand Down Expand Up @@ -2398,13 +2398,13 @@ public void TestArrayOfMsTypeGeneration()
var generator = new Generator
{
IntegerDataType = typeof(int),
NamespacePrefix = "Test_NS1",
NamespacePrefix = "TestNS1",
GenerateNullables = true,
CollectionType = typeof(System.Collections.Generic.List<>)
};
var contents = ConvertXml(nameof(TestArrayOfMsTypeGeneration), new[] { xsd0, xsd1 }, generator).ToArray();
var assembly = Compiler.Compile(nameof(TestForceIsNullableGeneration), contents);
var testType = assembly.GetType("Test_NS1.C_Ai");
var testType = assembly.GetType("TestNS1.CAi");
var serializer = new XmlSerializer(testType);
Assert.NotNull(serializer);
dynamic deserialized = serializer.Deserialize(new StringReader(validXml));
Expand Down Expand Up @@ -2773,10 +2773,10 @@ public void TestArrayItemAttribute()
};
var contents = ConvertXml(nameof(TestArrayItemAttribute), new[] { xsd }, generator).ToArray();
var assembly = Compiler.Compile(nameof(TestArrayItemAttribute), contents);
var applicationType = assembly.GetType("Test_Generation_Namespace.T_Application");
var applicationType = assembly.GetType("TestGenerationNamespace.TApplication");
Assert.NotNull(applicationType);
var optionList = applicationType.GetProperty("OptionList");
Assert.Equal("Test_Generation_Namespace.T_OptionList", optionList.PropertyType.FullName);
Assert.Equal("TestGenerationNamespace.TOptionList", optionList.PropertyType.FullName);
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions XmlSchemaClassGenerator/CodeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public static class CodeUtilities
// "INVALID VALUE AND _2THINGS" "InvalidValueAnd2Things"
public static string ToPascalCase(this string original)
{
// replace white spaces with undescore, then replace all invalid chars with empty string
var pascalCase = invalidCharsRgx.Replace(whiteSpace.Replace(original, "_"), string.Empty)
// replace white spaces with undescore, then replace all invalid chars with undescore
var pascalCase = invalidCharsRgx.Replace(whiteSpace.Replace(original, "_"), "_")
// split by underscores
.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries)
// set first letter to uppercase
Expand Down

0 comments on commit b6278be

Please sign in to comment.