mercredi 7 janvier 2015

Uni Test for Log in Page giving null

i am writing a unitest for login in my project .


when i call the login function of my controller. Memership.GetUser giving null value for passed User. below is Test case



[TestMethod]
public void Login()
{

//Arrange
AccountController account = new AccountController(_forgotPasswordTokensRepo, _IMessageTemplateDAO, _IEmailService, _ISettingDAO, _IProfileDAO);
List<AccountBO> TestUsers = new List<AccountBO>();

AccountBO objAccountBO = new AccountBO();
objAccountBO.Email = "uu@yopmail.com";
objAccountBO.Password = "123456789";


TestUsers.Add(objAccountBO);

var result = (JsonResult)account.Login(TestUsers[0]);
var json = new System.Web.Script.Serialization.JavaScriptSerializer();

string data = result.Data.ToString().Split('=')[1].Trim();
bool Processdata = Convert.ToBoolean(data.Replace('}', ' ').Trim());

Assert.AreEqual<bool>(true, Processdata);



}


Controller function is



public JsonResult Login(AccountBO account, string returnUrl = "")

{

bool hasBeenUnlocked = false;
if (ModelState.IsValid)
{
MembershipUser adminUser;
adminUser = Membership.GetUser(account.Email);
------so on
}

}


here adminUser = Membership.GetUser(account.Email) is giving null.


Aucun commentaire:

Enregistrer un commentaire