Created
October 5, 2012 18:35
-
-
Save tysonstewart/3841578 to your computer and use it in GitHub Desktop.
Example of data source plugin for Visual Studio Webtests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel; | |
using Hudl.WebApp.Tests.TestsCore.DataSources; | |
using Microsoft.VisualStudio.TestTools.WebTesting; | |
namespace Hudl.WebApp.Tests.TestsCore.Plugins | |
{ | |
[DisplayName("Annotations DataSource")] | |
[Description("Reads Annotation IDs from the context and assigns values to context parameters.")] | |
public class AnnotationsDataSourcePlugin : WebTestPlugin | |
{ | |
[DisplayName("DataSource Context Parameter Name")] | |
[Description("The name of the context parameter which holds the DataSource object.")] | |
[DefaultValue("AnnotationsDataSource")] | |
public string DataSourceContextParameterName { get; set; } | |
[DisplayName("AnnotationId Context Parameter Name")] | |
[Description("The name of the context parameter which will be assigned the annotation ID value.")] | |
[DefaultValue("AnnotationId")] | |
public string AnnotationIdContextParameterName { get; set; } | |
public override void PreWebTest(object sender, PreWebTestEventArgs e) | |
{ | |
base.PreWebTest(sender, e); | |
var webTextContext = e.WebTest.Context; | |
var annotationsDataSource = webTextContext[DataSourceContextParameterName] as IDataSource<long>; | |
var annotationId = annotationsDataSource.GetNext(); | |
webTextContext[AnnotationIdContextParameterName] = annotationId; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment