Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManish Sinha <manish.sinha@xamarin.com>2015-06-24 21:58:42 +0300
committerManish Sinha <manish.sinha@xamarin.com>2015-06-25 19:06:48 +0300
commit7913f8032331ba40891db3a9ab1acf95241fbc30 (patch)
tree776dd9accc345b128d53bfdc3faf51f496d2197d /main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest
parent1c0f0d838457c8f9d37bfd8502832fc18a60eda7 (diff)
[AutoTest] Move CheckForText, GetPropertValue and MatchProperty to AppResult
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AppResult.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AppResult.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AppResult.cs
index 09d3e73410..4d6a9a4f2d 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AppResult.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.AutoTest/AppResult.cs
@@ -27,6 +27,8 @@ using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Xml;
+using System.Reflection;
+using System.Linq;
namespace MonoDevelop.Components.AutoTest
{
@@ -95,5 +97,42 @@ namespace MonoDevelop.Components.AutoTest
attr.Value = value;
element.Attributes.Append (attr);
}
+
+ protected object GetPropertyValue (string propertyName, object requestedObject)
+ {
+ return AutoTestService.CurrentSession.UnsafeSync (delegate {
+ PropertyInfo propertyInfo = requestedObject.GetType().GetProperty(propertyName,
+ BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
+ if (propertyInfo != null && propertyInfo.CanRead && !propertyInfo.GetIndexParameters ().Any ()) {
+ var propertyValue = propertyInfo.GetValue (requestedObject);
+ if (propertyValue != null) {
+ return propertyValue;
+ }
+ }
+
+ return null;
+ });
+ }
+
+ protected AppResult MatchProperty (string propertyName, object objectToCompare, object value)
+ {
+ foreach (var singleProperty in propertyName.Split (new [] { '.' })) {
+ objectToCompare = GetPropertyValue (singleProperty, objectToCompare);
+ }
+ if (objectToCompare != null && value != null &&
+ CheckForText (objectToCompare.ToString (), value.ToString (), false)) {
+ return this;
+ }
+ return null;
+ }
+
+ protected bool CheckForText (string haystack, string needle, bool exact)
+ {
+ if (exact) {
+ return haystack == needle;
+ } else {
+ return (haystack.IndexOf (needle, StringComparison.Ordinal) > -1);
+ }
+ }
}
} \ No newline at end of file