Commit eded3007 eded30077c697b3f7846961b1ac6f67d3eb325ee by Mårten Nilson

Lagt till response URL validerare

git-tfs-id: [https://tfs.rsv.se/tfs/LoadTestCollection]$/VSTT-Plugins;C1338
1 parent c6aec8c3
......@@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.WebTesting;
using System.ComponentModel;
using System.Text.RegularExpressions;
namespace LIL_VSTT_Plugins
{
......@@ -37,4 +38,41 @@ namespace LIL_VSTT_Plugins
}
}
}
}
[DisplayName("Validate Response URL")]
[Description("(C) Mårten\r\nValiderar att en Response URL har ett visst värde eller inte.")]
public class ValidateResponseURL : ValidationRule
{
Regex rxRegExp = null;
[DisplayName("Regular expression"), DefaultValue(""), Description("Uttrycket som ska matcha Response URL")]
public string strRegExp { get; set; }
[DisplayName("Pass if found"), DefaultValue(false), Description("Om uttrycket matchar ska testet failas eller inte?")]
public bool boolPassIfFound { get; set; }
public override void Validate(object sender, ValidationEventArgs e)
{
e.IsValid = false;
e.Message = "Default triggades. False! Check the code!!";
if (rxRegExp == null)
{
rxRegExp = new Regex(strRegExp);
}
if (rxRegExp.IsMatch(e.Response.ResponseUri.AbsoluteUri))
{
e.IsValid = boolPassIfFound;
e.Message = "" + e.Response.ResponseUri.AbsoluteUri + " matchade uttrycket!";
}
else
{
e.IsValid = !boolPassIfFound;
e.Message = "" + e.Response.ResponseUri.AbsoluteUri + " matchade inte uttrycket!";
}
}
}
}
......