title: Assert.AreEqual fails while it shouldn't
body: <p>I have a really weird behavior which I cannot explain.</p>
  
  <p>I have the following class:</p>
  
  <pre><code>public class Project
  {
      public virtual int Id { get; set; }
  
      public virtual string Name { get; set; }
  }
  </code></pre>
  
  <p>And a method which returns a <code>Project</code> object:</p>
  
  <pre><code>public Project GetByName(string Name)
  {
      using (ISession session = NHibernateHelper.OpenSession())
      {
          Project project = session.CreateCriteria(typeof(Project))
                                   .Add(Restrictions.Eq("Name", Name))
                                   .UniqueResult&lt;Project&gt;();
  
          return project;
      }
  }
  </code></pre>
  
  <p>I have added a Unit Test to test the <code>GetByName</code> method:</p>
  
  <pre><code>[TestMethod]
  public void TestGetByName()
  {
      IProjectsRepository projectRepository = new ProjectsRepository();
  
      var expected = new Project { Id = 1000, Name = "Project1" };
      var actual = projectRepository.GetByName(expected.Name);
  
      Assert.AreEqual&lt;Project&gt;(expected, actual);
  }
  </code></pre>
  
  <p>But when I run the unit test it fails when comparing the type of the two objects with the following error:</p>
  
  <blockquote>
    <p>Assert.AreEqual failed. Expected:&lt;MyProject.NHibernate.Project&gt;.
    Actual:&lt;MyProject.NHibernate.Project&gt;.</p>
  </blockquote>
  
  <p>Why is the assertion failing?</p>
  
  <hr>
  
  <p>Isn't <a href="http://msdn.microsoft.com/en-us/library/ms243413.aspx" rel="noreferrer">Assert.AreEqual</a> asserting only on the properties of the objects?</p>
  
  <p>According to the documentation:</p>
  
  <blockquote>
    <p><strong>Assert.AreEqual Method (Object, Object)</strong></p>
    
    <p>Verifies that two specified objects are equal. The assertion fails if
    the objects are not equal.</p>
    
    <p><strong>Assert.AreSame Method</strong> </p>
    
    <p>Verifies that specified object variables refer to the same object.</p>
  </blockquote>