yanivru commented on a change in pull request #1597:
URL: https://github.com/apache/avro/pull/1597#discussion_r841119445
##########
File path: lang/csharp/src/apache/test/Schema/SchemaTests.cs
##########
@@ -335,6 +455,34 @@ public void TestEnumDefaultSymbolDoesntExist(string s)
Assert.Throws<SchemaParseException>(() => Schema.Parse(s));
}
+ [TestCase("name", new string[] { "A", "B" }, "s", new[] { "L1", "L2"
}, "regular enum", null, "name", "s")]
+ [TestCase("s.name", new string[] { "A", "B" }, null, new[] { "L1",
"L2" }, "internal namespace", null, "name", "s")]
+ [TestCase("name", new string[] { "A", "B" }, null, new[] { "L1", "L2"
}, "no namespace", null, "name", null)]
+ [TestCase("name", new string[] { "A", "B" }, null, new[] { "L1", "L2"
}, "with default value", "A", "name", null)]
+ public void TestEnumCreation(string name, string[] symbols, string
space, string[] aliases, string doc, string defaultSymbol, string expectedName,
string expectedNamespace)
+ {
+ EnumSchema enumSchema = EnumSchema.Create(name, symbols, space,
aliases, null, doc, defaultSymbol);
+
+ Assert.AreEqual(expectedName, enumSchema.Name);
+ CollectionAssert.AreEqual(symbols, enumSchema.Symbols);
+ Assert.AreEqual(expectedNamespace, enumSchema.Namespace);
+ Assert.AreEqual(Schema.Type.Enumeration, enumSchema.Tag);
+ Assert.AreEqual(doc, enumSchema.Documentation);
+ Assert.AreEqual(defaultSymbol, enumSchema.Default);
+ }
+
+ [TestCase(new object[] { "A", "A" })]
+ public void TestEnumCreationDuplicateSymbols(params string[] symbols)
+ {
+ Assert.Throws<AvroException>(() => EnumSchema.Create("Name",
symbols));
+ }
+
+ [TestCase]
+ public void TestEnumCreationDefaultSymbolDoesntExists()
+ {
+ Assert.Throws<AvroException>(() => EnumSchema.Create("name", new[]
{ "A", "B" }, defaultSymbol: "C"));
+ }
+
Review comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]