Skip to content

Commit

Permalink
Unit tests fixed after code review
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkfinger authored and aloneguid committed Feb 20, 2023
1 parent d254e67 commit ed7f1c0
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions src/Parquet.Test/Serialisation/SchemaReflectorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public void I_ignore_inherited_properties() {
public void I_can_recognize_inherited_properties() {
ParquetSchema schema = SchemaReflector.ReflectWithInheritedProperties<PocoSubClass>();
Assert.Equal(5, schema.Fields.Count);
VerifyPocoClassFields(schema);
VerifyPocoSubClassField((DataField)schema[4]);
VerifyPocoClassWithInheritedFields(schema);
VerifyPocoSubClassField((DataField)schema[0]);
}

[Fact]
Expand All @@ -39,7 +39,7 @@ public void Reflecting_with_inherited_properties_after_default_does_not_cause_ca
Assert.Equal(1, defaultSchema.Fields.Count);
Assert.Equal(5, schemaWithInheritedProps.Fields.Count);
VerifyPocoSubClassField((DataField)defaultSchema[0]);
VerifyPocoClassFields(schemaWithInheritedProps);
VerifyPocoClassWithInheritedFields(schemaWithInheritedProps);
}

[Fact]
Expand All @@ -50,7 +50,7 @@ public void Reflecting_with_inherited_properties_before_default_does_not_cause_c
Assert.Equal(1, defaultSchema.Fields.Count);
Assert.Equal(5, schemaWithInheritedProps.Fields.Count);
VerifyPocoSubClassField((DataField)defaultSchema[0]);
VerifyPocoClassFields(schemaWithInheritedProps);
VerifyPocoClassWithInheritedFields(schemaWithInheritedProps);
}

private static void VerifyPocoClassFields(ParquetSchema schema) {
Expand Down Expand Up @@ -79,6 +79,38 @@ private static void VerifyPocoClassFields(ParquetSchema schema) {
Assert.True(intArray.IsArray);
}

private static void VerifyPocoClassWithInheritedFields(ParquetSchema schema) {
DataField extraProperty = (DataField)schema[0];
Assert.Equal("ExtraProperty", extraProperty.Name);
Assert.Equal(typeof(int), extraProperty.ClrType);
Assert.False(extraProperty.IsNullable);
Assert.False(extraProperty.IsArray);

DataField id = (DataField)schema[1];
Assert.Equal("Id", id.Name);
Assert.Equal(typeof(int), id.ClrType);
Assert.False(id.IsNullable);
Assert.False(id.IsArray);

DataField altId = (DataField)schema[2];
Assert.Equal("AltId", altId.Name);
Assert.Equal(typeof(int), id.ClrType);
Assert.False(id.IsNullable);
Assert.False(id.IsArray);

DataField nullableFloat = (DataField)schema[3];
Assert.Equal("NullableFloat", nullableFloat.Name);
Assert.Equal(typeof(float), nullableFloat.ClrType);
Assert.True(nullableFloat.IsNullable);
Assert.False(nullableFloat.IsArray);

DataField intArray = (DataField)schema[4];
Assert.Equal("IntArray", intArray.Name);
Assert.Equal(typeof(int), intArray.ClrType);
Assert.False(intArray.IsNullable);
Assert.True(intArray.IsArray);
}

private static void VerifyPocoSubClassField(DataField extraProp) {
Assert.Equal("ExtraProperty", extraProp.Name);
Assert.Equal(typeof(int), extraProp.ClrType);
Expand Down

0 comments on commit ed7f1c0

Please sign in to comment.