WebTest - 如何更改上下文参数的大小写? [英] WebTest - How to change case of a context parameter?

查看:46
本文介绍了WebTest - 如何更改上下文参数的大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应由Application Insights作为多步可用性测试运行的webtest中,我需要确保上下文参数的内容为小写,然后在标题中发送其值。

这可能吗?

In a webtest that should run by Application Insights as a multistep availability test, I need to ensure the content of a context parameter is lowercase, before sending its value in a header.
Is this possible?

推荐答案

基于以下(未经测试的)代码的插件应该是做你想做的事。在提取值的请求上添加一个对它的调用。  

A plugin based on the (untested) code below should do what is wanted. Add a call of it on the request that extracts the value.  

    public class ConvertCpToLowerCase : WebTestRequestPlugin
    {
        public string Cp { get; set; }

        public override void PostRequest(object sender, PostRequestEventArgs e)
        {
            string inputText = e.WebTest.Context[Cp].ToString();
            string outputText = inputText.ToLower();

            e.WebTest.Context[Cp] = outputText;

            e.WebTest.AddCommentToResult(string.Format("Converted CP '{0}' containing '{1}' to lowercase", Cp, inputText));
        }
    }

如果您需要保留上下文参数的原始值,那么只需添加另一个'public string'属性并根据需要修改'e.WebTest.Context [Cp] = outputText;'行。

If you need to keep the original value of the context parameter then just add another 'public string' property and modify the 'e.WebTest.Context[Cp] = outputText;' line as needed.

问候

Adrian


这篇关于WebTest - 如何更改上下文参数的大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