diff --git a/test/MsSqlCdc.Tests/CdcTests.cs b/test/MsSqlCdc.Tests/CdcTests.cs index 958b948..be6eb6e 100644 --- a/test/MsSqlCdc.Tests/CdcTests.cs +++ b/test/MsSqlCdc.Tests/CdcTests.cs @@ -112,35 +112,37 @@ public async Task Get_all_changes_rowfilter_all() var minLsn = await Cdc.GetMinLsn(connection, captureInstance); var maxLsn = await Cdc.GetMaxLsn(connection); - var netChanges = (await Cdc.GetAllChanges( + var netChanges = await Cdc.GetAllChanges( connection, captureInstance, minLsn, maxLsn, - AllChangesRowFilterOption.All)).ToArray(); - - var insert = netChanges[0]; - var afterUpdate = netChanges[1]; - - using (var scope = new AssertionScope()) - { - netChanges.Length.Should().Be(2); - insert.CaptureInstance.Should().Be(captureInstance); - insert.StartLineSequenceNumber.Should().BeGreaterThan(default(BigInteger)); - insert.SequenceValue.Should().BeGreaterThan(default(BigInteger)); - insert.Operation.Should().Be(Operation.Insert); - insert.Fields["id"].Should().NotBeNull(); - insert.Fields["first_name"].Should().Be("Rune"); - insert.Fields["last_name"].Should().Be("Nielsen"); - - afterUpdate.CaptureInstance.Should().Be(captureInstance); - afterUpdate.StartLineSequenceNumber.Should().BeGreaterThan(default(BigInteger)); - afterUpdate.SequenceValue.Should().BeGreaterThan(default(BigInteger)); - afterUpdate.Operation.Should().Be(Operation.AfterUpdate); - afterUpdate.Fields["id"].Should().NotBeNull(); - afterUpdate.Fields["first_name"].Should().Be("Rune"); - afterUpdate.Fields["last_name"].Should().Be("Jensen"); - } + AllChangesRowFilterOption.All); + + netChanges + .Should() + .HaveCount(2).And + .SatisfyRespectively( + insert => + { + insert.CaptureInstance.Should().Be(captureInstance); + insert.StartLineSequenceNumber.Should().BeGreaterThan(default(BigInteger)); + insert.SequenceValue.Should().BeGreaterThan(default(BigInteger)); + insert.Operation.Should().Be(Operation.Insert); + insert.Fields["id"].Should().NotBeNull(); + insert.Fields["first_name"].Should().Be("Rune"); + insert.Fields["last_name"].Should().Be("Nielsen"); + }, + afterUpdate => + { + afterUpdate.CaptureInstance.Should().Be(captureInstance); + afterUpdate.StartLineSequenceNumber.Should().BeGreaterThan(default(BigInteger)); + afterUpdate.SequenceValue.Should().BeGreaterThan(default(BigInteger)); + afterUpdate.Operation.Should().Be(Operation.AfterUpdate); + afterUpdate.Fields["id"].Should().NotBeNull(); + afterUpdate.Fields["first_name"].Should().Be("Rune"); + afterUpdate.Fields["last_name"].Should().Be("Jensen"); + }); } [Fact] @@ -160,37 +162,40 @@ public async Task Get_all_changes_rowfilter_all_update_old() maxLsn, AllChangesRowFilterOption.AllUpdateOld)).ToArray(); - var insert = netChanges[0]; - var beforeUpdate = netChanges[1]; - var afterUpdate = netChanges[2]; - - using (var scope = new AssertionScope()) - { - netChanges.Length.Should().Be(3); - insert.CaptureInstance.Should().Be(captureInstance); - insert.StartLineSequenceNumber.Should().BeGreaterThan(default(BigInteger)); - insert.SequenceValue.Should().BeGreaterThan(default(BigInteger)); - insert.Operation.Should().Be(Operation.Insert); - insert.Fields["id"].Should().NotBeNull(); - insert.Fields["first_name"].Should().Be("Rune"); - insert.Fields["last_name"].Should().Be("Nielsen"); - - beforeUpdate.CaptureInstance.Should().Be(captureInstance); - beforeUpdate.StartLineSequenceNumber.Should().BeGreaterThan(default(BigInteger)); - beforeUpdate.SequenceValue.Should().BeGreaterThan(default(BigInteger)); - beforeUpdate.Operation.Should().Be(Operation.BeforeUpdate); - beforeUpdate.Fields["id"].Should().NotBeNull(); - beforeUpdate.Fields["first_name"].Should().Be("Rune"); - beforeUpdate.Fields["last_name"].Should().Be("Nielsen"); - - afterUpdate.CaptureInstance.Should().Be(captureInstance); - afterUpdate.StartLineSequenceNumber.Should().BeGreaterThan(default(BigInteger)); - afterUpdate.SequenceValue.Should().BeGreaterThan(default(BigInteger)); - afterUpdate.Operation.Should().Be(Operation.AfterUpdate); - afterUpdate.Fields["id"].Should().NotBeNull(); - afterUpdate.Fields["first_name"].Should().Be("Rune"); - afterUpdate.Fields["last_name"].Should().Be("Jensen"); - } + netChanges + .Should() + .HaveCount(3).And + .SatisfyRespectively( + insert => + { + insert.CaptureInstance.Should().Be(captureInstance); + insert.StartLineSequenceNumber.Should().BeGreaterThan(default(BigInteger)); + insert.SequenceValue.Should().BeGreaterThan(default(BigInteger)); + insert.Operation.Should().Be(Operation.Insert); + insert.Fields["id"].Should().NotBeNull(); + insert.Fields["first_name"].Should().Be("Rune"); + insert.Fields["last_name"].Should().Be("Nielsen"); + }, + beforeUpdate => + { + beforeUpdate.CaptureInstance.Should().Be(captureInstance); + beforeUpdate.StartLineSequenceNumber.Should().BeGreaterThan(default(BigInteger)); + beforeUpdate.SequenceValue.Should().BeGreaterThan(default(BigInteger)); + beforeUpdate.Operation.Should().Be(Operation.BeforeUpdate); + beforeUpdate.Fields["id"].Should().NotBeNull(); + beforeUpdate.Fields["first_name"].Should().Be("Rune"); + beforeUpdate.Fields["last_name"].Should().Be("Nielsen"); + }, + afterUpdate => + { + afterUpdate.CaptureInstance.Should().Be(captureInstance); + afterUpdate.StartLineSequenceNumber.Should().BeGreaterThan(default(BigInteger)); + afterUpdate.SequenceValue.Should().BeGreaterThan(default(BigInteger)); + afterUpdate.Operation.Should().Be(Operation.AfterUpdate); + afterUpdate.Fields["id"].Should().NotBeNull(); + afterUpdate.Fields["first_name"].Should().Be("Rune"); + afterUpdate.Fields["last_name"].Should().Be("Jensen"); + }); } private async Task CreateOpenSqlConnection()