[
https://issues.apache.org/jira/browse/AVRO-2211?focusedWorklogId=751992&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-751992
]
ASF GitHub Bot logged work on AVRO-2211:
----------------------------------------
Author: ASF GitHub Bot
Created on: 02/Apr/22 21:07
Start Date: 02/Apr/22 21:07
Worklog Time Spent: 10m
Work Description: 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]
Issue Time Tracking
-------------------
Worklog Id: (was: 751992)
Time Spent: 4h (was: 3h 50m)
> SchemaBuilder equivalent or other means of schema creation
> ----------------------------------------------------------
>
> Key: AVRO-2211
> URL: https://issues.apache.org/jira/browse/AVRO-2211
> Project: Apache Avro
> Issue Type: Wish
> Components: csharp
> Reporter: Dan Stelljes
> Priority: Major
> Labels: pull-request-available
> Time Spent: 4h
> Remaining Estimate: 0h
>
> Currently, the only way to create a schema is via the Schema.Parse method.
> We'd like to be able to build a schema programmatically—would it be possible
> to (1) introduce an analogue to the SchemaBuilder from the Java library or
> (2) expose constructors on Schema and its descendants?
> Would be more than happy to contribute work on this given some direction.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)