Condividi tramite


Classe PostWebTestEventArgs

fornisce i dati per WebTest.PostWebTest evento.

Gerarchia di ereditarietà

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

Spazio dei nomi:  Microsoft.VisualStudio.TestTools.WebTesting
Assembly:  Microsoft.VisualStudio.QualityTools.WebTestFramework (in Microsoft.VisualStudio.QualityTools.WebTestFramework.dll)

Sintassi

'Dichiarazione
Public Class PostWebTestEventArgs _
    Inherits EventArgs
public class PostWebTestEventArgs : EventArgs
public ref class PostWebTestEventArgs : public EventArgs
type PostWebTestEventArgs =  
    class
        inherit EventArgs
    end
public class PostWebTestEventArgs extends EventArgs

Il tipo PostWebTestEventArgs espone i seguenti membri.

Proprietà

  Nome Descrizione
Proprietà pubblica WebTest ottiene WebTest l'oggetto che completato e causato PostWebTest evento.

In alto

Metodi

  Nome Descrizione
Metodo pubblico Equals Determina se l'oggetto specificato equivale all'oggetto corrente. (Ereditato da Object)
Metodo protetto Finalize Consente a un oggetto di provare a liberare risorse ed eseguire altre operazioni di pulitura prima che l'oggetto stesso venga recuperato dalla procedura di Garbage Collection. (Ereditato da Object)
Metodo pubblico GetHashCode Funge da funzione hash per un determinato tipo. (Ereditato da Object)
Metodo pubblico GetType Ottiene l'oggetto Type dell'istanza corrente. (Ereditato da Object)
Metodo protetto MemberwiseClone Consente di creare una copia dei riferimenti dell'oggetto Object corrente. (Ereditato da Object)
Metodo pubblico ToString Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object)

In alto

Note

Ciò specificamente fornisce un riferimento a WebTest ciò ha richiamato PostWebTest evento.

Esempi

Nell'esempio seguente viene illustrato un plug-in test Web che aggiunge un numero casuale al contesto prima che il test delle prestazioni Web sia eseguita e restituisce la lunghezza del piena WebTestResponse dopo il test Web è in esecuzione.

Si noti l'utilizzo di PostWebTestEventArgs nella specifica di un riferimento a 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());
        }
    }
}

Codice thread safe

Qualsiasi membro static (Shared in Visual Basic) pubblico di questo tipo è thread-safe. I membri di istanza non sono garantiti come thread-safe.

Vedere anche

Riferimenti

Spazio dei nomi Microsoft.VisualStudio.TestTools.WebTesting

Altre risorse

Working with Web Tests