Skip to content

Commit

Permalink
Add tests to cover repeated message scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
Havret committed Apr 4, 2022
1 parent 83fb42f commit 397b6c3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@
"enumList": [
2,
4
],
"nestedMessageList": [
{
"field": 4
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ public void Should_serialize_message_with_repeated_list()
{
Int32List = {1, 2, 3},
Int64List = {int.MaxValue + 1L, int.MaxValue + 2L, int.MaxValue + 3L},
EnumList = {Corpus.Images, Corpus.News}
EnumList = {Corpus.Images, Corpus.News},
NestedMessageList =
{
new NestedField
{
Field = 4
}
}
};

var jsonSerializerOptions = TestHelper.CreateJsonSerializerOptions();
Expand All @@ -38,7 +45,14 @@ public void Should_deserialize_message_with_repeated_list()
{
Int32List = {1, 2, 3},
Int64List = {int.MaxValue + 1L, int.MaxValue + 2L, int.MaxValue + 3L},
EnumList = {Corpus.Images, Corpus.News}
EnumList = {Corpus.Images, Corpus.News},
NestedMessageList =
{
new NestedField
{
Field = 4
}
}
};

var jsonSerializerOptions = TestHelper.CreateJsonSerializerOptions();
Expand All @@ -52,5 +66,7 @@ public void Should_deserialize_message_with_repeated_list()

deserialized.Int32List.ShouldBe(msg.Int32List);
deserialized.Int64List.ShouldBe(msg.Int64List);
deserialized.EnumList.ShouldBe(msg.EnumList);
deserialized.NestedMessageList.ShouldBe(msg.NestedMessageList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ message MessageWithRepeatedList {
repeated int64 int_64_list = 2;

repeated Corpus enum_list = 3;

repeated NestedField nested_message_list = 4;
}

enum Corpus {
Expand All @@ -18,4 +20,8 @@ enum Corpus {
NEWS = 4;
PRODUCTS = 5;
VIDEO = 6;
}

message NestedField {
int32 field = 1;
}

0 comments on commit 397b6c3

Please sign in to comment.