diff --git a/lang/csharp/src/apache/test/AvroGen/AvroGenHelper.cs b/lang/csharp/src/apache/test/AvroGen/AvroGenHelper.cs index 1d265af7ce2..49865c17052 100644 --- a/lang/csharp/src/apache/test/AvroGen/AvroGenHelper.cs +++ b/lang/csharp/src/apache/test/AvroGen/AvroGenHelper.cs @@ -25,6 +25,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Emit; using NUnit.Framework; +using Avro.Specific; namespace Avro.Test.AvroGen { @@ -112,17 +113,18 @@ public static Assembly CompileCSharpFilesIntoLibrary(IEnumerable sourceF // Compile EmitResult compilationResult = compilation.Emit(compilerStream); - //Note: Comment the following out to analyze the compiler errors if needed - //if (!compilationResult.Success) - //{ - // foreach (Diagnostic diagnostic in compilationResult.Diagnostics) - // { - // if (diagnostic.IsWarningAsError || diagnostic.Severity == DiagnosticSeverity.Error) - // { - // TestContext.WriteLine($"{diagnostic.Id} - {diagnostic.GetMessage()} - {diagnostic.Location}"); - // } - // } - //} +#if DEBUG + if (!compilationResult.Success) + { + foreach (Diagnostic diagnostic in compilationResult.Diagnostics) + { + if (diagnostic.IsWarningAsError || diagnostic.Severity == DiagnosticSeverity.Error) + { + TestContext.WriteLine($"{diagnostic.Id} - {diagnostic.GetMessage()} - {diagnostic.Location}"); + } + } + } +#endif Assert.That(compilationResult.Success, Is.True); @@ -131,6 +133,7 @@ public static Assembly CompileCSharpFilesIntoLibrary(IEnumerable sourceF return null; } + // Load assembly from stream compilerStream.Seek(0, SeekOrigin.Begin); return Assembly.Load(compilerStream.ToArray()); } @@ -152,5 +155,131 @@ public static string CreateEmptyTemporyFolder(out string uniqueId, string path = return tempFolder; } + + public static Assembly CompileCSharpFilesAndCheckTypes( + string outputDir, + string assemblyName, + IEnumerable typeNamesToCheck = null, + IEnumerable generatedFilesToCheck = null) + { + // Check if all generated files exist + if (generatedFilesToCheck != null) + { + foreach (string generatedFile in generatedFilesToCheck) + { + Assert.That(new FileInfo(Path.Combine(outputDir, generatedFile)), Does.Exist); + } + } + + // Compile into netstandard library and load assembly + Assembly assembly = CompileCSharpFilesIntoLibrary( + new DirectoryInfo(outputDir) + .EnumerateFiles("*.cs", SearchOption.AllDirectories) + .Select(fi => fi.FullName), + assemblyName); + + if (typeNamesToCheck != null) + { + // Check if the compiled code has the same number of types defined as the check list + Assert.That(typeNamesToCheck.Count(), Is.EqualTo(assembly.DefinedTypes.Count())); + + // Check if types available in compiled assembly + foreach (string typeName in typeNamesToCheck) + { + Type type = assembly.GetType(typeName); + Assert.That(type, Is.Not.Null); + + // Protocols are abstract and cannot be instantiated + if (typeof(ISpecificProtocol).IsAssignableFrom(type)) + { + Assert.That(type.IsAbstract, Is.True); + + // If directly inherited from ISpecificProtocol, use reflection to read static private field + // holding the protocol. Callback objects are not directly inherited from ISpecificProtocol, + // so private fields in the base class cannot be accessed + if (type.BaseType.Equals(typeof(ISpecificProtocol))) + { + // Use reflection to read static field, holding the protocol + FieldInfo protocolField = type.GetField("protocol", BindingFlags.NonPublic | BindingFlags.Static); + Protocol protocol = protocolField.GetValue(null) as Protocol; + + Assert.That(protocol, Is.Not.Null); + } + } + else + { + Assert.That(type.IsClass || type.IsEnum, Is.True); + + // Instantiate object + object obj = Activator.CreateInstance(type); + Assert.That(obj, Is.Not.Null); + + // If ISpecificRecord, call its member for sanity check + if (obj is ISpecificRecord record) + { + // Read record's schema object + Assert.That(record.Schema, Is.Not.Null); + // Force exception by reading/writing invalid field + Assert.Throws(() => record.Get(-1)); + Assert.Throws(() => record.Put(-1, null)); + } + } + } + } + + return assembly; + } + + public static Assembly TestSchema( + string schema, + IEnumerable typeNamesToCheck = null, + IEnumerable> namespaceMapping = null, + IEnumerable generatedFilesToCheck = null) + { + // Create temp folder + string outputDir = CreateEmptyTemporyFolder(out string uniqueId); + + try + { + // Save schema + string schemaFileName = Path.Combine(outputDir, $"{uniqueId}.avsc"); + System.IO.File.WriteAllText(schemaFileName, schema); + + // Generate from schema file + Assert.That(AvroGenTool.GenSchema(schemaFileName, outputDir, namespaceMapping ?? new Dictionary()), Is.EqualTo(0)); + + return CompileCSharpFilesAndCheckTypes(outputDir, uniqueId, typeNamesToCheck, generatedFilesToCheck); + } + finally + { + Directory.Delete(outputDir, true); + } + } + + public static Assembly TestProtocol( + string protocol, + IEnumerable typeNamesToCheck = null, + IEnumerable> namespaceMapping = null, + IEnumerable generatedFilesToCheck = null) + { + // Create temp folder + string outputDir = CreateEmptyTemporyFolder(out string uniqueId); + + try + { + // Save protocol + string schemaFileName = Path.Combine(outputDir, $"{uniqueId}.avpr"); + System.IO.File.WriteAllText(schemaFileName, protocol); + + // Generate from protocol file + Assert.That(AvroGenTool.GenProtocol(schemaFileName, outputDir, namespaceMapping ?? new Dictionary()), Is.EqualTo(0)); + + return CompileCSharpFilesAndCheckTypes(outputDir, uniqueId, typeNamesToCheck, generatedFilesToCheck); + } + finally + { + Directory.Delete(outputDir, true); + } + } } } diff --git a/lang/csharp/src/apache/test/AvroGen/AvroGenProtocolTests.cs b/lang/csharp/src/apache/test/AvroGen/AvroGenProtocolTests.cs new file mode 100644 index 00000000000..b408650369f --- /dev/null +++ b/lang/csharp/src/apache/test/AvroGen/AvroGenProtocolTests.cs @@ -0,0 +1,517 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System.Collections.Generic; +using NUnit.Framework; + +namespace Avro.Test.AvroGen +{ + [TestFixture] + + class AvroGenProtocolTests + { + private const string _baseball = @" +{ + ""protocol"" : ""Baseball"", + ""namespace"" : ""avro.examples.baseball"", + ""doc"" : ""Licensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements. See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership. The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\""License\""); you may not use this file except in compliance\nwith the License. You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \""AS IS\"" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."", + ""types"" : [ { + ""type"" : ""enum"", + ""name"" : ""Position"", + ""symbols"" : [ ""P"", ""C"", ""B1"", ""B2"", ""B3"", ""SS"", ""LF"", ""CF"", ""RF"", ""DH"" ] + }, { + ""type"" : ""record"", + ""name"" : ""Player"", + ""fields"" : [ { + ""name"" : ""number"", + ""type"" : ""int"" + }, { + ""name"" : ""first_name"", + ""type"" : ""string"" + }, { + ""name"" : ""last_name"", + ""type"" : ""string"" + }, { + ""name"" : ""position"", + ""type"" : { + ""type"" : ""array"", + ""items"" : ""Position"" + } + } ] + } ], + ""messages"" : { + } +} +"; + private const string _comments = @" +{ + ""protocol"" : ""Comments"", + ""namespace"" : ""testing"", + ""types"" : [ { + ""type"" : ""enum"", + ""name"" : ""DocumentedEnum"", + ""doc"" : ""Documented Enum"", + ""symbols"" : [ ""A"", ""B"", ""C"" ], + ""default"" : ""A"" + }, { + ""type"" : ""enum"", + ""name"" : ""UndocumentedEnum"", + ""symbols"" : [ ""D"", ""E"" ] + }, { + ""type"" : ""fixed"", + ""name"" : ""DocumentedFixed"", + ""doc"" : ""Documented Fixed Type"", + ""size"" : 16 + }, { + ""type"" : ""fixed"", + ""name"" : ""UndocumentedFixed"", + ""size"" : 16 + }, { + ""type"" : ""error"", + ""name"" : ""DocumentedError"", + ""doc"" : ""Documented Error"", + ""fields"" : [ { + ""name"" : ""reason"", + ""type"" : ""string"", + ""doc"" : ""Documented Reason Field"" + }, { + ""name"" : ""explanation"", + ""type"" : ""string"", + ""doc"" : ""Default Doc Explanation Field"" + } ] + }, { + ""type"" : ""record"", + ""name"" : ""UndocumentedRecord"", + ""fields"" : [ { + ""name"" : ""description"", + ""type"" : ""string"" + } ] + } ], + ""messages"" : { + ""documentedMethod"" : { + ""doc"" : ""Documented Method"", + ""request"" : [ { + ""name"" : ""message"", + ""type"" : ""string"", + ""doc"" : ""Documented Parameter"" + }, { + ""name"" : ""defMsg"", + ""type"" : ""string"", + ""doc"" : ""Default Documented Parameter"" + } ], + ""response"" : ""null"", + ""errors"" : [ ""DocumentedError"" ] + }, + ""undocumentedMethod"" : { + ""request"" : [ { + ""name"" : ""message"", + ""type"" : ""string"" + } ], + ""response"" : ""null"" + } + } +} +"; + + private const string _interop = @" +{ + ""protocol"" : ""InteropProtocol"", + ""namespace"" : ""org.apache.avro.interop"", + ""doc"" : ""Licensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements. See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership. The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\""License\""); you may not use this file except in compliance\nwith the License. You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \""AS IS\"" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."", + ""types"" : [ { + ""type"" : ""record"", + ""name"" : ""Label"", + ""fields"" : [ { + ""name"" : ""label"", + ""type"" : ""string"" + } ] + }, { + ""type"" : ""enum"", + ""name"" : ""Kind"", + ""symbols"" : [ ""A"", ""B"", ""C"" ] + }, { + ""type"" : ""fixed"", + ""name"" : ""MD5"", + ""size"" : 16 + }, { + ""type"" : ""record"", + ""name"" : ""Node"", + ""fields"" : [ { + ""name"" : ""label"", + ""type"" : ""string"" + }, { + ""name"" : ""children"", + ""type"" : { + ""type"" : ""array"", + ""items"" : ""Node"" + }, + ""default"" : [ ] + } ] + }, { + ""type"" : ""record"", + ""name"" : ""Interop"", + ""fields"" : [ { + ""name"" : ""intField"", + ""type"" : ""int"", + ""default"" : 1 + }, { + ""name"" : ""longField"", + ""type"" : ""long"", + ""default"" : -1 + }, { + ""name"" : ""stringField"", + ""type"" : ""string"" + }, { + ""name"" : ""boolField"", + ""type"" : ""boolean"", + ""default"" : false + }, { + ""name"" : ""floatField"", + ""type"" : ""float"", + ""default"" : 0.0 + }, { + ""name"" : ""doubleField"", + ""type"" : ""double"", + ""default"" : -1.0E12 + }, { + ""name"" : ""nullField"", + ""type"" : ""null"" + }, { + ""name"" : ""arrayField"", + ""type"" : { + ""type"" : ""array"", + ""items"" : ""double"" + }, + ""default"" : [ ] + }, { + ""name"" : ""mapField"", + ""type"" : { + ""type"" : ""map"", + ""values"" : ""Label"" + } + }, { + ""name"" : ""unionField"", + ""type"" : [ ""boolean"", ""double"", { + ""type"" : ""array"", + ""items"" : ""bytes"" + } ] + }, { + ""name"" : ""enumField"", + ""type"" : ""Kind"" + }, { + ""name"" : ""fixedField"", + ""type"" : ""MD5"" + }, { + ""name"" : ""recordField"", + ""type"" : ""Node"" + } ] + } ], + ""messages"" : { } +} +"; + private const string _namespaces = @" +{ + ""protocol"" : ""TestNamespace"", + ""namespace"" : ""avro.test.protocol"", + ""doc"" : ""Licensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements. See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership. The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\""License\""); you may not use this file except in compliance\nwith the License. You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \""AS IS\"" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License."", + ""types"" : [ { + ""type"" : ""fixed"", + ""name"" : ""FixedInOtherNamespace"", + ""namespace"" : ""avro.test.fixed"", + ""size"" : 16 + }, { + ""type"" : ""fixed"", + ""name"" : ""FixedInThisNamespace"", + ""size"" : 16 + }, { + ""type"" : ""record"", + ""name"" : ""RecordInOtherNamespace"", + ""namespace"" : ""avro.test.record"", + ""fields"" : [ ] + }, { + ""type"" : ""error"", + ""name"" : ""ErrorInOtherNamespace"", + ""namespace"" : ""avro.test.error"", + ""fields"" : [ ] + }, { + ""type"" : ""enum"", + ""name"" : ""EnumInOtherNamespace"", + ""namespace"" : ""avro.test.enum"", + ""symbols"" : [ ""FOO"" ] + }, { + ""type"" : ""record"", + ""name"" : ""RefersToOthers"", + ""fields"" : [ { + ""name"" : ""someFixed"", + ""type"" : ""avro.test.fixed.FixedInOtherNamespace"" + }, { + ""name"" : ""someRecord"", + ""type"" : ""avro.test.record.RecordInOtherNamespace"" + }, { + ""name"" : ""someError"", + ""type"" : ""avro.test.error.ErrorInOtherNamespace"" + }, { + ""name"" : ""someEnum"", + ""type"" : ""avro.test.enum.EnumInOtherNamespace"" + }, { + ""name"" : ""thisFixed"", + ""type"" : ""FixedInThisNamespace"" + } ] + } ], + ""messages"" : { + } +} +"; + private const string _forwardRef = @" +{ + ""protocol"": ""Import"", + ""namespace"": ""org.foo"", + ""types"": [ + { + ""type"": ""record"", + ""name"": ""ANameValue"", + ""fields"": [ + { ""name"":""name"", ""type"": ""string"", ""doc"":""the name"" }, + { ""name"": ""value"", ""type"": ""string"", ""doc"": ""the value"" }, + { ""name"": ""type"", ""type"": { ""type"": ""enum"", ""name"":""ValueType"", ""symbols"": [""JSON"",""BASE64BIN"",""PLAIN""] }, ""default"": ""PLAIN"" } + ] + } + ], + ""messages"": { } +} +"; + private const string _unicode = @" +{ + ""protocol"" : ""Протоколы"", + ""namespace"" : ""org.avro.test"", + ""doc"" : ""This is a test that UTF8 functions correctly.\nこのテストでは、UTF - 8で正しく機能している。\n这是一个测试,UTF - 8的正常运行。"", + ""types"" : [ { + ""type"" : ""record"", + ""name"" : ""Структура"", + ""fields"" : [ { + ""name"" : ""Строковый"", + ""type"" : ""string"" + }, { + ""name"" : ""文字列"", + ""type"" : ""string"" + } ] + } ], + ""messages"" : { + } +} +"; + + private const string _myProtocol = @" +{ + ""protocol"" : ""MyProtocol"", + ""namespace"" : ""com.foo"", + ""types"" : [ + { + ""type"" : ""record"", + ""name"" : ""A"", + ""fields"" : [ { ""name"" : ""f1"", ""type"" : ""long"" } ] + }, + { + ""type"" : ""enum"", + ""name"" : ""MyEnum"", + ""symbols"" : [ ""A"", ""B"", ""C"" ] + }, + { + ""type"": ""fixed"", + ""size"": 16, + ""name"": ""MyFixed"" + }, + { + ""type"" : ""record"", + ""name"" : ""Z"", + ""fields"" : + [ + { ""name"" : ""myUInt"", ""type"" : [ ""int"", ""null"" ] }, + { ""name"" : ""myULong"", ""type"" : [ ""long"", ""null"" ] }, + { ""name"" : ""myUBool"", ""type"" : [ ""boolean"", ""null"" ] }, + { ""name"" : ""myUDouble"", ""type"" : [ ""double"", ""null"" ] }, + { ""name"" : ""myUFloat"", ""type"" : [ ""float"", ""null"" ] }, + { ""name"" : ""myUBytes"", ""type"" : [ ""bytes"", ""null"" ] }, + { ""name"" : ""myUString"", ""type"" : [ ""string"", ""null"" ] }, + + { ""name"" : ""myInt"", ""type"" : ""int"" }, + { ""name"" : ""myLong"", ""type"" : ""long"" }, + { ""name"" : ""myBool"", ""type"" : ""boolean"" }, + { ""name"" : ""myDouble"", ""type"" : ""double"" }, + { ""name"" : ""myFloat"", ""type"" : ""float"" }, + { ""name"" : ""myBytes"", ""type"" : ""bytes"" }, + { ""name"" : ""myString"", ""type"" : ""string"" }, + { ""name"" : ""myNull"", ""type"" : ""null"" }, + + { ""name"" : ""myFixed"", ""type"" : ""MyFixed"" }, + { ""name"" : ""myA"", ""type"" : ""A"" }, + { ""name"" : ""myE"", ""type"" : ""MyEnum"" }, + { ""name"" : ""myArray"", ""type"" : { ""type"" : ""array"", ""items"" : ""bytes"" } }, + { ""name"" : ""myArray2"", ""type"" : { ""type"" : ""array"", ""items"" : { ""type"" : ""record"", ""name"" : ""newRec"", ""fields"" : [ { ""name"" : ""f1"", ""type"" : ""long""} ] } } }, + { ""name"" : ""myMap"", ""type"" : { ""type"" : ""map"", ""values"" : ""string"" } }, + { ""name"" : ""myMap2"", ""type"" : { ""type"" : ""map"", ""values"" : ""newRec"" } }, + { ""name"" : ""myObject"", ""type"" : [ ""MyEnum"", ""A"", ""null"" ] }, + { ""name"" : ""myArray3"", ""type"" : { ""type"" : ""array"", ""items"" : { ""type"" : ""array"", ""items"" : [ ""double"", ""string"", ""null"" ] } } } + ] + } + ] +}"; + + [TestCase( + _baseball, + new string[] + { + "avro.examples.baseball.Baseball", + "avro.examples.baseball.BaseballCallback", + "avro.examples.baseball.Player", + "avro.examples.baseball.Position" + }, + new string[] + { + "avro/examples/baseball/Baseball.cs", + "avro/examples/baseball/BaseballCallback.cs", + "avro/examples/baseball/Player.cs", + "avro/examples/baseball/Position.cs" + })] + [TestCase( + _comments, + new string[] + { + "testing.Comments", + "testing.CommentsCallback", + "testing.DocumentedEnum", + "testing.DocumentedError", + "testing.DocumentedFixed", + "testing.UndocumentedEnum", + "testing.UndocumentedFixed", + "testing.UndocumentedRecord" + }, + new string[] + { + "testing/Comments.cs", + "testing/CommentsCallback.cs", + "testing/DocumentedEnum.cs", + "testing/DocumentedError.cs", + "testing/DocumentedFixed.cs", + "testing/UndocumentedEnum.cs", + "testing/UndocumentedFixed.cs", + "testing/UndocumentedRecord.cs" + })] + [TestCase( + _interop, + new string[] + { + "org.apache.avro.interop.Label", + "org.apache.avro.interop.Interop", + "org.apache.avro.interop.InteropProtocol", + "org.apache.avro.interop.InteropProtocolCallback", + "org.apache.avro.interop.Kind", + "org.apache.avro.interop.MD5", + "org.apache.avro.interop.Node", + }, + new string[] + { + "org/apache/avro/interop/Label.cs", + "org/apache/avro/interop/Interop.cs", + "org/apache/avro/interop/InteropProtocol.cs", + "org/apache/avro/interop/InteropProtocolCallback.cs", + "org/apache/avro/interop/Kind.cs", + "org/apache/avro/interop/MD5.cs", + "org/apache/avro/interop/Node.cs", + })] + [TestCase( + _namespaces, + new string[] + { + "avro.test.enum.EnumInOtherNamespace", + "avro.test.error.ErrorInOtherNamespace", + "avro.test.fixed.FixedInOtherNamespace", + "avro.test.protocol.FixedInThisNamespace", + "avro.test.protocol.RefersToOthers", + "avro.test.protocol.TestNamespace", + "avro.test.protocol.TestNamespaceCallback", + "avro.test.record.RecordInOtherNamespace" + }, + new string[] + { + "avro/test/enum/EnumInOtherNamespace.cs", + "avro/test/error/ErrorInOtherNamespace.cs", + "avro/test/fixed/FixedInOtherNamespace.cs", + "avro/test/protocol/FixedInThisNamespace.cs", + "avro/test/protocol/RefersToOthers.cs", + "avro/test/protocol/TestNamespace.cs", + "avro/test/protocol/TestNamespaceCallback.cs", + "avro/test/record/RecordInOtherNamespace.cs" + })] + [TestCase( + _forwardRef, + new string[] + { + "org.foo.ANameValue", + "org.foo.Import", + "org.foo.ImportCallback", + "org.foo.ValueType" + }, + new string[] + { + "org/foo/ANameValue.cs", + "org/foo/Import.cs", + "org/foo/ImportCallback.cs", + "org/foo/ValueType.cs" + })] + [TestCase( + _unicode, + new string[] + { + "org.avro.test.Протоколы", + "org.avro.test.ПротоколыCallback", + "org.avro.test.Структура" + }, + new string[] + { + "org/avro/test/Протоколы.cs", + "org/avro/test/ПротоколыCallback.cs", + "org/avro/test/Структура.cs" + })] + [TestCase( + _myProtocol, + new string[] + { + "com.foo.A", + "com.foo.MyEnum", + "com.foo.MyFixed", + "com.foo.MyProtocol", + "com.foo.MyProtocolCallback", + "com.foo.newRec", + "com.foo.Z" + }, + new string[] + { + "com/foo/A.cs", + "com/foo/MyEnum.cs", + "com/foo/MyFixed.cs", + "com/foo/MyProtocol.cs", + "com/foo/MyProtocolCallback.cs", + "com/foo/newRec.cs", + "com/foo/Z.cs" + })] + public void GenerateProtocol(string protocol, IEnumerable typeNamesToCheck, IEnumerable generatedFilesToCheck) + { + AvroGenHelper.TestProtocol(protocol, typeNamesToCheck, generatedFilesToCheck: generatedFilesToCheck); + } + } +} diff --git a/lang/csharp/src/apache/test/AvroGen/AvroGenTests.cs b/lang/csharp/src/apache/test/AvroGen/AvroGenSchemaTests.cs similarity index 98% rename from lang/csharp/src/apache/test/AvroGen/AvroGenTests.cs rename to lang/csharp/src/apache/test/AvroGen/AvroGenSchemaTests.cs index 1f61fc547dc..912284d6052 100644 --- a/lang/csharp/src/apache/test/AvroGen/AvroGenTests.cs +++ b/lang/csharp/src/apache/test/AvroGen/AvroGenSchemaTests.cs @@ -28,7 +28,7 @@ namespace Avro.Test.AvroGen { [TestFixture] - class AvroGenTests + class AvroGenSchemaTests { private const string _customConversionWithLogicalTypes = @" { @@ -489,7 +489,7 @@ private Assembly TestSchema( })] public void GenerateSchema(string schema, IEnumerable typeNamesToCheck, IEnumerable generatedFilesToCheck) { - TestSchema(schema, typeNamesToCheck, generatedFilesToCheck: generatedFilesToCheck); + AvroGenHelper.TestSchema(schema, typeNamesToCheck, generatedFilesToCheck: generatedFilesToCheck); } [TestCase( @@ -603,7 +603,7 @@ public void GenerateSchemaWithNamespaceMapping( IEnumerable typeNamesToCheck, IEnumerable generatedFilesToCheck) { - TestSchema(schema, typeNamesToCheck, new Dictionary { { namespaceMappingFrom, namespaceMappingTo } }, generatedFilesToCheck); + AvroGenHelper.TestSchema(schema, typeNamesToCheck, new Dictionary { { namespaceMappingFrom, namespaceMappingTo } }, generatedFilesToCheck); } [TestCase(_logicalTypesWithCustomConversion, typeof(AvroTypeException))] @@ -729,7 +729,7 @@ public void NotSupportedSchema(string schema, Type expectedException) new object[] { "enum.base.EnumInDifferentNamespace", "enum.base.other.AnEnum" })] public void GenerateSchemaCheckFields(string schema, object[] result) { - Assembly assembly = TestSchema(schema); + Assembly assembly = AvroGenHelper.TestSchema(schema); // Instantiate object Type type = assembly.GetType((string)result[0]);