示例#1
0
        /// <summary>
        /// Gets the value for the given <paramref name="attributename" />
        /// </summary>
        /// <param name="attributename">The attributename.</param>
        /// <returns>The value of the attribute</returns>
        public string GetValue(string attributename)
        {
            if (StringComparer.AreEqual(attributename, "style", true))
            {
                return(_htmlElement.style.cssText);
            }

            object attributeValue;

            if (attributename.ToLower(CultureInfo.InvariantCulture).StartsWith("style."))
            {
                attributeValue = Style.GetAttributeValue(attributename.Substring(6), _htmlElement.style);
            }
            else
            {
                attributeValue = _htmlElement.getAttribute(attributename, 0);
            }

            if (attributeValue == DBNull.Value || attributeValue == null)
            {
                return(null);
            }

            return(attributeValue.ToString());
        }
示例#2
0
        public string GetValue(string attributename)
        {
            string value = null;

            if (StringComparer.AreEqual(attributename, "href", true))
            {
                try
                {
                    value = Url;
                }
                catch {}
            }
            else if (StringComparer.AreEqual(attributename, "title", true))
            {
                try
                {
                    value = Title;
                }
                catch {}
            }
            else
            {
                throw new InvalidAttributException(attributename, "HTMLDialog");
            }

            return(value);
        }
示例#3
0
        public void TestsStaticCompare()
        {
            Assert.That(StringComparer.AreEqual("WatiN", "WatiN"), Is.True);
            Assert.That(StringComparer.AreEqual("WatiN", "watin"), Is.False);

            Assert.That(StringComparer.AreEqual("WatiN", "WatiN", true), Is.True);
            Assert.That(StringComparer.AreEqual("WatiN", "watin", true), Is.True);
        }
示例#4
0
		public void ConstuctorWithStringEmpty()
		{
			var comparer = new StringComparer(String.Empty);

			Assert.IsTrue(comparer.Compare(String.Empty), "String.Empty should match");

			Assert.IsFalse(comparer.Compare(" "), "None Empty string should not match");
			Assert.IsFalse(comparer.Compare(null), "null should not match");
		}
        private static bool FindByExactMatchOnIdPossible(BaseConstraint constraint)
        {
            Constraints.AttributeConstraint attributeConstraint = constraint as AttributeConstraint;

            return(attributeConstraint != null &&
                   StringComparer.AreEqual(attributeConstraint.AttributeName, "id", true) &&
                   !(constraint.HasAnd || constraint.HasOr) &&
                   attributeConstraint.Comparer.GetType() == typeof(StringComparer));
        }
示例#6
0
        public void ToStringShouldDescribeTheCondition()
        {
            var comparer = new StringComparer("A test value");

            Assert.AreEqual("equals 'A test value'", comparer.ToString());

            comparer = new StringComparer("A test value", true);
            Assert.AreEqual("equals 'A test value' ignoring case", comparer.ToString());
        }
示例#7
0
        public void ConstuctorWithStringEmpty()
        {
            var comparer = new StringComparer(String.Empty);

            Assert.IsTrue(comparer.Compare(String.Empty), "String.Empty should match");

            Assert.IsFalse(comparer.Compare(" "), "None Empty string should not match");
            Assert.IsFalse(comparer.Compare(null), "null should not match");
        }
        private bool CompareTagName(INativeElement nativeElement)
        {
            if (TagName == null)
            {
                return(true);
            }

            return(StringComparer.AreEqual(TagName, nativeElement.TagName, true));
        }
示例#9
0
		public void ConstructorWithValue()
		{
			var comparer = new StringComparer("A test value");

			Assert.IsTrue(comparer.Compare("A test value"), "Exact match should pass.");

			Assert.IsFalse(comparer.Compare("a test Value"), "Match should be case sensitive");
			Assert.IsFalse(comparer.Compare("A test value 2"), "Exact match plus more should not pass.");
			Assert.IsFalse(comparer.Compare("test"), "Partial match should not match");
			Assert.IsFalse(comparer.Compare("completely different"), "Something completely different should not match");
			Assert.IsFalse(comparer.Compare(String.Empty), "String.Empty should not match");
			Assert.IsFalse(comparer.Compare(null), "null should not match");
		}
