This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/branch-1.11 by this push:
     new 7bbbbc9  AVRO-3421 Added more test coverage to ArraySchema (#1569)
7bbbbc9 is described below

commit 7bbbbc975e3bd6ac8e9ab4faa86a9c49ee965b09
Author: Kyle Schoonover <[email protected]>
AuthorDate: Thu Mar 3 06:39:17 2022 -0800

    AVRO-3421 Added more test coverage to ArraySchema (#1569)
    
    * AVRO-3360 Updated XML documentation
    
    * Revert "AVRO-3360 Updated XML documentation"
    
    This reverts commit b8601c072a5083380d30b580804dd0908b8cf4cc.
    
    * AVRO-3421 Better code coverage for ArraySchema
    
    * Added Equals tests
    
    * Test fixes
    
    * revert ArraySchema
    
    * Revert spacing
    
    Co-authored-by: Kyle T. Schoonover <[email protected]>
    (cherry picked from commit e828cb0adc3c24e970f47c181d39ba21350d2ab5)
---
 .../src/apache/test/Schema/ArraySchemaTests.cs     | 55 ++++++++++++++++++++++
 lang/csharp/src/apache/test/Schema/SchemaTests.cs  |  1 +
 2 files changed, 56 insertions(+)

diff --git a/lang/csharp/src/apache/test/Schema/ArraySchemaTests.cs 
b/lang/csharp/src/apache/test/Schema/ArraySchemaTests.cs
new file mode 100644
index 0000000..7b8b7d3
--- /dev/null
+++ b/lang/csharp/src/apache/test/Schema/ArraySchemaTests.cs
@@ -0,0 +1,55 @@
+/*
+ * 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 NUnit.Framework;
+
+namespace Avro.test
+{
+    [TestFixture]
+    public class ArraySchemaTests
+    {
+        [Test]
+        public void EqualsNullCheck()
+        {
+            string schemaString = "{\"type\": \"array\", \"items\": \"long\"}";
+            ArraySchema nullSchema = null;
+
+            Schema schema = Schema.Parse(schemaString);
+
+            if (schema is ArraySchema arraySchema)
+            {
+                Assert.False(arraySchema.Equals(nullSchema));
+            }
+            else
+            {
+                Assert.Fail("Must be an array schema");
+            }
+        }
+
+        [Test]
+        public void EqualsNotArraySchema()
+        {
+            string schemaString = "[\"string\", \"null\", \"long\"]";
+            string arraySchemaString = "{\"type\": \"array\", \"items\": 
\"long\"}";
+            ArraySchema arraySchema = Schema.Parse(arraySchemaString) as 
ArraySchema;
+            Schema schema = Schema.Parse(schemaString);
+
+            Assert.False(arraySchema.Equals(schema));
+        }
+    }
+}
diff --git a/lang/csharp/src/apache/test/Schema/SchemaTests.cs 
b/lang/csharp/src/apache/test/Schema/SchemaTests.cs
index 44d66fe..59b4a90 100644
--- a/lang/csharp/src/apache/test/Schema/SchemaTests.cs
+++ b/lang/csharp/src/apache/test/Schema/SchemaTests.cs
@@ -89,6 +89,7 @@ namespace Avro.Test
         // Array
         [TestCase("{\"type\": \"array\", \"items\": \"long\"}")]
         [TestCase("{\"type\": \"array\",\"items\": {\"type\": \"enum\", 
\"name\": \"Test\", \"symbols\": [\"A\", \"B\"]}}")]
+        [TestCase("{\"type\": \"array\"}", typeof(AvroTypeException), 
Description = "No Items")]
 
         // Map
         [TestCase("{\"type\": \"map\", \"values\": \"long\"}")]

Reply via email to