Closed 2mawi2 closed 7 years ago
What you mean nothing implemented?
I was looking for the ILiteCollection and ILiteDatabase interfaces. But they dont have interfaces.
They wouldn't as they are sealed classes, what are you trying to achieve? On Jan 4, 2017 2:08 PM, "2mawi2" notifications@github.com wrote:
I was looking for the ILiteCollection and ILiteDatabase interfaces. But they dont have interfaces.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mbdavid/LiteDB/issues/413#issuecomment-270356960, or mute the thread https://github.com/notifications/unsubscribe-auth/AVQ2C2acS3q0y39j3zn_6UcVvIhbORUgks5rO4u-gaJpZM4LajgY .
I was trying to mock them with moq and unit test them with my repositories. How do I fake the db calls for the tests ? LiteDb.Tests uses a TempFile, but I dont really wanna test, if the db is working. Or am I missing something ?
Do you unit tests, create a reqular ol file to use, separate your db logic. Put it into a library ex (barnyardDB) has (Insert/update/delete) for each db table
By making a library you can run your unit tests etc in an isolated independent environment. While keeping the project accessable to ude the db system (your own library wrapper) On Jan 4, 2017 2:27 PM, "2mawi2" notifications@github.com wrote:
I was trying to mock them with moq and unit test them with my repositories. How do I fake the db calls for the tests ? LiteDb.Tests uses a TempFile, but I dont really wanna test, if the db is working. Or am I missing something ?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mbdavid/LiteDB/issues/413#issuecomment-270359935, or mute the thread https://github.com/notifications/unsubscribe-auth/AVQ2C_37nTiccfJMmYQJtd3aZm2f3veVks5rO5BHgaJpZM4LajgY .
Then you can put sub classes like barnyardDB.animals class barbyardDB.equipment class
Each class takes objects in form of Insert(animal/equipment newObj) Update(animal/equipment oldObj, animal/equipment newObject) delete(anime/equipment oldObject)
Delete / update can be overridento allow another paramter to specify which property of equipment/animal class to be used (ex _id) which should be of string type....
Better oop design. Imo this My method and it works well. On Jan 4, 2017 2:27 PM, "2mawi2" notifications@github.com wrote:
I was trying to mock them with moq and unit test them with my repositories. How do I fake the db calls for the tests ? LiteDb.Tests uses a TempFile, but I dont really wanna test, if the db is working. Or am I missing something ?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mbdavid/LiteDB/issues/413#issuecomment-270359935, or mute the thread https://github.com/notifications/unsubscribe-auth/AVQ2C_37nTiccfJMmYQJtd3aZm2f3veVks5rO5BHgaJpZM4LajgY .
So you basically wrote your own wrapper, subclassed it and wrote the tests on that basis. I presumably wont get around that. Thanks xX-MLG-Xx 👍
Hi @2mawi2 and @xX-MLG-Xx, just to know, LiteDB also support in-memory database just to unit test. You can use like
using(db = new LiteDatabase(new MemoryStream()))
{
...
}
Noted, he is trying to from my understand re-implement the LiteDatabase etc... to ensure that said methods etc can be unit tested. He was looking for an ILiteDatabase Interface. So he could write a unit test wrapper like.
public interface ILiteDatabase { .... methods etc ... }
public class UnitLiteDatabase { ... methods etcc... ..each method contains a logging function call... } On Jan 4, 2017 4:00 PM, "Mauricio David" notifications@github.com wrote:
Hi @2mawi2 https://github.com/2mawi2 and @xX-MLG-Xx https://github.com/xX-MLG-Xx, just to know, LiteDB also support in-memory database just to unit test. You can use like
using(db = new LiteDatabase(new MemoryStream())) { ... }
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mbdavid/LiteDB/issues/413#issuecomment-270376640, or mute the thread https://github.com/notifications/unsubscribe-auth/AVQ2CxcOwf6A3gFA49S0OZWvsY07rry_ks5rO6YOgaJpZM4LajgY .
Hey mbdavid, cool I haven't seen that. So there is no need for a mocked LiteDatabase, I can just pass in a temporary MemoryStream. That makes it easier.
Cheers
May i ask why there is no interface implemented for LiteDatabase and the partial LiteCollection ? It would make testing so much easier.