1
votes

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);
    }
}
1
interesting... never seen that before. Would you mind sending your XAML to me? ron (dot) jacobs (at) microsoft (dot) comRon Jacobs
Sorry for replyling back late, after reving my code again I realised that WorkflowArguments was giving problem. So when I changed input argumenst as dictionary object it worked fine.userpb
In your case, how did you fix it? Why do you need to change input arg into dictionary object? I have same issue here, and I have no idea what is wrong.Vu Nguyen

1 Answers

0
votes

try to modify source code of the activity. Change "xmlns:local="clr-namespace:Activity1" to xmlns:local="clr-namespace:Activity1;assembly=Activity1".

include the assembly in namespaces references (use the correct assembly name)