Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save greatb/ac87efa83673d78bba4a1c3170e29d95 to your computer and use it in GitHub Desktop.
Save greatb/ac87efa83673d78bba4a1c3170e29d95 to your computer and use it in GitHub Desktop.
Test to check the Extension method behavior when the object is null
public class Company
{
public string Name { get; set; }
public Company()
{
Name = "The Name";
}
}
[TestFixture]
public class NullTest
{
[Test]
public void TestExtensionMethodFailWhenTheObjectIsNull()
{
Company company = new Company();
Assert.AreEqual(company.IsNullObj(), true);
}
}
public static class Extension
{
public static bool IsNullObj(this Company obj)
{
return (obj == null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment