Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save miklund/a51466be24d5f5876d5f to your computer and use it in GitHub Desktop.
Save miklund/a51466be24d5f5876d5f to your computer and use it in GitHub Desktop.
2009-05-29 The difference between member methods and extension methods
# Title: The difference between member methods and extension methods
# Author: Mikael Lundin
# Link: http://blog.mikaellundin.name/2009/05/29/the-difference-between-member-methods-and-extension-methods.html
// Written with MsTest as unit test framework
namespace LiteMedia
{
using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class VerifyClaim
{
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void FirstOrDefaultThrowsArgumentNullException()
{
/* Setup */
string[] names = null;
/* Test */
names.FirstOrDefault();
}
[TestMethod]
[ExpectedException(typeof(NullReferenceException))]
public void UsingClassMembersOnNullReferenceWillThrowNullReferenceException()
{
/* Setup */
string[] names = null;
/* Test */
string fail = names.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment