PreWebTestEventArgs.WebTest 속성
시작하여 PreWebTest 이벤트를 발생시키려는 WebTest 개체를 가져옵니다.
네임스페이스: Microsoft.VisualStudio.TestTools.WebTesting
어셈블리: Microsoft.VisualStudio.QualityTools.WebTestFramework(Microsoft.VisualStudio.QualityTools.WebTestFramework.dll)
구문
‘선언
Public ReadOnly Property WebTest As WebTest
public WebTest WebTest { get; }
public:
property WebTest^ WebTest {
WebTest^ get ();
}
member WebTest : WebTest with get
function get WebTest () : WebTest
속성 값
형식: Microsoft.VisualStudio.TestTools.WebTesting.WebTest
WebTest 개체
예제
다음은 웹 성능 테스트를 실행하기 전에 임의의 숫자를 컨텍스트에 추가하는 웹 성능 테스트 플러그 인을 보여 주는 예제입니다. 웹 성능 테스트를 실행한 후에 이 플러그 인은 마지막 WebTestResponse의 길이를 표시합니다.
이 속성으로 WebTest에 대한 참조를 제공하는 방법에 주의하십시오.
using System;
using Microsoft.VisualStudio.TestTools.WebTesting;
using System.Windows.Forms;
namespace WebTestPluginNamespace
{
public class MyWebTestPlugin : WebTestPlugin
{
public static string NewRandomNumberString(int size)
{
byte[] buffer = new byte[size];
// Seed using system time
Random random = new Random(unchecked((int)DateTime.Now.Ticks));
random.NextBytes(buffer);
return BitConverter.ToInt32(buffer, 0).ToString();
}
public override void PreWebTest(object sender, PreWebTestEventArgs e)
{
e.WebTest.Context["RandNum"] = NewRandomNumberString(4);
}
public override void PostWebTest(object sender, PostWebTestEventArgs e)
{
MessageBox.Show(e.WebTest.LastResponse.ContentLength.ToString());
}
}
}
.NET Framework 보안
- 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용를 참조하세요.