public void IsLessThan() { CompareAssert.IsLessThan(4, 7); CompareAssert.IsLessThan("B", "a", StringComparer.Ordinal, "\"B\" should be less than \"a\" for case-sensitive ordinal comparison."); ExceptionAssert.ThrowsAssertFailed( () => CompareAssert.IsLessThan("B", "a", StringComparer.OrdinalIgnoreCase), "\"B\" should not be less than \"a\" for case-insensitive ordinal comparison."); ExceptionAssert.ThrowsAssertFailed( () => CompareAssert.IsLessThan("B", "b", StringComparer.OrdinalIgnoreCase), "\"B\" should not be less than \"b\" for case-insensitive ordinal comparison."); CompareAssert.IsLessThan(null, "x"); ExceptionAssert.ThrowsAssertFailed( () => CompareAssert.IsLessThan("x", null), "\"x\" should not be less than (null)."); ExceptionAssert.ThrowsAssertFailed( () => CompareAssert.IsLessThan <string>(null, null), "(null) should not be less than (null)."); }
public void Compare_Nulls() { var comparer = KeyComparer.Create((City city) => city.Name); CompareAssert.IsLessThan(null, athens, comparer); CompareAssert.IsEqualTo(null, null, comparer); CompareAssert.IsGreaterThan(athens, null, comparer); }
public void Compare_String() { var comparer = new OrdinalStringComparer(); CompareAssert.IsEqualTo(null, null, comparer); CompareAssert.IsLessThan(null, "abc", comparer); CompareAssert.IsGreaterThan("abc", null, comparer); CompareAssert.IsEqualTo("abc", "abc", comparer); CompareAssert.IsLessThan("abc", "xyz", comparer); CompareAssert.IsGreaterThan("abc", "a", comparer); }
public void Compare_NullableInt() { var comparer = new NullableIntComparer(); CompareAssert.IsEqualTo(null, null, comparer); CompareAssert.IsLessThan(null, 4, comparer); CompareAssert.IsGreaterThan(4, null, comparer); CompareAssert.IsEqualTo(4, 4, comparer); CompareAssert.IsLessThan(4, 7, comparer); CompareAssert.IsGreaterThan(4, 2, comparer); }
public void Compare_Nulls() { var x = new[] { "Madrid", "Añasco" }; foreach (var comparisonType in EnumUtility.GetValues <SequenceComparison>()) { var comparer = SequenceComparer.Create <string>(comparisonType); CompareAssert.IsLessThan(null, x, comparer); CompareAssert.IsEqualTo(null, null, comparer); CompareAssert.IsGreaterThan(x, null, comparer); } }
public void Compare() { using (new CultureSwapper(PredefinedCulture.EnglishUnitedStates)) { var message = "'ñ' should be less than 't' for default comparison (current culture, en-US)."; var comparer = KeyComparer.Create((City city) => city.Name); CompareAssert.IsLessThan(añasco, athens, comparer, message); CompareAssert.IsEqualTo(añasco, añasco, comparer); CompareAssert.IsGreaterThan(athens, añasco, comparer, message); message = "'ñ' should greater less than 't' for ordinal comparison."; comparer = KeyComparer.Create((City city) => city.Name, StringComparer.Ordinal); CompareAssert.IsGreaterThan(añasco, athens, comparer, message); CompareAssert.IsEqualTo(añasco, añasco, comparer); CompareAssert.IsLessThan(athens, añasco, comparer, message); } }
public void Compare_Shortlex_Enumerables() { var comparer = SequenceComparer <int> .Shortlex; CompareAssert.IsEqualTo(Enumerable.Empty <int>(), Enumerable.Empty <int>(), comparer); CompareAssert.IsLessThan(Enumerable.Empty <int>(), EnumerableUtility.Yield(42), comparer); CompareAssert.IsGreaterThan(EnumerableUtility.Yield(59), Enumerable.Empty <int>(), comparer); CompareAssert.IsGreaterThan(EnumerableUtility.Yield(59), EnumerableUtility.Yield(42), comparer); CompareAssert.IsLessThan(EnumerableUtility.Yield(59), EnumerableUtility.Yield(42, 98), comparer); CompareAssert.IsLessThan(EnumerableUtility.Yield(59), EnumerableUtility.Yield(42, 98, 11), comparer); CompareAssert.IsLessThan(EnumerableUtility.Yield(59, 23), EnumerableUtility.Yield(42, 98, 11), comparer); CompareAssert.IsGreaterThan(EnumerableUtility.Yield(59, 23, 34), EnumerableUtility.Yield(42, 98, 11), comparer); CompareAssert.IsGreaterThan(EnumerableUtility.Yield(59, 23, 34, 16), EnumerableUtility.Yield(42, 98, 11), comparer); CompareAssert.IsGreaterThan(EnumerableUtility.Yield(59, 23, 34, 16), EnumerableUtility.Yield(59, 98, 11), comparer); CompareAssert.IsGreaterThan(EnumerableUtility.Yield(59, 23, 34, 16), EnumerableUtility.Yield(59, 23, 11), comparer); CompareAssert.IsGreaterThan(EnumerableUtility.Yield(59, 23, 34, 16), EnumerableUtility.Yield(59, 23, 34), comparer); CompareAssert.IsEqualTo(EnumerableUtility.Yield(59, 23, 34, 16), EnumerableUtility.Yield(59, 23, 34, 16), comparer); CompareAssert.IsLessThan(EnumerableUtility.Yield(59, 23, 34, 16), EnumerableUtility.Yield(59, 23, 34, 16, 65), comparer); }
public void Compare_Shortlex_Arrays() { var comparer = SequenceComparer <int> .Shortlex; CompareAssert.IsEqualTo(new int[] { }, new int[] { }, comparer); CompareAssert.IsLessThan(new int[] { }, new int[] { 42 }, comparer); CompareAssert.IsGreaterThan(new int[] { 59 }, new int[] { }, comparer); CompareAssert.IsGreaterThan(new int[] { 59 }, new int[] { 42 }, comparer); CompareAssert.IsLessThan(new int[] { 59 }, new int[] { 42, 98 }, comparer); CompareAssert.IsLessThan(new int[] { 59 }, new int[] { 42, 98, 11 }, comparer); CompareAssert.IsLessThan(new int[] { 59, 23 }, new int[] { 42, 98, 11 }, comparer); CompareAssert.IsGreaterThan(new int[] { 59, 23, 34 }, new int[] { 42, 98, 11 }, comparer); CompareAssert.IsGreaterThan(new int[] { 59, 23, 34, 16 }, new int[] { 42, 98, 11 }, comparer); CompareAssert.IsGreaterThan(new int[] { 59, 23, 34, 16 }, new int[] { 59, 98, 11 }, comparer); CompareAssert.IsGreaterThan(new int[] { 59, 23, 34, 16 }, new int[] { 59, 23, 11 }, comparer); CompareAssert.IsGreaterThan(new int[] { 59, 23, 34, 16 }, new int[] { 59, 23, 34 }, comparer); CompareAssert.IsEqualTo(new int[] { 59, 23, 34, 16 }, new int[] { 59, 23, 34, 16 }, comparer); CompareAssert.IsLessThan(new int[] { 59, 23, 34, 16 }, new int[] { 59, 23, 34, 16, 65 }, comparer); }
public void Compare_Strings() { var x = new[] { "Madrid", "Añasco" }; var y = new[] { "Madrid", "Athens" }; using (new CultureSwapper(PredefinedCulture.EnglishUnitedStates)) { foreach (var comparisonType in EnumUtility.GetValues <SequenceComparison>()) { var message = "'ñ' should be less than 't' for default comparison (current culture, en-US)."; var comparer = SequenceComparer.Create <string>(comparisonType); CompareAssert.IsLessThan(x, y, comparer, message); CompareAssert.IsEqualTo(x, x, comparer); CompareAssert.IsGreaterThan(y, x, comparer, message); message = "'ñ' should be greater than 't' for ordinal comparison."; comparer = SequenceComparer.Create(comparisonType, StringComparer.Ordinal); CompareAssert.IsGreaterThan(x, y, comparer, message); CompareAssert.IsEqualTo(x, x, comparer); CompareAssert.IsLessThan(y, x, comparer, message); } } }