Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

PostWebTestEventArgs Class

Provides data for the PostWebTest event.

Namespace: Microsoft.VisualStudio.TestTools.WebTesting
Assembly: Microsoft.VisualStudio.QualityTools.WebTestFramework (in microsoft.visualstudio.qualitytools.webtestframework.dll)

public class PostWebTestEventArgs : EventArgs
public class PostWebTestEventArgs extends EventArgs
public class PostWebTestEventArgs extends EventArgs

This specifically provides a reference to the WebTest that invoked the PostWebTest event.

The following example shows a Web test plug-in that adds a random number to the context before the Web test is run and displays the length of the last WebTestResponse after the Web test has run.

Note the use of the PostWebTestEventArgs in providing a reference to the 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, PostWebTestEventArgse)
        {
            MessageBox.Show(e.WebTest.LastResponse.ContentLength.ToString());
        }
    }
}

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2015 Microsoft