Condividi tramite


Classe PostWebTestEventArgs

Fornisce dati per l'evento WebTest.PostWebTest.

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 l'oggetto WebTest che ha completato e causato l'evento PostWebTest.

In alto

Metodi

  Nome Descrizione
Metodo pubblico Equals Determina se l'oggetto Object specificato è uguale all'oggetto Object 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

Fornisce in modo specifico un riferimento alla classe WebTest che ha richiamato l'evento PostWebTest.

Esempi

Nell'esempio riportato di seguito viene illustrato un plug-in del test delle prestazioni Web che aggiunge un numero casuale al contesto prima dell'esecuzione del test delle prestazioni Web e visualizza la lunghezza dell'ultimo oggetto WebTestResponse al termine dell'esecuzione del test delle prestazioni Web.

Si noti l'utilizzo della classe PostWebTestEventArgs nel fornire un riferimento alla classe 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