다음을 통해 공유


PreWebTestEventArgs 클래스

WebTest.PreWebTest 이벤트에 대한 데이터를 제공합니다.

상속 계층 구조

System.Object
  System.EventArgs
    Microsoft.VisualStudio.TestTools.WebTesting.PreWebTestEventArgs

네임스페이스:  Microsoft.VisualStudio.TestTools.WebTesting
어셈블리:  Microsoft.VisualStudio.QualityTools.WebTestFramework(Microsoft.VisualStudio.QualityTools.WebTestFramework.dll)

구문

‘선언
Public Class PreWebTestEventArgs _
    Inherits EventArgs
public class PreWebTestEventArgs : EventArgs
public ref class PreWebTestEventArgs : public EventArgs
type PreWebTestEventArgs =  
    class
        inherit EventArgs
    end
public class PreWebTestEventArgs extends EventArgs

PreWebTestEventArgs 형식에서는 다음과 같은 멤버를 노출합니다.

속성

  이름 설명
Public 속성 WebTest 시작하여 PreWebTest 이벤트를 발생시키려는 WebTest 개체를 가져옵니다.

위쪽

메서드

  이름 설명
Public 메서드 Equals 지정한 Object가 현재 Object와 같은지 여부를 확인합니다. (Object에서 상속됨)
Protected 메서드 Finalize 가비지 수집에서 회수하기 전에 개체에서 리소스를 해제하고 다른 정리 작업을 수행할 수 있게 합니다. (Object에서 상속됨)
Public 메서드 GetHashCode 특정 형식에 대한 해시 함수 역할을 합니다. (Object에서 상속됨)
Public 메서드 GetType 현재 인스턴스의 Type을 가져옵니다. (Object에서 상속됨)
Protected 메서드 MemberwiseClone 현재 Object의 단순 복사본을 만듭니다. (Object에서 상속됨)
Public 메서드 ToString 현재 개체를 나타내는 문자열을 반환합니다. (Object에서 상속됨)

위쪽

설명

이는 특히 PreWebTest 이벤트를 호출한 WebTest에 대한 참조를 제공합니다.

예제

다음은 웹 성능 테스트를 실행하기 전에 임의의 숫자를 컨텍스트에 추가하는 웹 성능 테스트 플러그 인을 보여 주는 예제입니다. 웹 성능 테스트를 실행한 후에 이 플러그 인은 마지막 WebTestResponse의 길이를 표시합니다.

WebTest에 대한 참조를 제공하는 데 PreWebTestEventArgs가 사용되고 있습니다.

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());
        }
    }
}

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

참고 항목

참조

Microsoft.VisualStudio.TestTools.WebTesting 네임스페이스

기타 리소스

Working with Web Tests