diff --git a/pages/ef-mstest-usage.md b/pages/ef-mstest-usage.md index c3a2ad39..fb22365b 100644 --- a/pages/ef-mstest-usage.md +++ b/pages/ef-mstest-usage.md @@ -767,6 +767,8 @@ A test without any attribute gets a new database per test, which is the most exp In a `[NoDb]` test `Database` is null, and accessing `ArrangeData`, `ActData`, or `AssertData`, or calling `Reset`, throws. +In a database test, recording resumes on the first access of `ActData`. A `[NoDb]` test has no `ActData`, so recording is resumed when the test starts. Other recorded activity, such as NServiceBus messages sent by the code under test, still appears in the snapshot. + `[NoDb]` can also be applied to a test class. The nearest attribute wins, so a method marked `[PooledDb]`, `[SharedDb]`, or `[NewDb]` in a `[NoDb]` class gets a database. Applying `[NoDb]` together with `[PooledDb]`, `[SharedDb]` or `[NewDb]` to the same method or class throws. diff --git a/pages/ef-nunit-usage.md b/pages/ef-nunit-usage.md index 13156552..19348c9b 100644 --- a/pages/ef-nunit-usage.md +++ b/pages/ef-nunit-usage.md @@ -778,6 +778,8 @@ A test without any attribute gets a new database per test, which is the most exp In a `[NoDb]` test `Database` is null, and accessing `ArrangeData`, `ActData`, or `AssertData`, or calling `Reset`, throws. +In a database test, recording resumes on the first access of `ActData`. A `[NoDb]` test has no `ActData`, so recording is resumed when the test starts. Other recorded activity, such as NServiceBus messages sent by the code under test, still appears in the snapshot. + `[NoDb]` can also be applied to a test class. The nearest attribute wins, so a method marked `[PooledDb]`, `[SharedDb]`, or `[NewDb]` in a `[NoDb]` class gets a database. Applying `[NoDb]` together with `[PooledDb]`, `[SharedDb]` or `[NewDb]` to the same method or class throws. diff --git a/pages/ef-tunit-usage.md b/pages/ef-tunit-usage.md index 7fa3c101..06f1ebde 100644 --- a/pages/ef-tunit-usage.md +++ b/pages/ef-tunit-usage.md @@ -774,6 +774,8 @@ A test without any attribute gets a new database per test, which is the most exp In a `[NoDb]` test `Database` is null, and accessing `ArrangeData`, `ActData`, or `AssertData`, or calling `Reset`, throws. +In a database test, recording resumes on the first access of `ActData`. A `[NoDb]` test has no `ActData`, so recording is resumed when the test starts. Other recorded activity, such as NServiceBus messages sent by the code under test, still appears in the snapshot. + `[NoDb]` can also be applied to a test class. The nearest attribute wins, so a method marked `[PooledDb]`, `[SharedDb]`, or `[NewDb]` in a `[NoDb]` class gets a database. Applying `[NoDb]` together with `[PooledDb]`, `[SharedDb]` or `[NewDb]` to the same method or class throws. diff --git a/pages/ef-xunitv3-usage.md b/pages/ef-xunitv3-usage.md index 19ba64f0..d0306121 100644 --- a/pages/ef-xunitv3-usage.md +++ b/pages/ef-xunitv3-usage.md @@ -772,6 +772,8 @@ A test without any attribute gets a new database per test, which is the most exp In a `[NoDb]` test `Database` is null, and accessing `ArrangeData`, `ActData`, or `AssertData`, or calling `Reset`, throws. +In a database test, recording resumes on the first access of `ActData`. A `[NoDb]` test has no `ActData`, so recording is resumed when the test starts. Other recorded activity, such as NServiceBus messages sent by the code under test, still appears in the snapshot. + `[NoDb]` can also be applied to a test class. The nearest attribute wins, so a method marked `[PooledDb]`, `[SharedDb]`, or `[NewDb]` in a `[NoDb]` class gets a database. Applying `[NoDb]` together with `[PooledDb]`, `[SharedDb]` or `[NewDb]` to the same method or class throws. diff --git a/pages/mdsource/no-db.include.md b/pages/mdsource/no-db.include.md index d4bf9a7c..9c7999fc 100644 --- a/pages/mdsource/no-db.include.md +++ b/pages/mdsource/no-db.include.md @@ -4,4 +4,6 @@ A test without any attribute gets a new database per test, which is the most exp In a `[NoDb]` test `Database` is null, and accessing `ArrangeData`, `ActData`, or `AssertData`, or calling `Reset`, throws. +In a database test, recording resumes on the first access of `ActData`. A `[NoDb]` test has no `ActData`, so recording is resumed when the test starts. Other recorded activity, such as NServiceBus messages sent by the code under test, still appears in the snapshot. + `[NoDb]` can also be applied to a test class. The nearest attribute wins, so a method marked `[PooledDb]`, `[SharedDb]`, or `[NewDb]` in a `[NoDb]` class gets a database. Applying `[NoDb]` together with `[PooledDb]`, `[SharedDb]` or `[NewDb]` to the same method or class throws. diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 1e878182..342d689a 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ CS1591;CA1416;CS8632;NU1608;NU1109 - 27.2.1 + 27.2.2 preview 1.0.0 false diff --git a/src/EfLocalDb.MSTest.Tests/NoDbTests.cs b/src/EfLocalDb.MSTest.Tests/NoDbTests.cs index 7b352b23..6a49b3d2 100644 --- a/src/EfLocalDb.MSTest.Tests/NoDbTests.cs +++ b/src/EfLocalDb.MSTest.Tests/NoDbTests.cs @@ -14,6 +14,11 @@ public void ArrangeDataThrows() Assert.Contains("[NoDb]", exception.Message); } + [TestMethod] + [NoDb] + public void IsRecording() => + Assert.IsTrue(Recording.IsRecording()); + [TestMethod] [NoDb] public async Task ResetThrows() => diff --git a/src/EfLocalDb.MSTest/LocalDbTestBase.cs b/src/EfLocalDb.MSTest/LocalDbTestBase.cs index d71930fe..eb97ffc1 100644 --- a/src/EfLocalDb.MSTest/LocalDbTestBase.cs +++ b/src/EfLocalDb.MSTest/LocalDbTestBase.cs @@ -62,6 +62,9 @@ public virtual Task SetUp() QueryFilter.Enable(); if (isNoDb) { + // ActData is what resumes recording, and a [NoDb] test has none, + // so resume here to still record other activity such as sent messages + Recording.Resume(); return Task.CompletedTask; } diff --git a/src/EfLocalDb.NUnit.Tests/NoDbTests.cs b/src/EfLocalDb.NUnit.Tests/NoDbTests.cs index d917f1e6..a6dfe929 100644 --- a/src/EfLocalDb.NUnit.Tests/NoDbTests.cs +++ b/src/EfLocalDb.NUnit.Tests/NoDbTests.cs @@ -15,6 +15,11 @@ public void ArrangeDataThrows() That(exception.Message, Does.Contain("[NoDb]")); } + [Test] + [NoDb] + public void IsRecording() => + That(Recording.IsRecording(), Is.True); + [Test] [NoDb] public void ResetThrows() => diff --git a/src/EfLocalDb.NUnit/LocalDbTestBase.cs b/src/EfLocalDb.NUnit/LocalDbTestBase.cs index 2116662d..5a0f03cc 100644 --- a/src/EfLocalDb.NUnit/LocalDbTestBase.cs +++ b/src/EfLocalDb.NUnit/LocalDbTestBase.cs @@ -63,6 +63,9 @@ public virtual Task SetUp() QueryFilter.Enable(); if (isNoDb) { + // ActData is what resumes recording, and a [NoDb] test has none, + // so resume here to still record other activity such as sent messages + Recording.Resume(); return Task.CompletedTask; } diff --git a/src/EfLocalDb.TUnit.Tests/NoDbTests.cs b/src/EfLocalDb.TUnit.Tests/NoDbTests.cs index 6368c5f8..bd2a8752 100644 --- a/src/EfLocalDb.TUnit.Tests/NoDbTests.cs +++ b/src/EfLocalDb.TUnit.Tests/NoDbTests.cs @@ -13,6 +13,11 @@ public async Task ArrangeDataThrows() await Assert.That(exception!.Message).Contains("[NoDb]"); } + [Test] + [NoDb] + public async Task IsRecording() => + await Assert.That(Recording.IsRecording()).IsTrue(); + [Test] [NoDb] public async Task ResetThrows() => diff --git a/src/EfLocalDb.TUnit/LocalDbTestBase.cs b/src/EfLocalDb.TUnit/LocalDbTestBase.cs index a0234d02..2983b32b 100644 --- a/src/EfLocalDb.TUnit/LocalDbTestBase.cs +++ b/src/EfLocalDb.TUnit/LocalDbTestBase.cs @@ -69,6 +69,9 @@ public virtual Task SetUp() if (isNoDb) { + // ActData is what resumes recording, and a [NoDb] test has none, + // so resume here to still record other activity such as sent messages + Recording.Resume(); return Task.CompletedTask; } diff --git a/src/EfLocalDb.Xunit.V3.Tests/NoDbTests.cs b/src/EfLocalDb.Xunit.V3.Tests/NoDbTests.cs index ac415fd5..6f2dba23 100644 --- a/src/EfLocalDb.Xunit.V3.Tests/NoDbTests.cs +++ b/src/EfLocalDb.Xunit.V3.Tests/NoDbTests.cs @@ -13,6 +13,11 @@ public void ArrangeDataThrows() Assert.Contains("[NoDb]", exception.Message); } + [Fact] + [NoDb] + public void IsRecording() => + Assert.True(Recording.IsRecording()); + [Fact] [NoDb] public Task ResetThrows() => diff --git a/src/EfLocalDb.Xunit.V3/LocalDbTestBase.cs b/src/EfLocalDb.Xunit.V3/LocalDbTestBase.cs index d87535de..5de2d8d0 100644 --- a/src/EfLocalDb.Xunit.V3/LocalDbTestBase.cs +++ b/src/EfLocalDb.Xunit.V3/LocalDbTestBase.cs @@ -58,6 +58,9 @@ public virtual async ValueTask InitializeAsync() QueryFilter.Enable(); if (isNoDb) { + // ActData is what resumes recording, and a [NoDb] test has none, + // so resume here to still record other activity such as sent messages + Recording.Resume(); return; }