Skip to content

Commit ecbab6b

Browse files
Obsolete the given when then syntax with a WARN to guide users towards the AAA syntax (#299)
* Obsolete given when then syntax with WARN for v7 * Approve API changes
1 parent 00ebf61 commit ecbab6b

File tree

7 files changed

+30
-1
lines changed

7 files changed

+30
-1
lines changed

src/NServiceBus.Testing.Tests/APIApprovals.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class APIApprovals
99
[Test]
1010
public void Approve()
1111
{
12-
var publicApi = ApiGenerator.GeneratePublicApi(typeof(Test).Assembly, excludeAttributes: new[] { "System.Runtime.Versioning.TargetFrameworkAttribute", "System.Reflection.AssemblyMetadataAttribute" });
12+
var publicApi = ApiGenerator.GeneratePublicApi(typeof(TestableMessageSession).Assembly, excludeAttributes: new[] { "System.Runtime.Versioning.TargetFrameworkAttribute", "System.Reflection.AssemblyMetadataAttribute" });
1313
Approver.Verify(publicApi);
1414
}
1515
}

src/NServiceBus.Testing.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
33
namespace NServiceBus.Testing
44
{
5+
[System.ObsoleteAttribute("Use the arrange act assert (AAA) syntax instead. Please see the upgrade guide for" +
6+
" more details. Will be treated as an error from version 8.0.0. Will be removed i" +
7+
"n version 9.0.0.", false)]
58
public class ExpectationException : System.Exception
69
{
710
public ExpectationException() { }
@@ -26,6 +29,9 @@ namespace NServiceBus.Testing
2629
public void Register(System.Type type, System.Func<object[]> factory) { }
2730
public virtual void Release(object instance) { }
2831
}
32+
[System.ObsoleteAttribute("Use the arrange act assert (AAA) syntax instead. Please see the upgrade guide for" +
33+
" more details. Will be treated as an error from version 8.0.0. Will be removed i" +
34+
"n version 9.0.0.", false)]
2935
public class Handler<T>
3036
{
3137
public NServiceBus.Testing.Handler<T> ConfigureHandlerContext(System.Action<NServiceBus.Testing.TestableMessageHandlerContext> contextInitializer) { }
@@ -92,6 +98,9 @@ namespace NServiceBus.Testing
9298
{
9399
public RepliedMessage(TMessage message, NServiceBus.ReplyOptions options) { }
94100
}
101+
[System.ObsoleteAttribute("Use the arrange act assert (AAA) syntax instead. Please see the upgrade guide for" +
102+
" more details. Will be treated as an error from version 8.0.0. Will be removed i" +
103+
"n version 9.0.0.", false)]
95104
public class Saga<T>
96105
where T : NServiceBus.Saga
97106
{
@@ -171,6 +180,9 @@ namespace NServiceBus.Testing
171180
{
172181
public Subscription(System.Type message, NServiceBus.SubscribeOptions options) { }
173182
}
183+
[System.ObsoleteAttribute("Use the arrange act assert (AAA) syntax instead. Please see the upgrade guide for" +
184+
" more details. Will be treated as an error from version 8.0.0. Will be removed i" +
185+
"n version 9.0.0.", false)]
174186
public class Test
175187
{
176188
public Test() { }

src/NServiceBus.Testing.Tests/NServiceBus.Testing.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>net452;netcoreapp3.1;net5.0</TargetFrameworks>
55
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
6+
<NoWarn>0618</NoWarn>
67
</PropertyGroup>
78

89
<ItemGroup>

src/NServiceBus.Testing/ExpectationException.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
/// <summary>
66
/// Exception representing a failed expectation.
77
/// </summary>
8+
[ObsoleteEx(
9+
Message = "Use the arrange act assert (AAA) syntax instead. Please see the upgrade guide for more details.",
10+
RemoveInVersion = "9",
11+
TreatAsErrorFromVersion = "8")]
812
public class ExpectationException : Exception
913
{
1014
/// <summary>

src/NServiceBus.Testing/Handler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ namespace NServiceBus.Testing
77
/// <summary>
88
/// Message handler unit testing framework.
99
/// </summary>
10+
[ObsoleteEx(
11+
Message = "Use the arrange act assert (AAA) syntax instead. Please see the upgrade guide for more details.",
12+
RemoveInVersion = "9",
13+
TreatAsErrorFromVersion = "8")]
1014
public partial class Handler<T>
1115
{
1216
/// <summary>

src/NServiceBus.Testing/Saga.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ internal static class SagaConsts
1414
/// <summary>
1515
/// Saga unit testing framework.
1616
/// </summary>
17+
[ObsoleteEx(
18+
Message = "Use the arrange act assert (AAA) syntax instead. Please see the upgrade guide for more details.",
19+
RemoveInVersion = "9",
20+
TreatAsErrorFromVersion = "8")]
1721
public partial class Saga<T> where T : Saga
1822
{
1923
internal Saga(T saga)

src/NServiceBus.Testing/Test.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
/// <summary>
77
/// Entry class used for unit testing
88
/// </summary>
9+
[ObsoleteEx(
10+
Message = "Use the arrange act assert (AAA) syntax instead. Please see the upgrade guide for more details.",
11+
RemoveInVersion = "9",
12+
TreatAsErrorFromVersion = "8")]
913
public class Test
1014
{
1115
/// <summary>

0 commit comments

Comments
 (0)