protected override void Test(IOrganizationService service) { var plugin = new TestPlugin(null, null); var serviceProvider = new ServiceProviderBuilder( service, new PluginExecutionContextBuilder() .WithRegisteredEvent(20, "Delete", "account") .WithPrimaryEntityId(Ids.Account) .WithTarget(Ids.Account) .Build(), new DebugLogger()).Build(); var executionContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); var target = executionContext.InputParameters["Target"] as EntityReference; plugin.Execute(serviceProvider); serviceProvider = new ServiceProviderBuilder( service, new PluginExecutionContextBuilder() .WithRegisteredEvent(40, "Delete", "account") .WithPrimaryEntityId(Ids.Account) .WithTarget(Ids.Account) .Build(), new DebugLogger()).Build(); executionContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); plugin.Execute(serviceProvider); }
protected override void Test(IOrganizationService service) { service = new OrganizationServiceBuilder(service) .Build(); var plugin = new TestPlugin(null, null); var serviceProvider = new ServiceProviderBuilder( service, new PluginExecutionContextBuilder() .WithRegisteredEvent(40, "Create", "new_testentity") .WithPrimaryEntityId(Guid.NewGuid()) .Build(), new DebugLogger()).Build(); for (int i = 0; i < 20; i++) { try { plugin.Execute(serviceProvider); } catch (Exception ex) { // Process if it is not the expected exception we are throwing to test telemetry. if (ex.Message != "Unhandled Plugin Exception Throw Unhandled Exception") { throw; } } } }
protected override void Test(IOrganizationService service) { var plugin = new TestPlugin(null, null); var serviceProvider = new ServiceProviderBuilder( service, new PluginExecutionContextBuilder() .WithRegisteredEvent(20, "Create", "account") .WithPrimaryEntityId(Ids.Account) .WithTarget(Ids.Account) .Build(), new DebugLogger()).Build(); var executionContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); var target = executionContext.InputParameters["Target"] as Entity; Assert.AreEqual(2, target.Attributes.Count); plugin.Execute(serviceProvider); // input parameter was changed Assert.AreEqual(3, target.Attributes.Count); serviceProvider = new ServiceProviderBuilder( service, new PluginExecutionContextBuilder() .WithRegisteredEvent(40, "Create", "account") .WithPrimaryEntityId(Ids.Account) .WithTarget(Ids.Account) .WithOutputParameter("id", default(Guid)) .Build(), new DebugLogger()).Build(); executionContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); plugin.Execute(serviceProvider); // output parameter was changed. Assert.AreNotEqual(default(Guid), (Guid)executionContext.OutputParameters["id"]); }
protected override void Test(IOrganizationService service) { service = new OrganizationServiceBuilder(service) .Build(); var plugin = new TestPlugin(null, null); var serviceProvider = new ServiceProviderBuilder( service, new PluginExecutionContextBuilder() .WithRegisteredEvent(40, "Create", "new_testentity") .WithPrimaryEntityId(Guid.NewGuid()) .Build(), new DebugLogger()).Build(); plugin.Execute(serviceProvider); }