Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 115283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:59:41+00:00 2026-05-11T02:59:41+00:00

i recently stumbled upon a seemingly weird behavior that Google completely failed to explain.

  • 0

i recently stumbled upon a seemingly weird behavior that Google completely failed to explain.

 using Microsoft.VisualStudio.TestTools.UnitTesting;  class TestClass {     public override bool Equals(object obj)     {         return true;     } }  [TestMethod] public void TestMethod1() {     TestClass t = new TestClass ();     Assert.AreEqual (t, null); // fails     Assert.IsTrue (t.Equals (null)); // passes } 

I would expect this test to succeed. However, in Visual Studio 2008 / .NET 3.5 it fails. Is it intended to be like that or is it a bug?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:59:41+00:00Added an answer on May 11, 2026 at 2:59 am

    Your TestClass violates the contract of Object.Equals. Assert.AreEqual is relying on that contract, quite reasonably.

    The docs state (in the list of requirements):

    • x.Equals(a null reference (Nothing in Visual Basic)) returns false.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently stumbled upon Etherpad, it's a collaborative writing tool http://code.google.com/p/etherpad/ - main project
I recently stumbled across this entry in the google testing blog about guidelines for
I have recently figured out that I haven't been using regex properly in my
Recently I stumbled across this pretty slick JS library called nodeJS that acts like
I recently stumbled across the following assembly instruction sequence: rep stos dword ptr [edi]
I'm new to this site having stumbled across it recently (and am loving it!)
Recently i've switched to PHP 5.3+ and after that migration i learned that the
Recently Jeff has posted regarding his trouble with database deadlocks related to reading. Multiversion
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently, I started changing some of our applications to support MS SQL Server as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.