コード例 #1
0
        public void TestAbcComparerGetHashCode()
        {
            var abcComparer = new AbcComparer();
            var hc1         = abcComparer.GetHashCode("abc123");

            Assert.Equal(hc1, abcComparer.GetHashCode("abc123"));
            Assert.Equal(hc1, abcComparer.GetHashCode("__abc123!! --§"));
            Assert.NotEqual(hc1, abcComparer.GetHashCode("bcd123"));
        }
コード例 #2
0
        public void TestAbcComparerCompare()
        {
            var abcComparer = new AbcComparer();

            Assert.True(abcComparer.Compare("abc123", "__AbC_123!") == 0);
            Assert.True(abcComparer.Compare(null, null) == 0);
            Assert.True(abcComparer.Compare("abc123", "bcd123") < 0);
            Assert.True(abcComparer.Compare(null, "bcd123") < 0);
            Assert.True(abcComparer.Compare("bcd123", "abc123") > 0);
            Assert.True(abcComparer.Compare("bcd123", null) > 0);
        }
コード例 #3
0
        /// <summary>
        ///     Check if 2 strings are equal if both are made ToLower and all non alpha and digits are removed.
        /// </summary>
        /// <param name="value1"></param>
        /// <param name="value2"></param>
        /// <returns>true if they are 'equal'</returns>
        public static bool NonStrictEquals(this string value1, string value2)
        {
            var abcComparer = new AbcComparer();

            return(abcComparer.Equals(value1, value2));
        }