From 72446788b2290c96de962ca17083412975d0e158 Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Wed, 9 Feb 2022 16:48:23 +0000 Subject: [PATCH] Make bulk serialization tests less brittle --- .../Serialization/BulkSerialisationTests.cs | 49 +++++++++++++++++-- ...t_DescriptorSerialisationTest.verified.txt | 4 -- ...DescriptorSerialisationTest_1.verified.txt | 5 ++ ...DescriptorSerialisationTest_2.verified.txt | 15 ++++++ ...DescriptorSerialisationTest_3.verified.txt | 5 ++ ...DescriptorSerialisationTest_4.verified.txt | 15 ++++++ ...y_DescriptorSerialisationTest.verified.txt | 4 -- ...DescriptorSerialisationTest_1.verified.txt | 5 ++ ...DescriptorSerialisationTest_2.verified.txt | 15 ++++++ ...DescriptorSerialisationTest_3.verified.txt | 5 ++ ...DescriptorSerialisationTest_4.verified.txt | 15 ++++++ ...BulkRequest_SerialisationTest.verified.txt | 4 -- ...lkRequest_SerialisationTest_1.verified.txt | 5 ++ ...lkRequest_SerialisationTest_2.verified.txt | 15 ++++++ ...lkRequest_SerialisationTest_3.verified.txt | 5 ++ ...lkRequest_SerialisationTest_4.verified.txt | 15 ++++++ 16 files changed, 166 insertions(+), 15 deletions(-) delete mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_1.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_2.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_3.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_4.verified.txt delete mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_1.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_2.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_3.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_4.verified.txt delete mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_1.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_2.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_3.verified.txt create mode 100644 tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_4.verified.txt diff --git a/tests/Tests/Serialization/BulkSerialisationTests.cs b/tests/Tests/Serialization/BulkSerialisationTests.cs index 4e6c3572b01..0def0e2c760 100644 --- a/tests/Tests/Serialization/BulkSerialisationTests.cs +++ b/tests/Tests/Serialization/BulkSerialisationTests.cs @@ -2,6 +2,7 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. +using System.IO; using System.Threading.Tasks; using Tests.Core.Xunit; using Tests.Domain; @@ -28,7 +29,21 @@ public async Task BulkRequest_SerialisationTest() }; var serialisedJson = await SerializeAndGetJsonStringAsync(request); - await Verifier.Verify(serialisedJson); + + var sr = new StringReader(serialisedJson); + var count = 0; + while(true) + { + var line = sr.ReadLine(); + if (line is not null) + { + await Verifier.VerifyJson(line).UseMethodName($"{nameof(BulkRequest_SerialisationTest)}_{++count}"); + } + else + { + break; + } + } } [U] @@ -39,7 +54,21 @@ public async Task BulkRequest_DescriptorSerialisationTest() request.Index(FixedProject); var serialisedJson = await SerializeAndGetJsonStringAsync(request); - await Verifier.Verify(serialisedJson); + + var sr = new StringReader(serialisedJson); + var count = 0; + while (true) + { + var line = sr.ReadLine(); + if (line is not null) + { + await Verifier.VerifyJson(line).UseMethodName($"{nameof(BulkRequest_DescriptorSerialisationTest)}_{++count}"); + } + else + { + break; + } + } } [U] @@ -49,7 +78,21 @@ public async Task BulkRequest_IndexMany_DescriptorSerialisationTest() request.IndexMany(new [] { FixedProject, FixedProject }); var serialisedJson = await SerializeAndGetJsonStringAsync(request); - await Verifier.Verify(serialisedJson); + + var sr = new StringReader(serialisedJson); + var count = 0; + while (true) + { + var line = sr.ReadLine(); + if (line is not null) + { + await Verifier.VerifyJson(line).UseMethodName($"{nameof(BulkRequest_IndexMany_DescriptorSerialisationTest)}_{++count}"); + } + else + { + break; + } + } } private static readonly Project FixedProject = new() diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest.verified.txt deleted file mode 100644 index 25896043fa5..00000000000 --- a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest.verified.txt +++ /dev/null @@ -1,4 +0,0 @@ -{"index":{"_index":"project"}} -{"join":"project","lastActivity":"0001-01-01T00:00:00","leadDeveloper":{"gender":"Male","firstName":"Steve","id":0,"lastName":"Gordon"},"numberOfContributors":0,"startedOn":"0001-01-01T00:00:00","state":"BellyUp","type":"project","visibility":"Public"} -{"index":{"_index":"project"}} -{"join":"project","lastActivity":"0001-01-01T00:00:00","leadDeveloper":{"gender":"Male","firstName":"Steve","id":0,"lastName":"Gordon"},"numberOfContributors":0,"startedOn":"0001-01-01T00:00:00","state":"BellyUp","type":"project","visibility":"Public"} diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_1.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_1.verified.txt new file mode 100644 index 00000000000..da0dd7b4442 --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_1.verified.txt @@ -0,0 +1,5 @@ +{ + index: { + _index: project + } +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_2.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_2.verified.txt new file mode 100644 index 00000000000..9de5f31c30a --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_2.verified.txt @@ -0,0 +1,15 @@ +{ + join: project, + lastActivity: Date_MinValue, + leadDeveloper: { + firstName: Steve, + gender: Male, + id: 0, + lastName: Gordon + }, + numberOfContributors: 0, + startedOn: Date_MinValue, + state: BellyUp, + type: project, + visibility: Public +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_3.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_3.verified.txt new file mode 100644 index 00000000000..da0dd7b4442 --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_3.verified.txt @@ -0,0 +1,5 @@ +{ + index: { + _index: project + } +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_4.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_4.verified.txt new file mode 100644 index 00000000000..9de5f31c30a --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_DescriptorSerialisationTest_4.verified.txt @@ -0,0 +1,15 @@ +{ + join: project, + lastActivity: Date_MinValue, + leadDeveloper: { + firstName: Steve, + gender: Male, + id: 0, + lastName: Gordon + }, + numberOfContributors: 0, + startedOn: Date_MinValue, + state: BellyUp, + type: project, + visibility: Public +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest.verified.txt deleted file mode 100644 index 25896043fa5..00000000000 --- a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest.verified.txt +++ /dev/null @@ -1,4 +0,0 @@ -{"index":{"_index":"project"}} -{"join":"project","lastActivity":"0001-01-01T00:00:00","leadDeveloper":{"gender":"Male","firstName":"Steve","id":0,"lastName":"Gordon"},"numberOfContributors":0,"startedOn":"0001-01-01T00:00:00","state":"BellyUp","type":"project","visibility":"Public"} -{"index":{"_index":"project"}} -{"join":"project","lastActivity":"0001-01-01T00:00:00","leadDeveloper":{"gender":"Male","firstName":"Steve","id":0,"lastName":"Gordon"},"numberOfContributors":0,"startedOn":"0001-01-01T00:00:00","state":"BellyUp","type":"project","visibility":"Public"} diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_1.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_1.verified.txt new file mode 100644 index 00000000000..da0dd7b4442 --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_1.verified.txt @@ -0,0 +1,5 @@ +{ + index: { + _index: project + } +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_2.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_2.verified.txt new file mode 100644 index 00000000000..9de5f31c30a --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_2.verified.txt @@ -0,0 +1,15 @@ +{ + join: project, + lastActivity: Date_MinValue, + leadDeveloper: { + firstName: Steve, + gender: Male, + id: 0, + lastName: Gordon + }, + numberOfContributors: 0, + startedOn: Date_MinValue, + state: BellyUp, + type: project, + visibility: Public +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_3.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_3.verified.txt new file mode 100644 index 00000000000..da0dd7b4442 --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_3.verified.txt @@ -0,0 +1,5 @@ +{ + index: { + _index: project + } +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_4.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_4.verified.txt new file mode 100644 index 00000000000..9de5f31c30a --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_IndexMany_DescriptorSerialisationTest_4.verified.txt @@ -0,0 +1,15 @@ +{ + join: project, + lastActivity: Date_MinValue, + leadDeveloper: { + firstName: Steve, + gender: Male, + id: 0, + lastName: Gordon + }, + numberOfContributors: 0, + startedOn: Date_MinValue, + state: BellyUp, + type: project, + visibility: Public +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest.verified.txt deleted file mode 100644 index 25896043fa5..00000000000 --- a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest.verified.txt +++ /dev/null @@ -1,4 +0,0 @@ -{"index":{"_index":"project"}} -{"join":"project","lastActivity":"0001-01-01T00:00:00","leadDeveloper":{"gender":"Male","firstName":"Steve","id":0,"lastName":"Gordon"},"numberOfContributors":0,"startedOn":"0001-01-01T00:00:00","state":"BellyUp","type":"project","visibility":"Public"} -{"index":{"_index":"project"}} -{"join":"project","lastActivity":"0001-01-01T00:00:00","leadDeveloper":{"gender":"Male","firstName":"Steve","id":0,"lastName":"Gordon"},"numberOfContributors":0,"startedOn":"0001-01-01T00:00:00","state":"BellyUp","type":"project","visibility":"Public"} diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_1.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_1.verified.txt new file mode 100644 index 00000000000..da0dd7b4442 --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_1.verified.txt @@ -0,0 +1,5 @@ +{ + index: { + _index: project + } +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_2.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_2.verified.txt new file mode 100644 index 00000000000..9de5f31c30a --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_2.verified.txt @@ -0,0 +1,15 @@ +{ + join: project, + lastActivity: Date_MinValue, + leadDeveloper: { + firstName: Steve, + gender: Male, + id: 0, + lastName: Gordon + }, + numberOfContributors: 0, + startedOn: Date_MinValue, + state: BellyUp, + type: project, + visibility: Public +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_3.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_3.verified.txt new file mode 100644 index 00000000000..da0dd7b4442 --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_3.verified.txt @@ -0,0 +1,5 @@ +{ + index: { + _index: project + } +} \ No newline at end of file diff --git a/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_4.verified.txt b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_4.verified.txt new file mode 100644 index 00000000000..9de5f31c30a --- /dev/null +++ b/tests/Tests/_VerifySnapshots/BulkSerialisationTests.BulkRequest_SerialisationTest_4.verified.txt @@ -0,0 +1,15 @@ +{ + join: project, + lastActivity: Date_MinValue, + leadDeveloper: { + firstName: Steve, + gender: Male, + id: 0, + lastName: Gordon + }, + numberOfContributors: 0, + startedOn: Date_MinValue, + state: BellyUp, + type: project, + visibility: Public +} \ No newline at end of file