You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When testing e.g. a function translation, for full coverage we need to check both predicate translation (with the function in Where()), and projection (with the function in Select()).
Testing Select() is insufficient because EF client evaluates final select (and so translation isn't even tested); even without this, Select() wouldn't check that the translation returns the correct relational value, only that what it returns can be projected out and read.
Testing Where() ensures that actual translation occurs, and also that the proper relational value is produced (since we compare the translation result to e.g. some constant). However, it does not check that e.g. the correct CLR type is set on the resulting SqlExpression; thus, a correctly translated function can fail when projected out of the database.
In the base, we've sometimes done both Where and Select tests for the same function translation. We've done this very sporadically and non-systematically, with very few translations getting both and most getting only one or the other.
To do this more systematically, we could have an AssertTranslation, which accepts a query base, a lambda to be tested, and an expected result value for the Where test; AssertTranslation would then do AssertQuery twice internally, once for Where and once for Select. For example:
awaitAssertTranslation(async,ss=> ss.Set<BasicTypesEntity>(),b=>Math.Cos(b.Double), b =>8);
This would internally perform the following two things:
In the meantime, where we think it's important to test both Where and Select, we should simply combine both into the same test; so the single test that covers the translation for Func() can call AssertQuery twice. If and when we have AssertTranslation, it would basically do the same.
When testing e.g. a function translation, for full coverage we need to check both predicate translation (with the function in Where()), and projection (with the function in Select()).
In the base, we've sometimes done both Where and Select tests for the same function translation. We've done this very sporadically and non-systematically, with very few translations getting both and most getting only one or the other.
To do this more systematically, we could have an AssertTranslation, which accepts a query base, a lambda to be tested, and an expected result value for the Where test; AssertTranslation would then do AssertQuery twice internally, once for Where and once for Select. For example:
This would internally perform the following two things:
In the meantime, where we think it's important to test both Where and Select, we should simply combine both into the same test; so the single test that covers the translation for Func() can call AssertQuery twice. If and when we have AssertTranslation, it would basically do the same.
/cc @maumar
The text was updated successfully, but these errors were encountered: