Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Stuff that are hard to test is often <a href="http://www.thesoftwaredevotional.com/2009/02/loose-coupling-is-good-tight-coupling-is-the-devil.html" rel="noreferrer">tightly coupled</a> or not following the <a href="http://www.google.se/url?sa=t&amp;source=web&amp;cd=2&amp;ved=0CB4QFjAB&amp;url=http%3A%2F%2Fwww.objectmentor.com%2Fresources%2Farticles%2Fsrp.pdf&amp;ei=hhzHTJ-3BdCXOoC5kdUB&amp;usg=AFQjCNHQQ1Aw-2yCciEbERpJn3VdHBCmQw" rel="noreferrer">Single Responsibility principle</a>.</p> <p>First of all. Split your datalayer. Look at the <a href="http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/10/08/the-repository-pattern.aspx" rel="noreferrer">repository pattern</a>. Each entity (table or view) should have it's own class fetching data. </p> <p>Use data interfaces instead of specific driver implementation: <code>IDbConnection</code> instead of <code>SqlConnection</code>. Use <a href="http://msdn.microsoft.com/en-us/library/system.data.common.dbproviderfactory.aspx" rel="noreferrer"><code>DbProviderFactory</code></a> to get the proper connection implementation. Then use <code>connection.CreateCommand()</code> to get a command etc.</p> <p>Doing all that would make it a whole lot easier to test your data layer. And remember, the datalyer should not have any logic. It's only purpose is to load data from a data source.</p> <p>But if you don't want to change stuff: Working against a database is the easiest way. Remove all data and insert new test data before each test (to remove any changes during a previous test).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload