Skip to content

Commit 972f04f

Browse files
contextduckCopilot
andcommitted
Fix AccountDeleteInPostPlugin being auto-registered across all tests
The plugin extended Plugin directly, causing it to be discovered and registered by the base type scanner for every test that updated an account, deleting records in unrelated tests. Fix: - Change AccountDeleteInPostPlugin to extend TestPlugin (an intermediate abstract class) instead of Plugin directly. The scanner uses t.BaseType == basePluginType so transitively-inherited plugins are not auto-discovered. - Add missing #pragma warning disable CS0618 around RegisterPluginStep (consistent with other test plugins, also fixes CodeFactor warning). - Simplify test assertions to use already-imported QueryExpression types instead of fully-qualified names. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7b09c63 commit 972f04f

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

tests/TestPluginAssembly365/Plugins/AccountDeleteInPostPlugin.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22
namespace DG.Some.Namespace {
33
using System;
44
using DG.XrmFramework.BusinessDomain.ServiceContext;
5+
using TestPluginAssembly365.Plugins.SyncAsyncTest;
56
using XrmPluginCore;
67
using XrmPluginCore.Enums;
78

89
/// <summary>
910
/// Test plugin that deletes the target account in a post-Update operation.
1011
/// Used to verify that XrmMockup handles record deletion inside a post-operation plugin gracefully.
1112
/// </summary>
12-
public class AccountDeleteInPostPlugin : Plugin {
13+
public class AccountDeleteInPostPlugin : TestPlugin {
1314

1415
public AccountDeleteInPostPlugin() {
16+
#pragma warning disable CS0618 // Type or member is obsolete - disabled for testing purposes
1517
RegisterPluginStep<Account>(
1618
EventOperation.Update,
1719
ExecutionStage.PostOperation,
1820
Execute);
21+
#pragma warning restore CS0618 // Type or member is obsolete
1922
}
2023

2124
protected void Execute(LocalPluginContext localContext) {

tests/XrmMockup365Test/TestPlugins.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ public void TestDeleteTargetInPostUpdatePlugin()
236236

237237
// Verify the account was actually deleted by the plugin
238238
var retrieved = orgAdminService.RetrieveMultiple(
239-
new Microsoft.Xrm.Sdk.Query.QueryExpression(Account.EntityLogicalName)
239+
new QueryExpression(Account.EntityLogicalName)
240240
{
241-
Criteria = new Microsoft.Xrm.Sdk.Query.FilterExpression
241+
Criteria = new FilterExpression
242242
{
243243
Conditions =
244244
{
245-
new Microsoft.Xrm.Sdk.Query.ConditionExpression("accountid", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, account.Id)
245+
new ConditionExpression("accountid", ConditionOperator.Equal, account.Id)
246246
}
247247
}
248248
});

0 commit comments

Comments
 (0)