public void CompareToArgumentException() { ExceptionAssert.Throws <ArgumentException>( delegate { SqlByte Test = new SqlByte(1); Test1.CompareTo(Test); }); }
public static void SqlStringNullComparisonTest() { SqlString nullSqlString = new SqlString(null); SqlString nonNullSqlString = new SqlString("abc "); Assert.True( (bool)(nullSqlString < nonNullSqlString || nonNullSqlString >= nullSqlString || nullSqlString.CompareTo(nonNullSqlString) < 0 || nonNullSqlString.CompareTo(nullSqlString) >= 0), "FAILED: (SqlString Null Comparison): Null SqlString not equal to null"); Assert.True((nullSqlString == null && nullSqlString.CompareTo(null) == 0).IsNull, "FAILED: (SqlString Null Comparison): Null SqlString not equal to null"); }
public static void SqlStringNullComparisonTest() { SqlString nullSqlString = new SqlString(null); SqlString nonNullSqlString = new SqlString("abc "); Assert.True( (bool)(nullSqlString < nonNullSqlString || nonNullSqlString >= nullSqlString || nullSqlString.CompareTo(nonNullSqlString) < 0 || nonNullSqlString.CompareTo(nullSqlString) >= 0), "FAILED: (SqlString Null Comparison): Null SqlString not equal to null"); Assert.True((nullSqlString == null && nullSqlString.CompareTo(null) == 0).IsNull, "FAILED: (SqlString Null Comparison): Null SqlString not equal to null"); }
// Special characters matching test for default option (SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth) private static void SqlStringDefaultCompareOptionTest(int localeID) { SqlString str1; SqlString str2; int count = s_specialMatchingString.GetLength(0); // Some of Windows versions have a regression, so ignore last entry in the s_specialMatchingString if this is the case. if (PlatformDetection.IsWindows10Version1903OrGreater && CultureInfo.InvariantCulture.CompareInfo.Compare("\u3060", "\uFF80\uFF9E", CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) != 0) { count--; } for (int i = 0; i < count; ++i) { // SqlString(string) creates instance with the default comparison options str1 = new SqlString(s_specialMatchingString[i, 0], localeID); str2 = new SqlString(s_specialMatchingString[i, 1], localeID); // Per default option, each set contains two string which should be matched as equal per default option Assert.True((bool)(str1 == str2), string.Format("Error (Default Comparison Option with Operator): {0} and {1} should be equal", s_specialMatchingString[i, 0], s_specialMatchingString[i, 1])); Assert.True(str1.CompareTo(str2) == 0, string.Format("FAILED: (Default Comparison Option with CompareTo): {0} and {1} should be equal", s_specialMatchingString[i, 0], s_specialMatchingString[i, 1])); } }
public void String_Compare_Equal() { const string s = "Test string in UTF-16 LE"; var sqlString1 = new SqlString(s); var sqlString2 = new SqlString(s); Assert.AreEqual(0, sqlString1.CompareTo(sqlString2)); }
public void CompareToSqlTypeException() { SqlString t1 = new SqlString("test", 2057, SqlCompareOptions.IgnoreCase); SqlString t2 = new SqlString("TEST", 2057, SqlCompareOptions.None); Assert.Throws <SqlTypeException>(() => t1.CompareTo(t2)); }
public void CompareToSqlTypeException() { SqlString T1 = new SqlString("test", 2057, SqlCompareOptions.IgnoreCase); SqlString T2 = new SqlString("TEST", 2057, SqlCompareOptions.None); T1.CompareTo(T2); }
/// <summary> /// Accumulate the next value, not if the value is null /// </summary> /// <param name="value"></param> public void Accumulate(SqlString value, SqlString returner) { if (_mins == null || value.CompareTo(_mins) > 0) { _mins = value.ToString(); _ret = returner.ToString(); } }
public void CompareTo() { SqlByte Test = new SqlByte(1); Assert.IsTrue(Test1.CompareTo(Test3) < 0, "#D01"); Assert.IsTrue(Test2.CompareTo(Test1) > 0, "#D02"); Assert.IsTrue(Test2.CompareTo(Test3) == 0, "#D03"); Assert.IsTrue(Test3.CompareTo(SqlString.Null) > 0, "#D04"); SqlString T1 = new SqlString("test", 2057, SqlCompareOptions.IgnoreCase); SqlString T2 = new SqlString("TEST", 2057, SqlCompareOptions.None); // IgnoreCase T1 = new SqlString("test", 2057, SqlCompareOptions.IgnoreCase); T2 = new SqlString("TEST", 2057, SqlCompareOptions.IgnoreCase); Assert.IsTrue(T2.CompareTo(T1) == 0, "#D09"); T1 = new SqlString("test", 2057); T2 = new SqlString("TEST", 2057); Assert.IsTrue(T2.CompareTo(T1) == 0, "#D10"); T1 = new SqlString("test", 2057, SqlCompareOptions.None); T2 = new SqlString("TEST", 2057, SqlCompareOptions.None); Assert.IsTrue(T2.CompareTo(T1) != 0, "#D11"); // IgnoreNonSpace T1 = new SqlString("TEST\xF1", 2057, SqlCompareOptions.IgnoreNonSpace); T2 = new SqlString("TESTn", 2057, SqlCompareOptions.IgnoreNonSpace); Assert.IsTrue(T2.CompareTo(T1) == 0, "#D12"); T1 = new SqlString("TESTñ", 2057, SqlCompareOptions.None); T2 = new SqlString("TESTn", 2057, SqlCompareOptions.None); Assert.IsTrue(T2.CompareTo(T1) != 0, "#D13"); // BinarySort T1 = new SqlString("01_", 2057, SqlCompareOptions.BinarySort); T2 = new SqlString("_01", 2057, SqlCompareOptions.BinarySort); Assert.IsTrue(T1.CompareTo(T2) < 0, "#D14"); T1 = new SqlString("01_", 2057, SqlCompareOptions.None); T2 = new SqlString("_01", 2057, SqlCompareOptions.None); Assert.IsTrue(T1.CompareTo(T2) > 0, "#D15"); }
public void CompareTo() { SqlByte Test = new SqlByte(1); Assert.True(_test1.CompareTo(_test3) < 0); Assert.True(_test2.CompareTo(_test1) > 0); Assert.True(_test2.CompareTo(_test3) == 0); Assert.True(_test3.CompareTo(SqlString.Null) > 0); SqlString T1 = new SqlString("test", 2057, SqlCompareOptions.IgnoreCase); SqlString T2 = new SqlString("TEST", 2057, SqlCompareOptions.None); // IgnoreCase T1 = new SqlString("test", 2057, SqlCompareOptions.IgnoreCase); T2 = new SqlString("TEST", 2057, SqlCompareOptions.IgnoreCase); Assert.True(T2.CompareTo(T1) == 0); T1 = new SqlString("test", 2057); T2 = new SqlString("TEST", 2057); Assert.True(T2.CompareTo(T1) == 0); T1 = new SqlString("test", 2057, SqlCompareOptions.None); T2 = new SqlString("TEST", 2057, SqlCompareOptions.None); Assert.True(T2.CompareTo(T1) != 0); // IgnoreNonSpace T1 = new SqlString("TEST\xF1", 2057, SqlCompareOptions.IgnoreNonSpace); T2 = new SqlString("TESTn", 2057, SqlCompareOptions.IgnoreNonSpace); Assert.True(T2.CompareTo(T1) == 0); T1 = new SqlString("TEST\u00F1", 2057, SqlCompareOptions.None); T2 = new SqlString("TESTn", 2057, SqlCompareOptions.None); Assert.True(T2.CompareTo(T1) != 0); // BinarySort T1 = new SqlString("01_", 2057, SqlCompareOptions.BinarySort); T2 = new SqlString("_01", 2057, SqlCompareOptions.BinarySort); Assert.True(T1.CompareTo(T2) < 0); T1 = new SqlString("01_", 2057, SqlCompareOptions.None); T2 = new SqlString("_01", 2057, SqlCompareOptions.None); Assert.True(T1.CompareTo(T2) > 0); }
public void CompareToSqlTypeException() { ExceptionAssert.Throws <SqlTypeException>( delegate { SqlString T1 = new SqlString("test", "en-GB", SqlCompareOptions.IgnoreCase); SqlString T2 = new SqlString("TEST", "en-GB", SqlCompareOptions.None); T1.CompareTo(T2); }); }
public void CompareTo() { Assert.True(_test1.CompareTo(_test3) < 0); Assert.True(_test2.CompareTo(_test1) > 0); Assert.Equal(0, _test2.CompareTo(_test3)); Assert.True(_test3.CompareTo(SqlString.Null) > 0); // IgnoreCase SqlString t1 = new SqlString("test", 2057, SqlCompareOptions.IgnoreCase); SqlString t2 = new SqlString("TEST", 2057, SqlCompareOptions.IgnoreCase); Assert.Equal(0, t2.CompareTo(t1)); t1 = new SqlString("test", 2057); t2 = new SqlString("TEST", 2057); Assert.Equal(0, t2.CompareTo(t1)); t1 = new SqlString("test", 2057, SqlCompareOptions.None); t2 = new SqlString("TEST", 2057, SqlCompareOptions.None); Assert.NotEqual(0, t2.CompareTo(t1)); // IgnoreNonSpace t1 = new SqlString("TEST\xF1", 2057, SqlCompareOptions.IgnoreNonSpace); t2 = new SqlString("TESTn", 2057, SqlCompareOptions.IgnoreNonSpace); Assert.Equal(0, t2.CompareTo(t1)); t1 = new SqlString("TEST\u00F1", 2057, SqlCompareOptions.None); t2 = new SqlString("TESTn", 2057, SqlCompareOptions.None); Assert.NotEqual(0, t2.CompareTo(t1)); // BinarySort t1 = new SqlString("01_", 2057, SqlCompareOptions.BinarySort); t2 = new SqlString("_01", 2057, SqlCompareOptions.BinarySort); Assert.True(t1.CompareTo(t2) < 0); t1 = new SqlString("01_", 2057, SqlCompareOptions.None); t2 = new SqlString("_01", 2057, SqlCompareOptions.None); Assert.True(t1.CompareTo(t2) > 0); }
// Special characters matching test for default option (SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth) private static void SqlStringDefaultCompareOptionTest(int localeID) { SqlString str1; SqlString str2; for (int i = 0; i < s_specialMatchingString.GetLength(0); ++i) { // SqlString(string) creates instance with the default comparison options str1 = new SqlString(s_specialMatchingString[i, 0], localeID); str2 = new SqlString(s_specialMatchingString[i, 1], localeID); // Per default option, each set contains two string which should be matched as equal per default option Assert.True((bool)(str1 == str2), string.Format("Error (Default Comparison Option with Operator): {0} and {1} should be equal", s_specialMatchingString[i, 0], s_specialMatchingString[i, 1])); Assert.True(str1.CompareTo(str2) == 0, string.Format("FAILED: (Default Comparison Option with CompareTo): {0} and {1} should be equal", s_specialMatchingString[i, 0], s_specialMatchingString[i, 1])); } }
private static void VerifySortedSqlStringList(SortedList <SqlString, SqlString> items, SqlCompareOptions compareOption, CultureInfo cInfo) { // // Verify the list is in order // IList <SqlString> keyList = items.Keys; for (int i = 0; i < items.Count - 1; ++i) { SqlString currentString = keyList[i]; SqlString nextString = keyList[i + 1]; Assert.True((bool)((currentString < nextString) && (nextString >= currentString)), "FAILED: (SqlString Operator Comparison): SqlStrings are out of order"); Assert.True((currentString.CompareTo(nextString) < 0) && (nextString.CompareTo(currentString) > 0), "FAILED: (SqlString.CompareTo): SqlStrings are out of order"); switch (compareOption) { case SqlCompareOptions.BinarySort: Assert.True(CompareBinary(currentString.Value, nextString.Value) < 0, "FAILED: (SqlString BinarySort Comparison): SqlStrings are out of order"); break; case SqlCompareOptions.BinarySort2: Assert.True(string.CompareOrdinal(currentString.Value.TrimEnd(), nextString.Value.TrimEnd()) < 0, "FAILED: (SqlString BinarySort2 Comparison): SqlStrings are out of order"); break; default: CompareInfo cmpInfo = cInfo.CompareInfo; CompareOptions cmpOptions = SqlString.CompareOptionsFromSqlCompareOptions(nextString.SqlCompareOptions); Assert.True(cmpInfo.Compare(currentString.Value.TrimEnd(), nextString.Value.TrimEnd(), cmpOptions) < 0, "FAILED: (SqlString Comparison): SqlStrings are out of order"); break; } } }
public void CompareToArgumentException() { SqlByte test = new SqlByte(1); AssertExtensions.Throws <ArgumentException>(null, () => _test1.CompareTo(test)); }
public void CompareToArgumentException() { SqlByte Test = new SqlByte(1); Assert.Throws <ArgumentException>(() => _test1.CompareTo(Test)); }
public void CompareToArgumentException() { SqlByte Test = new SqlByte(1); Test1.CompareTo(Test); }
// Special characters matching test for default option (SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth) private static void SqlStringDefaultCompareOptionTest(int localeID) { SqlString str1; SqlString str2; for (int i = 0; i < s_specialMatchingString.GetLength(0); ++i) { // SqlString(string) creates instance with the default comparison options str1 = new SqlString(s_specialMatchingString[i, 0], localeID); str2 = new SqlString(s_specialMatchingString[i, 1], localeID); // Per default option, each set contains two string which should be matched as equal per default option Assert.True((bool)(str1 == str2), string.Format("Error (Default Comparison Option with Operator): {0} and {1} should be equal", s_specialMatchingString[i, 0], s_specialMatchingString[i, 1])); Assert.True(str1.CompareTo(str2) == 0, string.Format("FAILED: (Default Comparison Option with CompareTo): {0} and {1} should be equal", s_specialMatchingString[i, 0], s_specialMatchingString[i, 1])); } }