chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Is it possible to control the behavior of the workflow activities in WF 4.0? I've a xaml activity with two arguments. One input argument and one output argument.

What I want to do is to control the output argument so it returns a mocked object or an other predefined value type.

Is this possible? And if so, how to achieve this?
asked by Dutchdre (680 points)

5 Answers

0 votes
Hi,

Are you wrapping the XAML activity with a class with properties or you're working against the arguments with dictionary at initialization?

Regards,
Elisha,
Typemock Support
answered by Elisha (12k points)
0 votes
Hi Elisha,

I'm using the activity inside a flowchart. It is populated with variables of this flowchart and therefore not wrapped in a class.

Inside the flowchart I have defined a variable of type System.Decimal and bind it to the output argument of the activity. This activity calls an external system wich is not available during the tests.

So what I want, is to the mock this activity so it returns always € 20.00.
answered by Dutchdre (680 points)
0 votes
If the activity is a custom activity you can probably use WhenCalled and Swap to fake that activity:
[TestMethod]
public void TestMethod1()
{
    var fakeActivity = Isolate.Fake.Instance<MyActivity>();
    Isolate.Swap.NextInstance<MyActivity>().With(fakeActivity);

    IDictionary<string, object> results = WorkflowInvoker.Invoke
    (
         //...
    );

    Assert.AreEqual("654321", results["ReversedString"]);
}


If the code above does not work for you please send a more concrete example to support AT typemock.com
answered by dhelper (11.9k points)
0 votes
If the activity is a custom activity you can probably use WhenCalled and Swap to fake that activity:
[TestMethod]
public void TestMethod1()
{
    var fakeActivity = Isolate.Fake.Instance<MyActivity>();
    Isolate.Swap.NextInstance<MyActivity>().With(fakeActivity);

    IDictionary<string, object> results = WorkflowInvoker.Invoke
    (
         //...
    );

    Assert.AreEqual("654321", results["ReversedString"]);
}


If the code above does not work for you please send a more concrete example to support AT typemock.com
answered by dhelper (11.9k points)
0 votes
Hi dhelper,

I've sent you a simplified example of my situation.
answered by Dutchdre (680 points)
...