Transform Null Check

I'm having a strange issue with some of my unit tests running on Unity.
Simplified the test to this:
  var bone = new GameObject();
where Expect.Null looks like this:
  public static void Null(T reference) where T : class
    if (reference != null)
      throw new UnityException("expected null but was not");
But the expectation fails and the exception triggers... Any idea why?
Forgot to mention: Unity v3.5.6f4.

UnityEngine.Object overloads the ‘==’ and ‘!=’ operators. Without the ‘where T : UnityEngine.Object constraint’, the default comparison for System.Object equality is used, which is the source of the behavior you are seeing.

UnityEngine.Object also overrides the .Equals(object) method, which takes a System.Object as an argument and will perform the null check correctly. Example:

    public static void Null(object reference)
        if (reference == null || reference.Equals(null))
        throw new ArgumentNullException();

EDIT: Modified example to avoid null reference exception.

What you might want to use is Object.ReferenceEquals, however keep in mind that if a GameObject is destroyed it’s managed part will survive until all references go out of extent. Unity’s overridden operators usually take care of that. When using ReferenceEquals you might get the wrong result.