InMemoryAdapter swallows "No matching table found..." exceptions

25 views
Skip to first unread message

Jorge Gamba

unread,
Apr 24, 2013, 3:54:47 PM4/24/13
to simpl...@googlegroups.com
Hi, I'm executing some code like:

var adapter = new InMemoryAdapter();
Database.UseMockAdapter(adapter);

var db = Database.Open();
db["MyTable"].Insert(Id: 1);

var list = db.MyInexistentTable.All();
// or var list = db[MyInexistentTable].All();

Actually that's for testing purposes, but ... it should fails, but it just swallows the expected exception 'UnresolvableObjectException' about "No matching table found''.


Could some one shows me how to test that some like that fails?, thanks in advance.

Mark Rendle

unread,
Apr 24, 2013, 7:00:14 PM4/24/13
to Simple.Data
The problem is that the InMemoryAdapter creates tables as soon as you reference them as properties, including when you're going to call "All()" on them.

Not sure why you'd want it to throw an UnresolvableObjectException for your tests...?



--
You received this message because you are subscribed to the Google Groups "Simple.Data" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simpledata+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jorge Gamba

unread,
Apr 24, 2013, 10:26:31 PM4/24/13
to simpl...@googlegroups.com
Thanks for your response... because my Web API allows receive the table name to query, so I want that in case of that the passed table name not exists in my database it throws a Exception and for that purpose I have implemented a unit test that uses InMemoryAdapter.

Mark Rendle

unread,
Apr 25, 2013, 6:18:43 AM4/25/13
to Simple.Data
Right. I don't think InMemoryAdapter is the right choice there; you could try using the SQLite provider with an in-memory databaseif you need more database-like behaviour.

Jorge Gamba

unread,
Apr 25, 2013, 9:10:30 AM4/25/13
to simpl...@googlegroups.com
Thanks a lot for the clarification, I'll try it.
Reply all
Reply to author
Forward
0 new messages