Condividi tramite


Proprietà PostWebTestEventArgs.WebTest

Ottiene l'oggetto WebTest che ha completato e causato l'evento PostWebTest.

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

Sintassi

'Dichiarazione
Public ReadOnly Property WebTest As WebTest
    Get
public WebTest WebTest { get; }
public:
property WebTest^ WebTest {
    WebTest^ get ();
}
member WebTest : WebTest
function get WebTest () : WebTest

Valore proprietà

Tipo: Microsoft.VisualStudio.TestTools.WebTesting.WebTest
Un oggetto WebTest.

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 il modo in qui questa proprietà fornisce un riferimento all'oggetto 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());
        }
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

PostWebTestEventArgs Classe

Spazio dei nomi Microsoft.VisualStudio.TestTools.WebTesting