示例#1
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");
		}
示例#2
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");
        }
示例#3
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");
		}
示例#4
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");
        }
示例#5
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;
            }
        }
示例#6
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;
            }
        }