public void CompareTo_ComparisonAndProjectionApplied() { List <IntWrapper> source = new List <IntWrapper>() { new IntWrapper() { Value = 5 }, new IntWrapper() { Value = 4 }, new IntWrapper() { Value = 3 }, new IntWrapper() { Value = 2 }, new IntWrapper() { Value = 1 }, new IntWrapper() { Value = 0 } }; source.Sort(ProjectedComparer.Create <IntWrapper, int>( (x, y) => x.CompareTo(y), s => s.Value )); for (int i = 0; i < source.Count; i++) { Assert.AreEqual(i, source[i].Value); } }
public void Constructor_NonNullComparisonAndNonNullProjection_DoesNotThrowException() { ProjectedComparer <IntWrapper, int> c = new ProjectedComparer <IntWrapper, int>((x, y) => 0, x => x.Value); }
public void Constructor_NullProjection_ThrowsException() { ProjectedComparer <IntWrapper, int> c = new ProjectedComparer <IntWrapper, int>((x, y) => 0, null); }
public void Constructor_NullComparison_ThrowsException() { ProjectedComparer <IntWrapper, int> c = new ProjectedComparer <IntWrapper, int>(null, (x) => { return(x.Value); }); }
public void Constructor_NonNullComparisonAndNonNullProjection_DoesNotThrowException() { ProjectedComparer<IntWrapper, int> c = new ProjectedComparer<IntWrapper, int>((x, y) => 0, x => x.Value); }
public void Constructor_NullProjection_ThrowsException() { ProjectedComparer<IntWrapper, int> c = new ProjectedComparer<IntWrapper, int>((x, y) => 0, null); }
public void Constructor_NullComparison_ThrowsException() { ProjectedComparer<IntWrapper, int> c = new ProjectedComparer<IntWrapper, int>(null, (x) => { return x.Value; }); }