Use FakeXrmEasy with Third Party Extended Plugins #549
-
I currently using FakeXrmEasy with standard Plugins. I works great for me for example --> public class ContactUpdateAddress : PluginBase where PluginBase Extends (IPlugin) What Could I do to integrate FakeXrmEasy with External Third Party Plugin implementation? using System; namespace ThirdParty.CRM
} |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
Hello @Gmanunta81GFPS , |
Beta Was this translation helpful? Give feedback.
-
Hi Betim,
Thanks for the reply.
Looks like something missing
**_FakeXrmEasy.PullRequestException: 'Exception: The specified service type is not supported. This functionality is not available yet. Please consider contributing to the following Git project https://github.com/jordimontana82/fake-xrm-easy by cloning the repository and issuing a pull request.'_**
**_[External Code]
3party.ServiceProviders.GetService<T>(System.IServiceProvider) in ServiceProviders.cs
3party.CRM.PluginBase.Execute(System.IServiceProvider) in PluginBase.cs
[External Code]
3party.CRM.Customer.Testing.FakeXrmUnitTestProject.PLUGINUnitTest.ContactUpdateaddresstester() in PLUGINUnitTest.cs_**
|
Beta Was this translation helpful? Give feedback.
-
Hi @Gmanunta81GFPS , If the custom plugin implements IPlugin it should be possible to use FakeXrmEasy like with any other plugin. We do this to test our own plugins that inherit from a PluginBase class which is what you're asking I suppose. However, without the plugin source code, is going to be difficult to figure out what's going on there.... you might to follow up with your 3rd party provider? It seems that 3rd party plugin code is asking for a specific service for which there is no default mock. If you could tell us what that service is it could help. |
Beta Was this translation helpful? Give feedback.
-
Hi Jordi, Hi Betim
Thanks for the quick reply (I am one of your supporter)
This is the initial code
public void ContactUpdateaddresstester()
{
var fakedContext = new XrmFakedContext();
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
var context = new XrmRealContext
{
//ProxyTypesAssembly = typeof(InterestPreCreateDeleteBuildAppointmentInterestTextField).Assembly,
ConnectionStringName = "CRMOnline"
};
var guid1 = Guid.NewGuid();
var target = new Entity("contact") { Id = guid1 };
//Execute our plugin against the selected target
var plugCtx = fakedContext.GetDefaultPluginContext();
context.ExecutePluginWith<ContactUpdateAddress>(plugCtx);
}
Second part
/// <summary>
/// This Plugin adds the country from the optionset into the address field
/// </summary>
[PluginEntity(typeof(Contact)),
PluginMessage(PluginMessage.Create, PluginMessage.Update),
PluginStage(PluginStage.PostOperation)]
public class ContactUpdateAddress : PluginBase
{
protected override bool OnCheckFilter(PluginContext pluginContext)
{
//prevent infinity loop
if (pluginContext.Depth > 2)
{
return false;
}
return base.OnCheckFilter(pluginContext);
}
/// <summary>
/// OnExecute
/// </summary>
/// <param name="pluginContext">The plugin context.</param>
protected override void OnExecute(PluginContext pluginContext)
{ …………………..
Third part
public abstract class PluginBase : IPlugin
{
protected PluginBase();
protected PluginBase(string unsecureConfiguration, string secureConfiguration);
protected internal string SecureConfiguration { get; }
protected internal string UnsecureConfiguration { get; }
protected static void OnValidateRegistration(Type pluginType, PluginContext pluginContext);
protected internal static void OnValidateRegistration(Type pluginType, PluginContext pluginContext, bool inheritAttributes);
public void Execute(PluginContext pluginContext);
public void Execute(IServiceProvider serviceProvider);
protected virtual Guid? GetOrganizationServiceUserId(IPluginExecutionContext pluginExecutionContext);
protected virtual bool OnCheckFilter(PluginContext pluginContext);
protected virtual bool OnCheckFilterPreValidation(IPluginExecutionContext pluginExecutionContext);
protected virtual bool OnCheckMessageContextPreValidation(IPluginExecutionContext pluginExecutionContext);
protected abstract void OnExecute(PluginContext pluginContext);
protected virtual void OnExecutionCompleted(PluginContext pluginContext);
protected virtual void OnPluginContextCreated(PluginContext pluginContext);
protected virtual void OnValidateRegistration(PluginContext pluginContext);
}
I hope this help
From: Jordi <[email protected]>
Sent: 12 February 2021 13:22
To: jordimontana82/fake-xrm-easy <[email protected]>
Cc: Manunta, Giovanni <[email protected]>; Mention <[email protected]>
Subject: -EXTERNAL- Re: [jordimontana82/fake-xrm-easy] Use FakeXrmEasy with Third Party Extended Plugins (#549)
[Security note added by GF Corporate IT: This e-mail was sent from outside of GF. Do not click on links or open attachments unless you recognize the sender of this e-mail and know the content is safe.]
Added a new issue to track this as an enhancement: #550<#550>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#549 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ASTK4MNIFCJJARQOYTJTIHLS6UMPRANCNFSM4XMQPUXA>.
This e-mail (including attachments) is confidential and may be privileged. Please delete if obtained in error and email confirmation to the sender. Thank you for your cooperation.
|
Beta Was this translation helpful? Give feedback.
-
Oaky
What should I do ? with method should I use ?
From: Jordi <[email protected]>
Sent: 12 February 2021 13:40
To: jordimontana82/fake-xrm-easy <[email protected]>
Cc: Manunta, Giovanni <[email protected]>; Mention <[email protected]>
Subject: -EXTERNAL- Re: [jordimontana82/fake-xrm-easy] Use FakeXrmEasy with Third Party Extended Plugins (#549)
[Security note added by GF Corporate IT: This e-mail was sent from outside of GF. Do not click on links or open attachments unless you recognize the sender of this e-mail and know the content is safe.]
In addition to that, it seems you're executing a plugin using the XrmRealContext instance not the XrmFakedContext?? That's not a envisioned scenario to use the ExecutePluginWith method ... @Gmanunta81GFPS<https://github.com/Gmanunta81GFPS>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#549 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ASTK4MLU2DKTYCVNIJUYUNDS6UOTNANCNFSM4XMQPUXA>.
This e-mail (including attachments) is confidential and may be privileged. Please delete if obtained in error and email confirmation to the sender. Thank you for your cooperation.
|
Beta Was this translation helpful? Give feedback.
-
Hi everyone, Thank you very much for your support Betim. the issue is in this line of code serviceProvider.GetService(); the interface IPluginContextFactory is not implemented in the Standard IServiceProvider serviceProvider object and the system is going to catch the exception (unfortunately for me ) |
Beta Was this translation helpful? Give feedback.
Hi everyone,
Thank you very much for your support Betim.
the issue is in this line of code
serviceProvider.GetService();
the interface IPluginContextFactory is not implemented in the Standard IServiceProvider serviceProvider object and the system is going to catch the exception (unfortunately for me )