using System.Collections.Generic;
public List<user_mstr> user_mstr;
private static string strUserCD = "foo";
private static void FirstUserAsNull()
Console.WriteLine("OneUserAsNull");
FakeContext ctx = new FakeContext();
ctx.user_mstr = new List<user_mstr>() { null, new user_mstr(), new user_mstr() };
user_mstr vwUser = ctx.user_mstr.FirstOrDefault(x => x.user_cd == strUserCD);
catch (NullReferenceException e)
Console.WriteLine(e.Message);
catch (ArgumentNullException e)
Console.WriteLine(e.Message);
private static void UserListAsNull()
Console.WriteLine("UserListAsNull");
FakeContext ctx = new FakeContext();
user_mstr vwUser = ctx.user_mstr.FirstOrDefault(x => x.user_cd == strUserCD);
catch (NullReferenceException e)
Console.WriteLine(e.Message);
catch (ArgumentNullException e)
Console.WriteLine(e.Message);
private static void CtxAsNull()
Console.WriteLine("CtxAsNull");
user_mstr vwUser = ctx.user_mstr.FirstOrDefault(x => x.user_cd == strUserCD);
catch (NullReferenceException e)
Console.WriteLine(e.Message);
public static void Main()