Q: Equal Collection returns false when Object implements IEquatable? I have the following test example:
var a = new List<OrderRule> {
  new OrderRule("name", OrderDirection.Ascending),
  new OrderRule("age", OrderDirection.Descending)
};

var b = new List<OrderRule> {
  new OrderRule("name", OrderDirection.Ascending),
  new OrderRule("age", OrderDirection.Descending)
};

var r = a.SequenceEqual(b);
Assert.Equal(a, b);

The variable r is true but Assert.Equal is false ...
The OrderRule class is the following:
public class OrderRule : IEquatable<OrderRule> {

  public OrderDirection Direction { get; }
  public String Property { get; }

  public OrderRule(String property, OrderDirection direction) {
    Direction = direction;
    Property = property;
  }

  public Boolean Equals(OrderRule other) {
    if (other == null)
      return false;
    return Property.Equals(other.Property) && Direction.Equals(other.Direction);  
  }

  public override Boolean Equals(Object obj) {  
    if (ReferenceEquals(null, obj))
      return false;
    if (ReferenceEquals(this, obj))
      return true;
    if (obj.GetType() != GetType())
      return false;
    return Equals(obj as IncludeRule);
  }

  public override Int32 GetHashCode() {
    return HashCode.Of(Property).And(Direction);
  }
}

public enum OrderDirection { ASC, DESC }

Is there any problem with Assert.Equal when overriding Equals and implementing IEquatable?
UPDATE - HashCode helper
public struct HashCode {

  private readonly Int32 Value;

  private HashCode(Int32 value) {
    Value = value;
  }

  public static implicit operator Int32(HashCode hashCode) {
    return hashCode.Value;
  }

  public static HashCode Of<T>(T item) {
    return new HashCode(GetHashCode(item));
  }

  public HashCode And<T>(T item) {
    return new HashCode(CombineHashCodes(Value, GetHashCode(item)));
  }

  public HashCode AndEach<T>(IEnumerable<T> items) {      
    Int32 hashCode = items.Select(x => GetHashCode(x)).Aggregate((x, y) => CombineHashCodes(x, y));
    return new HashCode(CombineHashCodes(Value, hashCode));
  }

  private static Int32 CombineHashCodes(Int32 x, Int32 y) {
    unchecked {        
      return ((x << 5) + x) ^ y;
    }  
  }

  private static Int32 GetHashCode<T>(T item) {
    return item == null ? 0 : item.GetHashCode();
  }

}


A: Your code works as expected on my side. I've only fixed compilation erros - IncludeRule changed to OrderRule in Equals, also fixed OrderDirection enum members.
