<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>TDD developer &#187; sqlce</title>
	<atom:link href="http://testdrivendevelopment.wordpress.com/tag/sqlce/feed/" rel="self" type="application/rss+xml" />
	<link>http://testdrivendevelopment.wordpress.com</link>
	<description>Diary of an agile developer</description>
	<lastBuildDate>Wed, 28 Oct 2009 22:06:05 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='testdrivendevelopment.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/a6ef45b2d30fa0fcbe697fa111d46fdd?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>TDD developer &#187; sqlce</title>
		<link>http://testdrivendevelopment.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://testdrivendevelopment.wordpress.com/osd.xml" title="TDD developer" />
		<item>
		<title>Create SqlCe database before integration test</title>
		<link>http://testdrivendevelopment.wordpress.com/2008/10/07/create-sqlce-database-before-integration-test/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2008/10/07/create-sqlce-database-before-integration-test/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 19:35:29 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[TDD]]></category>
		<category><![CDATA[integrationtest]]></category>
		<category><![CDATA[sqlce]]></category>
		<category><![CDATA[unittest]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2008/10/07/create-sqlce-database-before-integration-test/</guid>
		<description><![CDATA[In these days I&#8217;m developing a smart client application that use a Sql Compact Edition database as local storage. I&#8217;m using NHibernate to query the database and one of the things I need to check are my mapping files. In order to accomplish this task I setup a series of integration tests. Once before all [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&blog=2459763&post=43&subd=testdrivendevelopment&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In these days I&#8217;m developing a smart client application that use a Sql Compact Edition database as local storage. <br />I&#8217;m using NHibernate to query the database and one of the things I need to check are my mapping files. <br />In order to accomplish this task I setup a series of integration tests. Once before all tests I run a method that create an empty database.<br />In fact using SqlCeEngine class I can create the empty database using CreateDatase method. <br />Later than with a simple SqlCeConnection I run a set of sql commands saved in .sql file in order to create all the objects inside my database.</p>
<div>
<pre class="csharpcode"><span class="kwrd">const</span> <span class="kwrd">string</span> connectionString = <span class="str">@"Data Source=|DataDirectory|demo.sdf"</span>;
var engine = <span class="kwrd">new</span> SqlCeEngine(connectionString);
engine.CreateDatabase(); 

<span class="kwrd">string</span>[] commands = File.ReadAllText(<span class="str">@"C:Projectsdemo002.CreateTables.sqlce"</span>).Split(<span class="str">';'</span>);
<span class="kwrd">using</span> (IDbConnection connection = <span class="kwrd">new</span> SqlCeConnection(connectionString))
{
    connection.Open();
    <span class="kwrd">foreach</span> (var commandText <span class="kwrd">in</span> commands)
    {
        <span class="kwrd">if</span> (<span class="kwrd">string</span>.IsNullOrEmpty(commandText)) <span class="kwrd">continue</span>;
        <span class="kwrd">using</span> (IDbCommand command = connection.CreateCommand())
        {
            command.CommandType = CommandType.Text;
            command.CommandText = commandText;
            command.ExecuteNonQuery();
        }
    }
}
</pre>
</div>
<p>Simple, easy &amp; clear.</p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:416031d4-a9c7-4fea-a076-94fea19bc5ae" style="display:inline;margin:0;padding:0;">Technorati Tag: <a href="http://technorati.com/tags/Sql%20Compact%20Edition" rel="tag">Sql Compact Edition</a>,<a href="http://technorati.com/tags/SqlCE" rel="tag">SqlCE</a>,<a href="http://technorati.com/tags/NHibernate" rel="tag">NHibernate</a>,<a href="http://technorati.com/tags/unit%20test" rel="tag">unit test</a>,<a href="http://technorati.com/tags/integration%20test" rel="tag">integration test</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&blog=2459763&post=43&subd=testdrivendevelopment&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2008/10/07/create-sqlce-database-before-integration-test/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>
	</item>
	</channel>
</rss>