示例#10
0
        public void ConstructorWithValue()
        {
            var comparer = new StringComparer("A test value");

            Assert.IsTrue(comparer.Compare("A test value"), "Exact match should pass.");

            Assert.IsFalse(comparer.Compare("a test Value"), "Match should be case sensitive");
            Assert.IsFalse(comparer.Compare("A test value 2"), "Exact match plus more should not pass.");
            Assert.IsFalse(comparer.Compare("test"), "Partial match should not match");
            Assert.IsFalse(comparer.Compare("completely different"), "Something completely different should not match");
            Assert.IsFalse(comparer.Compare(String.Empty), "String.Empty should not match");
            Assert.IsFalse(comparer.Compare(null), "null should not match");
        }
        private IHTMLElement2 GetFrameElement(string tagname)
        {
            IHTMLElementCollection elements = _frameSetParent.getElementsByTagName(tagname);

            foreach (DispHTMLBaseElement element in elements)
            {
                if (StringComparer.AreEqual(element.uniqueID, _frameElementUniqueId, true))
                {
                    return((IHTMLElement2)element);
                }
            }
            return(null);
        }
        /// <inheritdoc />
        protected override string GetAttributeValueImpl(string attributeName)
        {
            string value = null;

            if (StringComparer.AreEqual(attributeName, "href", true))
            {
                UtilityClass.TryActionIgnoreException(() => value = Url);
            }
            else if (StringComparer.AreEqual(attributeName, "title", true))
            {
                UtilityClass.TryActionIgnoreException(() => value = Title);
            }
            else
            {
                throw new InvalidAttributeException(attributeName, "HTMLDialog");
            }

            return(value);
        }
示例#13
0
        public void CompareShouldBeCultureInvariant()
        {
            // Get the tr-TR (Turkish-Turkey) culture.
            CultureInfo turkish = new CultureInfo("tr-TR");

            // Get the culture that is associated with the current thread.
            CultureInfo thisCulture = Thread.CurrentThread.CurrentCulture;

            try
            {
                // Set the culture to Turkish
                Thread.CurrentThread.CurrentCulture = turkish;

                StringComparer comparer = new StringComparer("I", true);
                Assert.That(comparer.Compare("i"), Is.True);

                Assert.That(StringComparer.AreEqual("I", "i", true), Is.True);
            }
            finally
            {
                // Set the culture back to the original
                Thread.CurrentThread.CurrentCulture = thisCulture;
            }
        }
示例#14
0
        public void CompareShouldBeCultureInvariant()
        {
            // Get the tr-TR (Turkish-Turkey) culture.
            CultureInfo turkish = new CultureInfo("tr-TR");

            // Get the culture that is associated with the current thread.
            CultureInfo thisCulture = Thread.CurrentThread.CurrentCulture;

            try
            {
                // Set the culture to Turkish
                Thread.CurrentThread.CurrentCulture = turkish;

                StringComparer comparer = new StringComparer("I", true);
                Assert.That(comparer.Compare("i"), Is.True);

                Assert.That(StringComparer.AreEqual("I", "i", true), Is.True);
            }
            finally
            {
                // Set the culture back to the original
                Thread.CurrentThread.CurrentCulture = thisCulture;
            }
        }
示例#15
0
        public void ToStringShouldDescribeTheCondition()
        {
            var comparer = new StringComparer("A test value");
            Assert.AreEqual("equals 'A test value'", comparer.ToString());

            comparer = new StringComparer("A test value", true);
            Assert.AreEqual("equals 'A test value' ignoring case", comparer.ToString());
        }
 public static bool IsAnInputElement(string tagName)
 {
     return(StringComparer.AreEqual(tagName, ElementsSupport.InputTagName, true));
 }