I have the following method:
User IDataContext.AuthenticateUser(string userName, string password)
{
byte[] hash = PasswordHasher.HashPassword(userName, password);
var query =
from e in mContext.GetTable<User>()
where e.Email == userName && e.Password == hash
select e;
return query.FirstOrDefault();
}
When mContext
is a System.Data.Linq.DataContext
everything works great. However, when mContext
is an in-memory mock during my uniting testing, the comparison between e.Password
and hash
always returns false
.
If I rewrite this comparison as e.Password.SequenceEqual(hash)
, then my unit tests will pass, but I get an exception when I'm talking to LinqToSql. (System.NotSupportedException: The query operator 'SequenceEqual' is not supported.)
Is there a way that I can write this query that will satisfy my unit tests with an in-memory mock, as well as the production component with LinqToSql?