title: Queryable.Intersect not working on object
body: <p>I have the following object, <code>Role</code>, defined as :</p>
  
  <pre><code>public class Role
  {
      public String RoleName { get; set; }
      public Guid RoleGuid { get; set; }
      public override bool Equals(object obj)
      {
          return (this.RoleName == ((Role)obj).RoleName);
      }
  }
  </code></pre>
  
  <p>I also have a collection modeled as <code>RolesCollection</code>, defined as:</p>
  
  <pre><code>public class RolesCollection : IList&lt;Role&gt;, IEqualityComparer&lt;Role&gt;, IEnumerable&lt;Role&gt;
  {
      private readonly IList&lt;Role&gt; _list = new List&lt;Role&gt;();
      public Role this[int index]
      {
          get
          {
              return _list[index];
          }
  
          set
          {
              _list[index] = value;
          }
      }
  
      public int Count
      {
          get
          {
              return _list.Count;
          }
      }
  
      public bool IsReadOnly
      {
          get
          {
              return _list.IsReadOnly;
          }
      }
  
      public void Add(Role item)
      {
          _list.Add(item);
      }
  
      public void Clear()
      {
          _list.Clear();
      }
  
      public bool Contains(Role item)
      {
          return _list.Contains(item);
      }
  
      public void CopyTo(Role[] array, int arrayIndex)
      {
          _list.CopyTo(array, arrayIndex);
      }
  
      public bool Equals(Role x, Role y)
      {
          return (x.RoleName == y.RoleName);
      }
  
      public IEnumerator&lt;Role&gt; GetEnumerator()
      {
          return _list.GetEnumerator();
      }
  
      public int GetHashCode(Role obj)
      {
          return obj.RoleName.GetHashCode();
      }
  
      public int IndexOf(Role item)
      {
          Role interalItem = _list.First&lt;Role&gt;(i =&gt; i.RoleName == item.RoleName);
          return _list.IndexOf(interalItem);
      }
  
      public void Insert(int index, Role item)
      {
          _list.Insert(index, item);
      }
  
      public bool Remove(Role item)
      {
          return _list.Remove(item);
      }
  
      public void RemoveAt(int index)
      {
          _list.RemoveAt(index);
      }
  
      IEnumerator IEnumerable.GetEnumerator()
      {
          return GetEnumerator();
      }
  }
  </code></pre>
  
  <p>Now comes my Unit <code>Tests.EqualsTest()</code>, which is passing and  <code>RolesIntersectTest()</code>, which is failing. It should give me 2 but it gives me 0. </p>
  
  <pre><code>[TestClass()]
  public class RoleTests
  {
      public RolesCollection Source { get; set; }
      public RolesCollection Destination { get; set; }
      [TestInitialize()]
      public void SetUp() {
          Source = new RolesCollection();
          Source.Add(new Role() { RoleGuid = System.Guid.NewGuid(), RoleName = "Baker" });
          Source.Add(new Role() { RoleGuid = System.Guid.NewGuid(), RoleName = "Tailor" });
          Source.Add(new Role() { RoleGuid = System.Guid.NewGuid(), RoleName = "Chef" });
  
          Destination = new RolesCollection();
          Destination.Add(new Role() { RoleGuid = System.Guid.NewGuid(), RoleName = "Baker" });
          Destination.Add(new Role() { RoleGuid = System.Guid.NewGuid(), RoleName = "Tailor" });
          Destination.Add(new Role() { RoleGuid = System.Guid.NewGuid(), RoleName = "Teacher" });
      }
      [TestMethod()]
      public void EqualsTest()
      {
          Role role1 = new Role() {
              RoleGuid = System.Guid.NewGuid(),
              RoleName = "Vinay"
          };
          Role role2 = new Role()
          {
              RoleGuid = System.Guid.NewGuid(),
              RoleName = "Vinay"
          };
          Assert.IsTrue(role1.Equals(role2));
  
      }
      [TestMethod()]
      public void RolesIntersectTest() {
          RolesCollection results = Source.Intersect(Destination) as RolesCollection;
          Assert.IsTrue(results.Count() &gt; 1);
      }
  }
  </code></pre>
  
  <p>Please advice.</p>