Created
May 9, 2017 02:36
-
-
Save greatb/ac87efa83673d78bba4a1c3170e29d95 to your computer and use it in GitHub Desktop.
Test to check the Extension method behavior when the object is null
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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