I've read that when using moq you cannot mock a non-virtual function. I've also read that this should be possible now.. Is that true?
If so, then I'd like to mock the following query:
DatabaseContext.Database.ExecuteSqlCommand(updateQuery, newValue);
I'm overriding the Context in my test as so
DAL.Context.DatabaseContext = mockContext.Object;
I've tried this setup, but it seems the query stills goes agains my regular db
mockContext.Setup(c => c.Set<AppSalesAndResult>()).Returns(mockBudgetData.Object);
Any ideas, could perhaps the executesqlcommand be replaced with something else so that the row above would catch any udpates to the set? I use executesqlcommand due to performance reasons when updating multiple rows at once. Regular EF is too slow
UPDATE:
Reading the following post, How to Moq Entity Framework SqlQuery calls I wonder if a similar implementation would work for ExecuteSQLCommand...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…