Quick Tips
  • 16 Sep 2025
  • 2 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Quick Tips

  • Dark
    Light
  • PDF

Article summary

The aim of this page is to provide some quick tips on common techniques you may need to use.

Assertions against the body from a response action

In the below code snipped you can see how to access a response action and then use the message in it which in this case is json and you can get data from it to make assertions against.

//Assert response returned to caller
            var responseOutput = testRun.Actions["Response"].Outputs;
            var responseBody = responseOutput.SelectToken("$.body");
            var responseBodyJson = JObject.Parse(responseBody.ToString());
            var isVipValue = responseBodyJson.SelectToken("$.is_vip");
            var isVip = bool.Parse(isVipValue?.ToString() ?? "false");

            Assert.IsFalse(isVip, "The response should indicate the customer is a VIP when they should NOT be.");
        

Return A Dynamic Value from an Action Mock

In the below example you can see how I am dynamically building a json message for my mock which will return a variable as the customer percentage.


/Setup Get Customer History Mock
            mockData.ActionMocks["Get_customer_value"] = new GetCustomerValueActionMock(
                name: "Get_customer_value",
                onGetActionMock: (testExecutionContext) =>
            {
            

                return new GetCustomerValueActionMock(
                    status: TestWorkflowStatus.Succeeded,
                    outputs: new GetCustomerValueActionOutput
                    {
                        Body = new JObject
                        {
                            ["CustomerValuePercentage"] = customerValue
                        }
                    }
                );
            });

Check if My Mock Got Called

Below you can see where I set a variable to true when my mock gets dynamically called so I can assert on this later.

Make my Mock read a file at runtime to return a response

In this case when my mock is called I want to read the contents of a file and return that to the workflow.


Was this article helpful?