In unit test, i passed the assembly of Custom Activity to the ctor as the local assembly var xamlInjector = new XamlInjector("CreditAtRenewalFlow.xaml", typeof(CreateFollowUp).Assembly);
CreateFollowUp is a AsynCodeActivity
I got error "'Unexpected 'PROPERTYELEMENT' in parse rule 'Element ::= . EmptyElement | ( StartElement ElementBody ).'.' Line number '2' and line position '4'." at execution of the following line
var host = WorkflowInvokerTest.Create(xamlInjector.GetActivity());
The sample of the unit test is [TestMethod] [DeploymentItem(@"src\ProcessFlows\Activity1.xaml")] public void Activity1Test() {
var xamlInjector = new XamlInjector("Activity1.xaml", typeof(CreateFollowUp).Assembly); xamlInjector.ReplaceAll(typeof(CreateFollowUp), typeof (MockCreateFollowUp)); var mockExternalServiceManager = new Mock<IExternalServices>(); mockExternalServiceManager.Setup(x => x.CreateFollowUp()).Verifiable(); var host = WorkflowInvokerTest.Create(xamlInjector.GetActivity()); dynamic parameterValues1 = new WorkflowArguments(); parameterValues1.value1 = mockExternalServiceManager.Object; IDictionary<string, object> dictionary = host.TestActivity(); }
And the CreateFollowUp is given below
public sealed class CreateFollowUp : AsyncCodeActivity {
[RequiredArgument] public InArgument ExternalServices { get; set; }protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback,
object state) { Action createFollowUp = this.ExternalServices.Get(context).CreateFollowUp; context.UserState = createFollowUp; return createFollowUp.BeginInvoke(callback, state); }
protected override void EndExecute(AsyncCodeActivityContext context, IAsyncResult result) { var createFollowUp = context.UserState as Action; if (createFollowUp == null) { throw new ArgumentNullException("The AsyncState of the IAsyncResult was not of the type
ExternalServices.AsyncCreateFollowUp.", (Exception)null); }
createFollowUp.EndInvoke(result); } }