public void ConstuctorWithStringEmpty()
        {
            var comparer = new StringEqualsAndCaseInsensitiveComparer(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");
        }
        public void ConstructorWithValue()
        {
            var comparer = new StringEqualsAndCaseInsensitiveComparer("A test value");

            Assert.IsTrue(comparer.Compare("A test value"), "Exact match should pass.");
            Assert.IsTrue(comparer.Compare("a test Value"), "Match should be case insensitive");

            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");
        }
Exemplo n.º 3
0
        public static void SelectByTextOrValue(this SelectList selectList, string option)
        {
            var comparer   = new StringEqualsAndCaseInsensitiveComparer(option);
            var constraint = Find.ByText(comparer) | Find.ByValue(comparer);

            if (selectList.Multiple)
            {
                selectList.SelectByTextOrValueMultiple(constraint);
            }
            else
            {
                selectList.SelectByTextOrValueSingle(constraint);
            }
        }
        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;

                StringEqualsAndCaseInsensitiveComparer comparer = new StringEqualsAndCaseInsensitiveComparer("I");
                Assert.That(comparer.Compare("i"), Is.True);
            }
            finally
            {
                // Set the culture back to the original
                Thread.CurrentThread.CurrentCulture = thisCulture;
            }
        }
        public void ToStringShouldDescribeTheCondition()
        {
            var comparer = new StringEqualsAndCaseInsensitiveComparer("A test value");

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