-1

我有两个类,但我想从 LastFridayDate 类到 Buildversion 类的值字符串“版本”。

大家好,我有两个类,但我想从 LastFridayDate 类到 Buildversion 类的值字符串“版本”。

我无法访问字符串版本,有人提供任何帮助。

我的代码:

using System;
using Microsoft.VisualStudio.TestTools.WebTesting;
using Microsoft.VisualStudio.TestTools.LoadTesting;
using System.ComponentModel;
namespace PTUtil
{

    [System.ComponentModel.DisplayName("GetVersion")]
    [System.ComponentModel.Description("Get the Build No Version")]
    public class LastFridayDate : WebTestPlugin
    {
        String version;

        //Setting the version in the usercontext
        public override void PostWebTest(object sender, PostWebTestEventArgs e)
        {
            version = e.WebTest.Context["Param_ClientSoftwareVersion"].ToString();
        }

    }

    /// Specify a name for use in the user interface.
    /// The user sees this name in the Add Validation dialog box.
    [DisplayName("Build Version Processing")]
    /// Specify a description for use in the user interface
    /// The user sees this description in the Add Validation dialog box.
    [Description("Add the build version for a load test")]
    public class BuildVersion : ILoadTestPlugin
    {
        [DisplayName("Comment")]
        [Description("What the plugin is for")]
        public string theComment { get; set; }

        [DisplayName("Test Type")]
        [Description("M for Manual or A for Automatic")]
        [DefaultValue("A")]
        public string connectionStr { get; set; }

        [DisplayName("Version Context Parameter")]
        [Description("The Context Parameter for the build version")]
        [DefaultValue("{{Param_ClientSoftwareVersion}}")]
        public string Version_param { get; set; }

        LoadTest m_loadTest;

        public void Initialize(LoadTest loadTest)
        {
            m_loadTest = loadTest;

            m_loadTest.LoadTestFinished += new EventHandler(m_loadTest_LoadTestFinished);
        }

        // Do it *after* the Load Test.
        //---------------------------------------------------------------------

        void m_loadTest_LoadTestFinished(object sender, System.EventArgs e)
        {

        }
    }

}
4

1 回答 1

0

您需要将其公开,我建议您使用属性并在某处对其进行初始化。就像在构造函数或自动初始化中一样。

public string Version {get; set; } = String.Empty
于 2017-09-29T13:13:03.317 回答