I am writing test cases using the Unit Test for ASP.NET MVC 3 with Web Api.
Now I have an action which makes a call to some method I have defined in the service layer, where I have used the following line of code.
var userId = ((Project)(User.Identity)).UserId;
where Project class is
using System;
using System.Security.Principal;
using System.Web.Security;
namespace Project.Web.Core.Models
{
[Serializable]
public class ProjectUser : IIdentity
{
public ProjectUser(){}
public int UserId { get; set; }
}
}
Now how to I create unit test method for this, I am getting null reference exceptions. I am new to writing unit test Can anyone please help me