WebServicePostRecording.cs
2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//*************************************************************************************************
// WebServicePostRecording.cs
// Owner: Mahipal Kante
//
// WebTestRecorderPlugin Implementation:
// Web Test Plugin for adding references to the other Web Service plugins
// (Extraction/Validation rules etc) to the WebTest after completing recording.
// This gets executed if user selects the plugin in the dialog that gets displayed
// before a record session.
//
// Copyright(c) Microsoft Corporation, 2010
//*************************************************************************************************
using System.ComponentModel;
using Microsoft.VisualStudio.TestTools.WebTesting;
using System.Diagnostics.CodeAnalysis;
using WebTest.WebService.Plugin.ResultTab;
using WebTest.WebService.Plugin.Runtime;
namespace WebTest.WebService.Plugin.MessageEditors
{
[DisplayName("Plugin for Web Service Messages")]
[Description("XPath extraction/validation rules that extract data from Web Service responses for various content types")]
class WebServicePostRecording : WebTestRecorderPlugin
{
/// <summary>
/// Parameters:
/// sender:
/// The source of the event.
///
/// e:
/// A Microsoft.VisualStudio.TestTools.WebTesting.PostWebTestRecordingEventArgs
/// that contains the event data.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")]
public override void PostWebTestDynamicParameterDetection(object sender, PostWebTestRecordingEventArgs e)
{
Connect connect = Connect.GetInstance();
if (connect != null)
{
connect.AddWebTestRecording(e.RecordedWebTest);
}
bool pluginFound = false;
foreach (WebTestPluginReference pluginReference1 in e.RecordedWebTest.WebTestPluginReferences)
{
if (pluginReference1.Type.ToString().Equals(typeof(WebServicePlugin).ToString()))
{
pluginFound = true;
break;
}
}
if (!pluginFound)
{
WebTestPluginReference pluginReference = new WebTestPluginReference();
pluginReference.Type = typeof(WebServicePlugin);
e.RecordedWebTest.WebTestPluginReferences.Add(pluginReference);
}
// Mark it as modified
e.RecordedWebTestModified = true;
}
}
}