Trying to Xunit test with InMemoryDatabase, is this possible in Core 3 yet? It works in the application just fine and I thnik IO am using the right FromSqlRaw command and I get System.NotImplementedException: 'Unhandled method: FromSqlOnQueryable'.
var sqlParameters = new List<SqlParameter>()
{
new SqlParameter("p1", p1val),
new SqlParameter("p2", p2val),
new SqlParameter("p3", p3val),
new SqlParameter("p4", p4val)
};
return _context.[ModelObjectName]
.FromSqlRaw("EXECUTE spCreateAuction @p1, @p2, @p3, @p4", sqlParameters.ToArray())
.AsNoTracking()
.ToList()
.FirstOrDefault();
InMemory is not a relational database and doesn't support raw SQL execution
Thanks for the input, I thought I read somewhere that 3.+ might be allowing the option to test sprocs. Guess not, anyway you recommend to test store procedures with XUnit?
The most accurate and useful way would be to use a local database
Understood, trying NOT to run SPROCs that create stuff and junk up my dev environment which is why InMemory is being used. Is there a lot of complications in running a sproc InMemory when the DB is all cached, relational does not really matter in this respect. I get the relationship part, FK and ocntraints do not work but just hitting the repo functions is a good test as months go on, you know? Would do the same with Views even, helps catch stuff that you might not have factored for.
While InMemory can help to catch some bugs you might need waste time dealing with issues that will never show up when using a relational database.
You can configure XUnit to create the database, run the tests, then clean it up when done (it's faster to clean the database then dropping and recreating). See TestStore and SqlServerTestStore
Most helpful comment
While InMemory can help to catch some bugs you might need waste time dealing with issues that will never show up when using a relational database.
You can configure XUnit to create the database, run the tests, then clean it up when done (it's faster to clean the database then dropping and recreating). See TestStore and SqlServerTestStore