Actually this is my service layer. I want to test a create account method by Xunit testing. How can I proceed further?
public class UserService :IUserService // service
{
#region Property
private readonly IAppDbContext _appDbContext;
#endregion
#region Constructor
public UserService(IAppDbContext appDbContext)
{
_appDbContext = appDbContext;
}
#endregion
public int Create(User model)
{
_appDbContext.Users.Add(model);
_appDbContext.SaveChanges();
return model.Id;
}
public bool CheckAccount(User data)
{
if (this._appDbContext.Users.Any(x => x.UserName == data.UserName))
{
return false;
}
else
{
return true;
}
}
public string CheckDetails(User data)
{
if (this._appDbContext.Users.Any(x => x.Password == data.Password) &&
this._appDbContext.Users.Any(x => x.UserName == data.UserName))
{
var userid = "";
var obj = this._appDbContext.Users.Where(x => x.UserName == data.UserName);
foreach (var i in obj)
{
userid = i.Id.ToString();
}
return userid;
}
else
{
return null;
}
}
}
}
Please tell ,how to I test this method are there in User service by xunit testing