Skip to content

Commit

Permalink
Added Serialization deserialization unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrinal Thomas authored and Mrinal Thomas committed Oct 19, 2023
1 parent 5ea0954 commit 95a2734
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/Parquet.Test/Serialisation/ParquetSerializerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Parquet.Data;
using Parquet.File.Values.Primitives;
Expand Down Expand Up @@ -172,6 +173,7 @@ class Address {
}

class AddressBookEntry {

public string? FirstName { get; set; }

public string? LastName { get; set; }
Expand Down Expand Up @@ -557,5 +559,40 @@ public async Task Deserialize_required_strings() {

Assert.Equivalent(expected, actual);
}

class AddressBookEntryAlias {

public string? Name { get; set; }

[JsonPropertyName("Address")]
public Address? _address { get; set; }

[JsonPropertyName("PhoneNumbers")]
public List<string>? _phoneNumbers { get; set; }
}

[Fact]
public async Task List_Struct_WithAlias_Serde() {

var data = Enumerable.Range(0, 1_000).Select(i => new AddressBookEntryAlias {
Name = "Joe",
_address = new Address() {
Country = "UK",
City = "Unknown",
},
_phoneNumbers = new List<string>() {
"123-456-7890",
"111-222-3333"
}
}).ToList();

using var ms = new MemoryStream();
await ParquetSerializer.SerializeAsync(data, ms);

ms.Position = 0;
IList<AddressBookEntryAlias> data2 = await ParquetSerializer.DeserializeAsync<AddressBookEntryAlias>(ms);

Assert.Equivalent(data2, data);
}
}
}

0 comments on commit 95a2734

Please sign in to comment.