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 System.Data.Linq.DataContext , everything works fine. However, when mContext is a layout in memory during my e.Password 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 speak with LinqToSql. (System.NotSupportedException: The query statement "SequenceEqual" is not supported.)
Is there a way that I can write this query that will satisfy my unit tests with a layout in memory, as well as the production component of LinqToSql?
c # unit-testing linq-to-sql mocking
Kyle chafin
source share