How to test with a mocking framework using Entity Framework Core #259
-
Hi team! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi. Most capabilities enabled by CoreEx, that Beef leverages, are primarily interface driven, by design, and therefore mockable. Also, the There is no example of the EF and Database mocking as per the link you shared (and there are acknowledged limitations with its usage). I have a philosophical issue with the mocking of key dependencies such as its tightly coupled database, as such the preferred approach has been to unit test intra-domain and mock inter-domain (see definition) dependencies where possible. By mocking the database dependency so much of the solution is not validated. For example, existence of table(s) and/or column(s), column type mapping, identifier creation, timestamping for optimistic concurrency, duplicate checking, stored-procedure existence and related logic, data filtering and sorting validation, etc. Plus, with containers, and CI pipelines, it is relatively easy to ensure that the verification is performed early and often (see In the sample, to improve the execution performance of the validation unit tests and minimize data set up requirements, the data access is mocked. See I hope this helps :-) |
Beta Was this translation helpful? Give feedback.
Hi. Most capabilities enabled by CoreEx, that Beef leverages, are primarily interface driven, by design, and therefore mockable. Also, the
IXxxData
is a common mocked layer in unit tests where required.There is no example of the EF and Database mocking as per the link you shared (and there are acknowledged limitations with its usage). I have a philosophical issue with the mocking of key dependencies such as its tightly coupled database, as such the preferred approach has been to unit test intra-domain and mock inter-domain (see definition) dependencies where possible.
By mocking the database dependency so much of the solution is not validated. For example, existence of table(s) and/or co…