From 1fbc339874f546064b999461b59e80c80ee8fbe5 Mon Sep 17 00:00:00 2001 From: Michael Ganss Date: Mon, 8 Jul 2019 12:08:41 +0200 Subject: [PATCH] Add vstst test (modified, see #119) Surface GenerateComplexTypesForCollections on cli and make it true by default --- XmlSampleGenerator/XmlSampleGenerator.cs | 8 +- XmlSchemaClassGenerator.Console/Program.cs | 5 +- XmlSchemaClassGenerator.Tests/Compiler.cs | 4 +- .../XmlSchemaClassGenerator.Tests.csproj | 6 + XmlSchemaClassGenerator.Tests/XmlTests.cs | 13 + .../xsd/vstst/vstst.xsd | 3011 +++++++++++++++++ .../GeneratorConfiguration.cs | 2 +- 7 files changed, 3044 insertions(+), 5 deletions(-) create mode 100644 XmlSchemaClassGenerator.Tests/xsd/vstst/vstst.xsd diff --git a/XmlSampleGenerator/XmlSampleGenerator.cs b/XmlSampleGenerator/XmlSampleGenerator.cs index 3a3af2ff..a5473bbd 100644 --- a/XmlSampleGenerator/XmlSampleGenerator.cs +++ b/XmlSampleGenerator/XmlSampleGenerator.cs @@ -709,8 +709,12 @@ private void ProcessGroup(InstanceGroup grp) { } private void ProcessChoiceGroup(InstanceGroup grp) { - for (int i=0; i < grp.Occurs; i++) { //Cyclically iterate over the children of choice - ProcessGroup(grp.GetChild(i % grp.NoOfChildren)); + if (grp.NoOfChildren > 0) + { + for (int i = 0; i < grp.Occurs; i++) + { //Cyclically iterate over the children of choice + ProcessGroup(grp.GetChild(i % grp.NoOfChildren)); + } } } diff --git a/XmlSchemaClassGenerator.Console/Program.cs b/XmlSchemaClassGenerator.Console/Program.cs index e9b53591..f29fdd1f 100644 --- a/XmlSchemaClassGenerator.Console/Program.cs +++ b/XmlSchemaClassGenerator.Console/Program.cs @@ -40,6 +40,7 @@ static void Main(string[] args) var doNotUseUnderscoreInPrivateMemberNames = false; var generateDescriptionAttribute = true; var enableUpaCheck = true; + var generateComplexTypesForCollections = true; var options = new OptionSet { { "h|help", "show this message and exit", v => showHelp = v != null }, @@ -86,6 +87,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l { "dc|disableComments", "do not include comments from xsd", v => disableComments = v != null }, { "nu|noUnderscore", "do not generate underscore in private member name (default is false)", v => doNotUseUnderscoreInPrivateMemberNames = v != null }, { "da|description", "generate DescriptionAttribute (default is true)", v => generateDescriptionAttribute = v != null }, + { "cc|complexTypesForCollections", "generate complex types for collections (default is true)", v => generateComplexTypesForCollections = v != null }, }; var files = options.Parse(args); @@ -132,7 +134,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l DisableComments = disableComments, GenerateDescriptionAttribute = generateDescriptionAttribute, PrivateMemberPrefix = doNotUseUnderscoreInPrivateMemberNames ? "" : "_", - EnableUpaCheck = enableUpaCheck + EnableUpaCheck = enableUpaCheck, + GenerateComplexTypesForCollections = generateComplexTypesForCollections }; if (pclCompatible) diff --git a/XmlSchemaClassGenerator.Tests/Compiler.cs b/XmlSchemaClassGenerator.Tests/Compiler.cs index f6a468e0..6a3b134e 100644 --- a/XmlSchemaClassGenerator.Tests/Compiler.cs +++ b/XmlSchemaClassGenerator.Tests/Compiler.cs @@ -83,6 +83,7 @@ public static Assembly GenerateFiles(string name, IEnumerable files, Gen GenerateInterfaces = true, NamespacePrefix = name, GenerateDescriptionAttribute = true, + TextValuePropertyName = "Value" }; var output = new FileWatcherOutputWriter(Path.Combine("output", name)); @@ -100,7 +101,8 @@ public static Assembly GenerateFiles(string name, IEnumerable files, Gen GenerateInterfaces = generatorPrototype.GenerateInterfaces, MemberVisitor = generatorPrototype.MemberVisitor, GenerateDescriptionAttribute = generatorPrototype.GenerateDescriptionAttribute, - CodeTypeReferenceOptions = generatorPrototype.CodeTypeReferenceOptions + CodeTypeReferenceOptions = generatorPrototype.CodeTypeReferenceOptions, + TextValuePropertyName = generatorPrototype.TextValuePropertyName }; gen.Generate(files); diff --git a/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj b/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj index 155cf683..c825a966 100644 --- a/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj +++ b/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj @@ -449,6 +449,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/XmlSchemaClassGenerator.Tests/XmlTests.cs b/XmlSchemaClassGenerator.Tests/XmlTests.cs index 60e26b35..02d7e156 100644 --- a/XmlSchemaClassGenerator.Tests/XmlTests.cs +++ b/XmlSchemaClassGenerator.Tests/XmlTests.cs @@ -75,6 +75,7 @@ private IEnumerable ConvertXml(string name, string xsd, Generator genera const string IataPattern = @"xsd\iata\*.xsd"; const string TimePattern = @"xsd\time\time.xsd"; const string TableauPattern = @"xsd\ts-api\*.xsd"; + const string VSTstPattern = @"xsd\vstst\vstst.xsd"; // IATA test takes too long to perform every time @@ -168,6 +169,18 @@ public void TestTableau() TestSamples("Tableau", TableauPattern); } + [Fact, TestPriority(1)] + [UseCulture("en-US")] + public void TestVSTst() + { + Compiler.Generate("VSTst", VSTstPattern, new Generator + { + TextValuePropertyName = "TextValue", + GenerateComplexTypesForCollections = true + }); + TestSamples("VSTst", VSTstPattern); + } + private void TestSamples(string name, string pattern) { var assembly = Compiler.GetAssembly(name); diff --git a/XmlSchemaClassGenerator.Tests/xsd/vstst/vstst.xsd b/XmlSchemaClassGenerator.Tests/xsd/vstst/vstst.xsd new file mode 100644 index 00000000..9eda995b --- /dev/null +++ b/XmlSchemaClassGenerator.Tests/xsd/vstst/vstst.xsd @@ -0,0 +1,3011 @@ + + + + + Shared between all test types. + + + + + Currituck subsystem something ... + + + + + + + + + Describes the test. This is shown in the properties window. + + + + + + + + + + + + + + + + + + At the moment only one owner is allowed, but in the future we might extend to multiple owner support. + + + + + + For example REDMOND\user1 + + + + + + + + + + + Files to deploy before executing this test. + + + + + + + + + + Categories applied to the test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + References to workitems (bugs, issues) related to this test on the team server. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Coded web test in TRX file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Declarative web test in TRX file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This is in addition to the timeout to distinguish between a failed command and a test that timed out. + + + + + + + + + If this element does not exist it's the same as if it was not enabled. + But if it's not enabled, we still allow the user to change the file location and persist the file location for later use. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TODO: leave up to NC: this type is a duplicate of LoadTestRunCOnfigurationType. The differentces are results of WebTestSuiteSerializer (upper case for attributes and enums are strings vs ints) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This one can be used by any other test type as they all can internally call another set of tests and produce results, which are later merged into this aggregation for unified presentation to the caller. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Only one instance is allowed but no check is done due to xsd limitations. + + + + + + + + + + + + + Only one instance is allowed but no check is done due to xsd limitations. + + + + + + + + + + + + + + + + New in Orcas + + + + + + + + + + Only one instance is allowed but no check is done due to xsd limitations. + + + + + Only one instance is allowed but no check is done due to xsd limitations. + Deprecated. Use WebTestRunConfiguration instead. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // Deprecated. Use UnitTest instead + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Only one instance is allowed but no check is done due to xsd limitations. + + + + + + + + + + + + + Only one instance is allowed but no check is done due to xsd limitations. + + + + + + + + + + + + + + + + New in Orcas + + + + + + + + + + Only one instance is allowed but no check is done due to xsd limitations. + + + + + Only one instance is allowed but no check is done due to xsd limitations. + Deprecated. Use WebTestRunConfiguration instead. + + + + + Only one instance is allowed but no check is done due to xsd limitations. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/XmlSchemaClassGenerator/GeneratorConfiguration.cs b/XmlSchemaClassGenerator/GeneratorConfiguration.cs index e5d005d4..cbdbc44e 100644 --- a/XmlSchemaClassGenerator/GeneratorConfiguration.cs +++ b/XmlSchemaClassGenerator/GeneratorConfiguration.cs @@ -226,6 +226,6 @@ public void WriteLog(string message) /// public class componentType {} /// /// - public bool GenerateComplexTypesForCollections { get; set; } = false; + public bool GenerateComplexTypesForCollections { get; set; } = true; } }