<?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/"
	>

<channel>
	<title>blog.dervalp.com &#187; TDD</title>
	<atom:link href="http://blog.dervalp.com/tag/tdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dervalp.com</link>
	<description>Think before Programming (Public learning)</description>
	<lastBuildDate>Sat, 20 Mar 2010 22:22:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Kiwi MVC.NET : Why this, why that ? I explain my architecture choices Part 5 [source on codeplex]</title>
		<link>http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/</link>
		<comments>http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/#comments</comments>
		<pubDate>Fri, 29 May 2009 18:26:39 +0000</pubDate>
		<dc:creator>dervalp</dc:creator>
				<category><![CDATA[Kiwi MVC]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[MVC.NET]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://blog.dervalp.com/?p=283</guid>
		<description><![CDATA[So, I work hard these days to  finish my data access. I would like to explain you how I see application&#8217;s design.
As I told you before, I want to separate my application in 3 parts. I know that architecture could be discussed but I would make this point clear, it should be &#8220;re-factored&#8221;. Anyway, for [...]]]></description>
			<content:encoded><![CDATA[<p>So, I work hard these days to  finish my data access. I would like to explain you how I see application&#8217;s design.</p>
<p>As I told you before, I want to separate my application in 3 parts. I know that architecture could be discussed but I would make this point clear, it should be &#8220;re-factored&#8221;. Anyway, for the moment, I think it is enough flexible for what I want to do <span style="text-decoration: underline;">NOW</span>.</p>
<p>Here is a reminder of my layers:</p>
<ul>
<li>The Web application which will be the view of my application.</li>
</ul>
<ul>
<li>The controller with all my business logic embedded in a library Service.</li>
</ul>
<ul>
<li>The model library which will contain my models, my data access (repository) and all my filter static classes.</li>
</ul>
<h2><span id="more-283"></span></h2>
<p>To improve my explanations, I hand draw a little pseudo UML diagram :</p>
<p><img class="alignnone size-full wp-image-287" title="kiwi_mvc_pseudo_uml" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_mvc_pseudo_uml.jpg" alt="kiwi_mvc_pseudo_uml" width="805" height="626" /></p>
<p>What I want it is to keep as much as I can the &#8220;Soc&#8221; (separation of concern). My service should make what a service should do and if I want to change my repository with a Oracle one, I could change it only by modifying the instantiation of my service (with DI for the future). I want to keep that &#8220;philosophy&#8221; all along the development but philosophy is not obligation.</p>
<p>In the same way, you&#8217;ve certainly noticed that I often return an IQueryable for my &#8220;get&#8221; method (see listing 1). I know this should be better to return a List type cause it is a more &#8220;standard&#8221; and you do not have to use the Linq library. Nevertheless I think I will keep it. I do not want to call to often the .IEnumerable function and also it will be easier to use my filter classes.</p>
<p>As the only developer for this application, I assume my choices. <img src='http://blog.dervalp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  If you have remarks about this, please leave a comment.</p>
<p>Listing 1 : Example of the getPages method who retreive all the page from my db</p>
<pre class="brush: c;">

public IQueryable&lt;Page&gt; getPages()
{

return from p in _db.Posts
where p.Type == &quot;Page&quot;
let lp = getLocalizedPages(p.PostID)
select new Page
{
PageID = p.PostID,
Author = p.Author,
Date = p.Date,
PageLozalized = new LazyList&lt;PageLocalized&gt;(lp),
ModifiedDate = p.ModifiedDate,
Password = p.Password ?? string.Empty,
Permalink = p.Permalink,
Status = p.PostStatusID,
Version = p.RevisionOf

};
}

private IQueryable&lt;PageLocalized&gt; getLocalizedPages(int postID)
{
return from lp in _db.PostCultureDetails
where lp.PostID == postID
select new PageLocalized()
{
Description = lp.Excerpt,
Text = lp.Text,
Title = lp.Title,
LanguageCode = (from culture in _db.Cultures
where culture.CultureID == lp.CultureID
select culture.LanguageCode).SingleOrDefault()

};

}
</pre>
<p><strong>Why I did not use Entity framework ?</strong> I hate when the framework decide for me which object I should use. Also, the time I would spend to make it work as I want is doubtless longer than the time I wrote my custom Linq to Sql Class. Entity framework could be great for simple application but for an application who will grow in the future (as I expect Kiwi will do) I do not think it&#8217;s a good choice.</p>
<p><strong>Why I did not use NHibernate ? </strong>I could have chosen NHibernate, but I absolutely wanted to play with Linq. Also, maybe in the future I could make the data access with it and compare what&#8217;s better for my application. Anyway, this is not the time to do this.</p>
<p>If you have other questions like this, please, do not hesitate.</p>
<p><strong>And now the service :<br />
</strong></p>
<p>As I mentioned, my data access is almost finished (for the moment). I am going to create the services I need for my application. Evidently, always in a TDD approach.</p>
<p><strong>Kiwi Part 4 was bullshit :</strong></p>
<p>Maybe it was but the aim of that post was to show you how to start with TDD. And I know that I was going in front of a wall. Indeed, I had an empty db and the post object was the most connected object. As you know in TDD, you write a test, you write <span style="text-decoration: underline;">some code</span>. I realized that I should have written a lot (before creating the &#8220;SaveFunction&#8221; for it). I needed the category object, the comment object,&#8230; Thus, I begin to create a save function for the category object (alway with a tdd style).</p>
<p>Create the test :</p>
<pre class="brush: text;">
//Spike Test !!!
[TestMethod]
public void SqlPostRepositoryTest_can_add_category()
{

Category category = new Category();
category.CreatedDate = DateTime.Now;
category.CategoryParentID = 0;
var categoryEn = new CategoryLocalized() {Description = &quot;This is a test&quot;, Value = &quot;Software Development&quot;, LangageCode = &quot;EN&quot;};
var categoryFR = new CategoryLocalized() { Description = &quot;Ceci est un test&quot;, Value = &quot;Développement Logiciel&quot;, LangageCode = &quot;FR&quot; };

var list = new LazyList&lt;CategoryLocalized&gt;();
list.Add(categoryEn);
list.Add(categoryFR);

category.LocalizedCategory = list;

_repository.Save(category);

Assert.IsNotNull(category);

}
</pre>
<p>And after the function I need :</p>
<pre class="brush: c;">

//save or add a category

public void Save (Category category)
{
var dbCategory = (from c in _db.Categories
where c.CategoryID == category.CategoryID
select c).SingleOrDefault();
if(dbCategory == null)
{
dbCategory = new SqlRepository.Category();
dbCategory.CreatedDate = DateTime.Now;
dbCategory.ParentID = category.CategoryParentID;
//commit the change to have the id and insert the culture
_db.Categories.InsertOnSubmit(dbCategory);
_db.SubmitChanges();

//foreach culture we have in the objec we add it in the table CategoryCultureDetail
foreach (CategoryLocalized item in category.LocalizedCategory)
{
var dbitem = new CategoryCultureDetail();
//some Object to DB
dbitem.CategoryID = dbCategory.CategoryID;
dbitem.Description = item.Description;
dbitem.Value = item.Value;
dbitem.CultureID =
(from culture in _db.Cultures
where culture.LanguageCode == item.LangageCode
select culture.CultureID).SingleOrDefault();
dbCategory.CategoryCultureDetails.Add(dbitem);
_db.SubmitChanges();
}

}
else
{

foreach (CategoryLocalized item in category.LocalizedCategory)
{
var thisCategoryLocalized = (from cn in _db.CategoryCultureDetails
where cn.CategoryID == category.CategoryID
where cn.CultureID ==   (from culture in _db.Cultures
where culture.LanguageCode == item.LangageCode
select culture.CultureID).SingleOrDefault()
select cn).SingleOrDefault();
thisCategoryLocalized.Description = item.Description;
thisCategoryLocalized.Value = item.Value;
_db.CategoryCultureDetails.InsertOnSubmit(thisCategoryLocalized);
_db.SubmitChanges();

}
}
}
</pre>
<p>Of course, you see the &#8220;final&#8221; result. To have that, I went by little piece of code. Test, write, build, test, write, build, test &#8230;</p>
<p>I also know the test you see above is not a unit test, it is more an integration test or a spike test and it will be deleted or commented in the future.</p>
<p>But the name is <span style="text-decoration: underline;">test driven </span>design and not &#8220;make pure unit test&#8221; design.</p>
<p>NOTE : I know I am saying that each time I post but I will try to add the source code in my codeplex project this afternoon.</p>
<p>UPDATE  : I put the source on code plex, if you would like to see it : http://dervalp.codeplex.com/</p>
<p>I have some troubles with codeplex, I will check this out tomorrow cause I am a bit tired today.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d283').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d283" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;title=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;title=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;title=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;title=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;title=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D+@+http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/&amp;t=Kiwi+MVC.NET+%3A+Why+this%2C+why+that+%3F+I+explain+my+architecture+choices+Part+5+%5Bsource+on+codeplex%5D" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d283').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d283').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.dervalp.com/2009/05/29/kiwi-mvcnet-why-this-why-that-i-explain-my-architecture-choices-part-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kiwi MVC.NET : Let&#8217;s go to TDD ! Part 4</title>
		<link>http://blog.dervalp.com/2009/05/27/kiwi-mvc-lets-go-to-tdd-part-4/</link>
		<comments>http://blog.dervalp.com/2009/05/27/kiwi-mvc-lets-go-to-tdd-part-4/#comments</comments>
		<pubDate>Wed, 27 May 2009 20:24:28 +0000</pubDate>
		<dc:creator>dervalp</dc:creator>
				<category><![CDATA[Kiwi MVC]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[MVC.NET]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://blog.dervalp.com/?p=233</guid>
		<description><![CDATA[So, now that I have introduced TDD in my Agile Page. I will try to use it along all the development of Kiwi.

First, I add to my Test project, 3 folders.

ControllerTest : where I will put all my tests related with a controller.


TestRepositories : there I will create fake repositories, to know if my service [...]]]></description>
			<content:encoded><![CDATA[<p>So, now that I have introduced TDD in my Agile Page. I will try to use it along all the development of Kiwi.</p>
<h3><span id="more-233"></span></h3>
<p>First, I add to my Test project, 3 folders.</p>
<ul>
<li>ControllerTest : where I will put all my tests related with a controller.</li>
</ul>
<ul>
<li>TestRepositories : there I will create fake repositories, to know if my service will work with other repositories.</li>
</ul>
<ul>
<li>IntegrationTest : there I will put all my tests related with the repositories. It will contain some “Spike Test”.</li>
</ul>
<p><img class="alignnone size-full wp-image-258" title="tdd_projects" src="http://blog.dervalp.com/wp-content/uploads/2009/05/tdd_projects.jpg" alt="tdd_projects" width="347" height="269" /></p>
<p>Maybe, I will change this structure in the future.</p>
<p>For this example, you need to have the model Post. This model have some properties and one lazylist of PostLocalized.</p>
<pre class="brush: c;">

public class Post
{
public int PostID { get; set; }
public string Author { get; set; }
public string Status { get; set; }
public DateTime Date { get; set; }
public DateTime ModifiedDate { get; set; }
public string Version { get; set; }
public string Permalink { get; set; }
public string Password { get; set; }
public LazyList&lt;PostLocalized&gt; LocalizedPost { get; set; }
}
public class PostLocalized
{
public string Title { get; set; }
public string Text { get; set; }
public string Excerpt { get; set; }
public string LanguageCode { get; set; }
}
</pre>
<p>Back to the code, I want to create a test which return a list of post form the DB. I created a class SqlCMSRepositoryTest in my IntegrationTest folder.If I write the code in VS (like you can see in the picture here under) VS says me that the function GetAll() does not exsit. Without executing the test, I know that we have to create this function. Normally in a pure TDD way, you should try to rebuild and see if it succeed.  Of course, you will get an error. So, let&#8217;s correct it.</p>
<p><img class="alignnone size-full wp-image-261" title="kiwi_part4_0" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part4_0.jpg" alt="kiwi_part4_0" width="667" height="358" /></p>
<p>To correct it, I create a function GetPosts in the SqlCMSRepositories. Here is the code :</p>
<pre class="brush: c;">
using System.Collections.Generic;
using System.Linq;
using CMS.MVC.Data.SqlRepository;

namespace CMS.MVC.Data
{
public class SqlCMSRespository
{
//the name we changed in the properties of our Linq to Sql class
private DB _db;

//constructor
#region .ctor

//we instanciate the db when we instantciate the SqlCMSRespository
//default constructor
public SqlCMSRespository()
{
_db = new DB();
}

public SqlCMSRespository(DB dataContext)
{
//override the current context with the on passed in
//for TDD
_db = dataContext;
}

#endregion

#region Post

public IQueryable&lt;Post&gt; getPosts()
{
var res = new List&lt;Post&gt;();
return res.AsQueryable();
}

#endregion
}
}
</pre>
<p>When I try to build I receive error, indeed, I instantiated the SqlCMSRepositoryTest in place of the SqlCMSRepository. Also, I should add a reference to the data library and decorate the class with the attribute [TestClass]. Oh it is  a lot of mistakes, isn&#8217;t it ?</p>
<p>After correcting the code, I build the solution and I execute the test with this code :</p>
<pre class="brush: c;">

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using CMS.MVC.Data;

namespace CMS.MVC.Web.Tests
{
[TestClass]
public class SqlCMSRepositoryTest
{
private SqlCMSRespository _repository;

/// &lt;summary&gt;
/// Loading the SqlCMSRepository each time we use the SqlCMSRespositoryTest
/// &lt;/summary&gt;
[TestInitialize]
public void Setup()
{
_repository = new SqlCMSRespository();
}

[TestMethod]
public void can_get_all_post()
{
List&lt;Post&gt; PostList = _repository.getPosts().ToList();
Assert.IsNotNull(PostList);
}

}
}
</pre>
<p>The test passes.</p>
<p><img class="alignnone size-full wp-image-262" title="kiwi_part4_2" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part4_2.jpg" alt="kiwi_part4_2" width="951" height="190" /></p>
<p>So, now I go beyond, I will create another test method. I would like to do the same test but count if there is 2 posts in the db post.</p>
<p>But my db is empty, so before, I write a test &#8220;can_create_post&#8221;.</p>
<pre class="brush: c;">
[TestMethod]
public void can_create_post()
{
Post thisPost = new Post();
thisPost.Author = &quot;dervalp&quot;;
thisPost.Date = DateTime.Now;
thisPost.ModifiedDate = DateTime.Now;
thisPost.Password = string.Empty;
thisPost.Permalink = string.Empty;
thisPost.Version = string.Empty;
thisPost.Status = &quot;Post&quot;;

PostLocalized PostContentEN = new PostLocalized();
PostContentEN.Excerpt = &quot;This is a resum&quot;;
PostContentEN.LanguageCode = &quot;EN&quot;;
PostContentEN.Title = &quot;Titre du post&quot;;
PostContentEN.Text = &quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&quot;;
var ListLocalizedPost = new LazyList&lt;PostLocalized&gt;();
ListLocalizedPost.Add(PostContentEN);
thisPost.LocalizedPost = ListLocalizedPost;

//create the post in the db
_repository.Add(thisPost);

//It the application throw an exception the test will fail
Assert.IsNotNull(thisPost);

}
</pre>
<p>&#8220;thisPost&#8221; is never null but if it will throw you an exception if your test fails. So, I rebuild and execute the test. It fails.</p>
<p>To succeed the test, I add the function, Add() in my SqlCMSRespository :</p>
<pre class="brush: c;">
public void Add(Post post)
{

}
</pre>
<p>So now, I execute the test and It succeeds. As I am stupid, I will create another test. I will make the have_post_one_item_in_db.</p>
<pre class="brush: c;">

[TestMethod]
public void have_post_one_item_in_db()
{
var res = _repository.getPosts();

Assert.AreEqual(1, res.Count());
}
</pre>
<p>Of course, it fails. So to make this test passes, I have to adapt my function add.</p>
<p>I think, you understand the idea now. I will update this post with a more complete SqlCMSRespository class.</p>
<p>Feedback is welcome.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d233').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d233" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.dervalp.com/2009/05/27/kiwi-mvc-lets-go-to-tdd-part-4/&amp;title=Kiwi+MVC.NET+%3A+Let%26%238217%3Bs+go+to+TDD+%21+Part+4" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://blog.dervalp.com/2009/05/27/kiwi-mvc-lets-go-to-tdd-part-4/&amp;title=Kiwi+MVC.NET+%3A+Let%26%238217%3Bs+go+to+TDD+%21+Part+4" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://blog.dervalp.com/2009/05/27/kiwi-mvc-lets-go-to-tdd-part-4/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://blog.dervalp.com/2009/05/27/kiwi-mvc-lets-go-to-tdd-part-4/&amp;title=Kiwi+MVC.NET+%3A+Let%26%238217%3Bs+go+to+TDD+%21+Part+4" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://blog.dervalp.com/2009/05/27/kiwi-mvc-lets-go-to-tdd-part-4/&amp;title=Kiwi+MVC.NET+%3A+Let%26%238217%3Bs+go+to+TDD+%21+Part+4" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://blog.dervalp.com/2009/05/27/kiwi-mvc-lets-go-to-tdd-part-4/&amp;title=Kiwi+MVC.NET+%3A+Let%26%238217%3Bs+go+to+TDD+%21+Part+4" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Kiwi+MVC.NET+%3A+Let%26%238217%3Bs+go+to+TDD+%21+Part+4+@+http://blog.dervalp.com/2009/05/27/kiwi-mvc-lets-go-to-tdd-part-4/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://blog.dervalp.com/2009/05/27/kiwi-mvc-lets-go-to-tdd-part-4/&amp;t=Kiwi+MVC.NET+%3A+Let%26%238217%3Bs+go+to+TDD+%21+Part+4" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d233').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d233').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.dervalp.com/2009/05/27/kiwi-mvc-lets-go-to-tdd-part-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Agile &#8211; Test Driven Design &#8220;Need it or not Need it&#8221;</title>
		<link>http://blog.dervalp.com/2009/05/27/agile-test-driven-design-i-do-need-it/</link>
		<comments>http://blog.dervalp.com/2009/05/27/agile-test-driven-design-i-do-need-it/#comments</comments>
		<pubDate>Wed, 27 May 2009 09:43:34 +0000</pubDate>
		<dc:creator>dervalp</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://blog.dervalp.com/?p=237</guid>
		<description><![CDATA[What my colleagues often say when they hear TDD is :  &#8220;It makes no sense&#8221;, &#8220;We do not need that&#8221;, &#8220;I am doing without TDD since ten years&#8221;.
Indeed, maybe, you do not need it. Indeed, you were doing without it but if you are a developer, you should be open to new technologies, curious and [...]]]></description>
			<content:encoded><![CDATA[<p>What my colleagues often say when they hear TDD is :  &#8220;It makes no sense&#8221;, &#8220;We do not need that&#8221;, &#8220;I am doing without TDD since ten years&#8221;.</p>
<p>Indeed, maybe, you do not need it. Indeed, you were doing without it but if you are a developer, you should be open to new technologies, curious and maybe you should test it before saying that you do not need it.</p>
<p>Main bugs come from stupid errors. If you use TDD, a lot of this (syntax, typo, omission) error will emerge quickly.</p>
<h2><span id="more-237"></span></h2>
<p>To make your code testable you have to understand all the methods and objects you use. I think it is the main reason why some developers fear about TDD cause if you want to simulate your httpcontext for example, you have to understand how a httpcontext works.  Also, to do that, you have to &#8220;mock&#8221;, good tools exist to help developers to setup fake context but It cost you time.</p>
<p>Is it worth? I would say yes. In the end of the process,  you can be self-confident with your code and you can explain to everyone what you are doing without gray area. Moreover, if you change something in your code, you should be able to know if there are side effects or not. You will execute all your tests and if all your tests pass, you are safe. If not, you can immediately  know where you have to change.</p>
<p>The other great thing with TDD is the iterative way. You create a test, it fails, you write some code, you execute the test, if it is ok, you write a new test,&#8230; Like this you feel less overwhelmed by your project.</p>
<p><img class="alignnone size-full wp-image-244" title="tdd_test" src="http://blog.dervalp.com/wp-content/uploads/2009/05/tdd_test.jpg" alt="tdd_test" width="380" height="732" /></p>
<p>The definition from Wikipedia :</p>
<p><em>Test-driven development (TDD) is a software development technique that uses short development iterations based on pre-written test cases that define desired improvements or new functions. Each iteration produces code necessary to pass that iteration&#8217;s tests. Finally, the programmer or team refactors the code to accommodate changes. A key TDD concept is that preparing tests before coding facilitates rapid feedback changes. Note that test-driven development is a software design method, not merely a method of testing.</em></p>
<p>“The act of writing a unit test is more an act of design than of verification.<span> </span>It is also more an act of documentation than of verification.<span> </span>The act of writing a unit test closes a remarkable number of feedback  loops, the least of which is the one pertaining to verification of function”.<a href="http://www.amazon.com/exec/obidos/ASIN/0135974445/ambysoftinc"> Bob Martin</a></p>
<p>I guess it is what a developer should understand. Writing a test is not only test but it a act of design.</p>
<p>For example, we have an application who manage flights in the Airport X. And the client want to see all the flight details who land between 3 PM and 4 PM in that Airport. The questions are : What do you need ? Where do I have to query the data ? Also, maybe you have to deal with 5 or 6 web services.  How are you going to test this function without unit tests ?  Are you going to create a gridview to see the results and go in debug mode ? It is going to be a nightmare. But if you go step by step by using TDD, I am sure it will be easier cause when you will write your tests, you will ask the right questions and you will better understand the domain you are dealing with. It is, &#8220;Think before programming&#8221;.</p>
<p>In conclusion, I am not going to explain how TDD is working. I know some websites explain that better than me. I will give you some links that I&#8217;ve found usefull during my learning process.  Also, maybe my opinion on TDD will change, in that case, I will update this post. As usual, feeback is welcome.</p>
<p>Related Links :</p>
<p><a href="http://www.agiledata.org/essays/tdd.html">Wikipedia</a></p>
<p><a href="http://www.agiledata.org/essays/tdd.html">AgileData</a></p>
<p><a href="http://blog.wekeroad.com/tag/tdd/">Rob Connery</a></p>
<p><a href="http://haacked.com/Tags/TDD/default.aspx">Phil Haack</a></p>
<p>NOTE : For my unit tests, I am using Visual Studio 2008 SP1. I used <a href="http://www.nunit.org/index.php">Nunit</a> in the past but, for me, VS makes a good job with unit test so I&#8217;ve switched. If you have feedback in that topic, you&#8217;re welcome.</p>
<p>NOTE2 : TDD without Mocking is not TDD, I will write a post about that in the future.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d237').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d237" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.dervalp.com/2009/05/27/agile-test-driven-design-i-do-need-it/&amp;title=Agile+%26%238211%3B+Test+Driven+Design+%26%238220%3BNeed+it+or+not+Need+it%26%238221%3B" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://blog.dervalp.com/2009/05/27/agile-test-driven-design-i-do-need-it/&amp;title=Agile+%26%238211%3B+Test+Driven+Design+%26%238220%3BNeed+it+or+not+Need+it%26%238221%3B" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://blog.dervalp.com/2009/05/27/agile-test-driven-design-i-do-need-it/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://blog.dervalp.com/2009/05/27/agile-test-driven-design-i-do-need-it/&amp;title=Agile+%26%238211%3B+Test+Driven+Design+%26%238220%3BNeed+it+or+not+Need+it%26%238221%3B" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://blog.dervalp.com/2009/05/27/agile-test-driven-design-i-do-need-it/&amp;title=Agile+%26%238211%3B+Test+Driven+Design+%26%238220%3BNeed+it+or+not+Need+it%26%238221%3B" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://blog.dervalp.com/2009/05/27/agile-test-driven-design-i-do-need-it/&amp;title=Agile+%26%238211%3B+Test+Driven+Design+%26%238220%3BNeed+it+or+not+Need+it%26%238221%3B" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Agile+%26%238211%3B+Test+Driven+Design+%26%238220%3BNeed+it+or+not+Need+it%26%238221%3B+@+http://blog.dervalp.com/2009/05/27/agile-test-driven-design-i-do-need-it/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://blog.dervalp.com/2009/05/27/agile-test-driven-design-i-do-need-it/&amp;t=Agile+%26%238211%3B+Test+Driven+Design+%26%238220%3BNeed+it+or+not+Need+it%26%238221%3B" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d237').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d237').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.dervalp.com/2009/05/27/agile-test-driven-design-i-do-need-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kiwi MVC.NET : Prepare your data access Part3</title>
		<link>http://blog.dervalp.com/2009/05/26/kiwi-mvc-prepare-your-data-access/</link>
		<comments>http://blog.dervalp.com/2009/05/26/kiwi-mvc-prepare-your-data-access/#comments</comments>
		<pubDate>Tue, 26 May 2009 20:03:45 +0000</pubDate>
		<dc:creator>dervalp</dc:creator>
				<category><![CDATA[Kiwi MVC]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[DB]]></category>
		<category><![CDATA[Localized]]></category>
		<category><![CDATA[MVC.NET]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://blog.dervalp.com/?p=196</guid>
		<description><![CDATA[So, I decide to rebuild a new solution. I will carry on the membership layer later cause I want a system who could use Sql, Active Directory or OpenID for the login and only use Sql for the membership role. I have an idea to do that but as I told you in a previous [...]]]></description>
			<content:encoded><![CDATA[<p>So, I decide to rebuild a new solution. I will carry on the membership layer later cause I want a system who could use Sql, Active Directory or OpenID for the login and only use Sql for the membership role. I have an idea to do that but as I told you in a previous post, a security layer is a kind of plugin. Therefore, we could add it later.</p>
<p>Today, I will show you how I am going to create the models and prepare my data access with the help of LinqToSql class.</p>
<p>I choose to make Kiwi multilingual.</p>
<h2><span id="more-196"></span></h2>
<h2>1) The DB</h2>
<p>I am not a dba, you are welcome with your feedback.</p>
<p>Here is the design I choose :</p>
<p><img class="alignnone size-full wp-image-206" title="kiwi_db" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_db.jpg" alt="kiwi_db" width="833" height="780" /></p>
<h2>2) The models</h2>
<p>I decided to create five objects to begin the project. An object Post, Page, Comment, Tag and Category.</p>
<ul>
<li>The object Post : It is a content of a news (for the moment). A post must be in a category. There are status for this type. A post cannot have subposts. This object is localized</li>
</ul>
<ul>
<li>The object Page : It cannot be a part of a category, the page can have subpages. This object is localized and have the same status (puslihed, offline,&#8230;) than a post object.</li>
</ul>
<ul>
<li>The object Comment : A classic comment object, with the author name, the ip address,&#8230; A comment can have child (qutoes). This object is not localized (for the moment, we could think of an automatic translation but KISS).</li>
</ul>
<ul>
<li>The object Category :  This object contains the post. It is localized by the name.</li>
</ul>
<p>Example for Page:</p>
<p>I use the LazyList pattern (<a href="http://blog.wekeroad.com/blog/lazy-loading-with-the-lazylist/">more info here</a>). I will put the project on codeplex, like this, you will able to browse and download the code.</p>
<pre class="brush: c;">

namespace KIWI.MVC.Data
{
class Page
{
public int PageID { get; set; }
public string Author { get; set; }
public string Status { get; set; }
public DateTime Date { get; set; }
public DateTime ModifiedDate { get; set; }
public string Version { get; set; }
public string Permalink { get; set; }
public string Password { get; set; }
public LazyList&lt;Page&gt; PageChild{ get;set;}
public LazyList&lt;Page&gt; PageLozalized { get; set; }
}
public class PageLocalized
{
public string Title { get; set; }
public string Text { get; set; }
public string Excerpt { get; set; }
public string LanguageCode { get; set; }
}
}
</pre>
<h2>3) The SqlCMSRepository</h2>
<p>This repository will be the link between my object and my db. It will contain all the main method I need. I will always return an IQueryable type.  It will allow you to use the <a href="http://en.wikipedia.org/wiki/Pipes_and_filters">pipeline pattern</a> to create some filter functions.</p>
<ul>
<li>Create a LinqToSql class.</li>
</ul>
<p><img class="alignnone size-full wp-image-212" title="kiwi_linq_to_sql" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_linq_to_sql.jpg" alt="kiwi_linq_to_sql" width="683" height="414" /></p>
<p>After creating the linq to sql class, drop the table you need from the server explorer of visual studio to the dml file.</p>
<p><img class="alignnone size-full wp-image-215" title="kiwi_class_cms" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_class_cms.jpg" alt="kiwi_class_cms" width="253" height="323" /></p>
<p>You will have the representation of you db (like the first page of this post). After, change some properties of you LinqCMSRespository class. Double clik on the LinqCMDRespository.dbml and right click on the screen where your tables appear. Here change the Name to &#8220;DB&#8221;. It is only to use the same name for you future dbml and improve the visibilty of your code.</p>
<p><img class="alignnone size-full wp-image-216" title="kiwi_class_linq_properties" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_class_linq_properties.jpg" alt="kiwi_class_linq_properties" width="311" height="253" /></p>
<p>Build you solution to see if everything goes well.</p>
<p>If you have built successfully, then create you SqlCMSRespository class.</p>
<p>Here is the code :</p>
<pre class="brush: c;">
using CMS.MVC.Data.SqlRepository;

namespace CMS.MVC.Data
{
class SqlCMSRespository
{
//the name we changed in the properties of our Linq to Sql class
private DB _db;

//constructor
#region .ctor

//we instanciate the db when we instantciate the SqlCMSRespository
//default constructor
public SqlCMSRespository()
{
_db = new DB();
}

public SqlCMSRespository(DB dataContext)
{
//override the current context with the on passed in
//for TDD
_db = dataContext;
}

#endregion

#region Post
//there we will put our main functions like GetPost(),...
//But before, let's go to TDD !!!!
//TEST DRIVEN DESIGN
#endregion
}
}
</pre>
<p>Now we are able to begin all our data access method but before writing some code in your repository, we&#8217;ll go with the TDD approach.<br />
And by creating our tests, we will see what we need in our application.</p>
<p>So this is the end for today, as usual, feedback and comments are very appreciated.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d196').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d196" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.dervalp.com/2009/05/26/kiwi-mvc-prepare-your-data-access/&amp;title=Kiwi+MVC.NET+%3A+Prepare+your+data+access+Part3" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://blog.dervalp.com/2009/05/26/kiwi-mvc-prepare-your-data-access/&amp;title=Kiwi+MVC.NET+%3A+Prepare+your+data+access+Part3" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://blog.dervalp.com/2009/05/26/kiwi-mvc-prepare-your-data-access/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://blog.dervalp.com/2009/05/26/kiwi-mvc-prepare-your-data-access/&amp;title=Kiwi+MVC.NET+%3A+Prepare+your+data+access+Part3" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://blog.dervalp.com/2009/05/26/kiwi-mvc-prepare-your-data-access/&amp;title=Kiwi+MVC.NET+%3A+Prepare+your+data+access+Part3" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://blog.dervalp.com/2009/05/26/kiwi-mvc-prepare-your-data-access/&amp;title=Kiwi+MVC.NET+%3A+Prepare+your+data+access+Part3" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Kiwi+MVC.NET+%3A+Prepare+your+data+access+Part3+@+http://blog.dervalp.com/2009/05/26/kiwi-mvc-prepare-your-data-access/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://blog.dervalp.com/2009/05/26/kiwi-mvc-prepare-your-data-access/&amp;t=Kiwi+MVC.NET+%3A+Prepare+your+data+access+Part3" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d196').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d196').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.dervalp.com/2009/05/26/kiwi-mvc-prepare-your-data-access/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kiwi MVC.NET : Authentication Layer, introduction Part2</title>
		<link>http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/</link>
		<comments>http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/#comments</comments>
		<pubDate>Thu, 14 May 2009 12:47:20 +0000</pubDate>
		<dc:creator>dervalp</dc:creator>
				<category><![CDATA[Kiwi MVC]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Membership]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Provider]]></category>
		<category><![CDATA[Role]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://blog.dervalp.com/?p=100</guid>
		<description><![CDATA[I know it is a bit weird to begin a CMS application by implementing a Membership system but the simple raison why I start up with that is because I needed for my work (as you can see in my previous post ).
Too often, I saw developers rewriting their own membership system in place to [...]]]></description>
			<content:encoded><![CDATA[<p>I know it is a bit weird to begin a CMS application by implementing a Membership system but the simple raison why I start up with that is because I needed for my work (as you can see in <a href="http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%C2%BB-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/" target="_blank">my previous post</a> ).</p>
<p>Too often, I saw developers rewriting their own membership system in place to use what the framework (no matter which one) can offer.</p>
<h2><span id="more-100"></span></h2>
<p>It is the main raison why I choose to implement the ASP.NET Membership system in Kiwi.  It has a lot of interesting functionalities but on the other hand it is like riding a big monster.  Thus, I am going to use it as pluggableas as I can do.</p>
<h2>The User Object :</h2>
<p>Today, creating an object called User is being strange. If you want to choose the OOP way, a user is often too generic. If you developed an e-commerce, you will certainly choose customer in place of user. But a customer and an admin can login in your system, so are-you going to create two objects? One called “customer” and the other called “vip”? That sounds weird no?</p>
<p>Here is my point of view. A membership system is for me an additional layer you can implement (or not). It is not the hearth of your application; it is just a security layer. That why I am going to use it without any &#8220;User&#8221; object.  I saw 3 mains services that a Membership system could offer :</p>
<ul>
<li> authentication (who is this guy)</li>
<li>personalization (what the guy like)</li>
<li>authorization (what the guy can do)</li>
</ul>
<h2>Sql membership :</h2>
<p>We saw in one of <a href="http://blog.dervalp.com/2009/05/12/azam-adam-abracanabram-%C2%BB-is-harry-potter-a-dotnet-developer-part-1-membershipprovider/" target="_blank">my previous post</a> that ASP.NET has 2 differents way to manage the membership layer. There we saw the active directory membership provider. Today, we will use the SqlMembershipProvider.</p>
<p>First, to use Sql membership you need a sql server with a database up. Therefore, I went to the Microsoft website to download Sql Server 2008 express and I installed it.</p>
<p>I create an empty db called Kiwi.</p>
<p>Then in the folder &#8220;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727&#8243;, I execute the aspnet_regsql.exe and provide the right information to allow the connection to the database. Finish the setup and let’s take a look on the database called Kiwi:</p>
<p><img class="alignnone size-full wp-image-105" title="kiwi_part2_1" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_1.jpg" alt="kiwi_part2_1" width="413" height="488" /></p>
<p>Now, I configure the Webconfig to use the SqlMemberShipProvider with my application.<br />
Here is the connection string I added to my webconfig file:</p>
<p><img class="alignnone size-full wp-image-107" title="kiwi_part2_2" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_2.jpg" alt="kiwi_part2_2" width="604" height="100" /></p>
<p>To test if everything works well,</p>
<p>Change the name of the connection string under membership to make the connection with your db.</p>
<p><img class="alignnone size-full wp-image-108" title="kiwi_part2_3" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_3.jpg" alt="kiwi_part2_3" width="590" height="336" /></p>
<p>Now make a test, go to the ASP.NET configuration when you are on your MVC.WEB in your website.</p>
<p><img class="alignnone size-full wp-image-109" title="kiwi_part2_4" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_4.jpg" alt="kiwi_part2_4" width="243" height="445" /></p>
<p>You will enter in the Web Site Administation Tool :</p>
<p><img class="alignnone size-full wp-image-110" title="kiwi_part2_5" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_5.jpg" alt="kiwi_part2_5" width="628" height="381" /></p>
<p>If you click on Security you will access a page where you can manage the users, the roles and the access rules.<br />
For the test, click on the “Create User” link and create one :<br />
<img class="alignnone size-full wp-image-111" title="kiwi_part2_6" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_6.jpg" alt="kiwi_part2_6" width="570" height="308" /></p>
<p>Create the user and go to the server explorer on your Visual Studio. If you do not have a connection to your db yet in server explorer, add it.</p>
<p><img class="alignnone size-full wp-image-112" title="kiwi_part2_7" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_7.jpg" alt="kiwi_part2_7" width="347" height="508" /></p>
<p>On the table aspnet_Users, right-click on Show Table Data and you will see the user you created above.</p>
<p><img class="alignnone size-full wp-image-113" title="kiwi_part2_8" src="http://blog.dervalp.com/wp-content/uploads/2009/05/kiwi_part2_8.jpg" alt="kiwi_part2_8" width="628" height="62" /></p>
<p>Cool stuff isn’t it ?<br />
Now we have a db called Kiwi with some tables created by the .NET framwork.<br />
The web application can connect to the Kiwi database and you are now able to manage user with the ASP.NET administation tools.</p>
<p>In the next post : I will begin to code with the Test driven design approach. I will create the different layer we need in our repository to make the authentication working.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d100').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d100" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;title=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;title=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;title=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;title=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;title=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2+@+http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/&amp;t=Kiwi+MVC.NET+%3A+Authentication+Layer%2C+introduction+Part2" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d100').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d100').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.dervalp.com/2009/05/14/kiwi-mvc-authentication-layer-introduction-part2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Kiwi MVC.NET : Building the application Part1</title>
		<link>http://blog.dervalp.com/2009/05/08/kiwi-mvc-building-the-application-part1/</link>
		<comments>http://blog.dervalp.com/2009/05/08/kiwi-mvc-building-the-application-part1/#comments</comments>
		<pubDate>Fri, 08 May 2009 14:57:39 +0000</pubDate>
		<dc:creator>dervalp</dc:creator>
				<category><![CDATA[Kiwi MVC]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[MVC.NET]]></category>
		<category><![CDATA[SoC]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://www.blog.dervalp.com/?p=7</guid>
		<description><![CDATA[In this part, I am going to explain you how to setup an MVC .Net application.
I will tell you often &#8220;I am not a senior .Net developer&#8221;, I assume that I can make some faults and have totally wrong. If you think I am, do not hesitate to contact me at pierre@dervalp.com or leave me [...]]]></description>
			<content:encoded><![CDATA[<p>In this part, I am going to explain you how to setup an MVC .Net application.</p>
<p>I will tell you often &#8220;I am not a senior .Net developer&#8221;, I assume that I can make some faults and have totally wrong. If you think I am, do not hesitate to contact me at <a href="mailto:pierre@dervalp.com">pierre@dervalp.com</a> or leave me a comment in this blog. I would enjoy discussing with you. I am open-mind and I know I am far to know everything in software development. This blog would pretend to help people like me to find their way to make a MVC application using TDD and implement some well-known patterns.</p>
<h2><span id="more-7"></span></h2>
<h2>1.       Configuration</h2>
<p>Before you can start building websites with ASP.NET MVC, you need to install the following free software:</p>
<ul>
<li><!--[if !supportLists]--><span>.NET Framework version 3.5 with Service Pack 1</span></li>
<li><span>Visual Web Developer 2008 Express with Service Pack 1 </span></li>
<li><span style="font-size: 11pt; line-height: 115%; font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">ASP.NET MVC 1.0</span></li>
</ul>
<p>You can also download the Microsoft Webforms installer 2.0 beta which is a nice tool.</p>
<h2>2.       What is MVC Framework</h2>
<p>Microsoft is certainly better than me to explain this, so here is what they say:</p>
<p>ASP.NET MVC is a free and fully supported Microsoft framework for building web applications that use a model-view-controller pattern. Like ASP.NET Web Forms, ASP.NET MVC is built on the ASP.NET framework.</p>
<p>ASP.NET MVC provides the following benefits:</p>
<ul class="unIndentedList">
<li> Clear separation of concerns</li>
<li> Testability &#8211; support for Test-Driven Development</li>
<li> Fine-grained control over HTML and JavaScript</li>
<li> Intuitive URLs</li>
</ul>
<p>If you would like to know more in the pattern model-view-controller, I invite you to read these links (if you have others interesting link, please contact me and I will edit this post):</p>
<p>-          <a href="http://en.wikipedia.org/wiki/Model-view-controller">http://en.wikipedia.org/wiki/Model-view-controller</a></p>
<p>-          <a href="http://msdn.microsoft.com/en-us/library/ms978748.aspx">http://msdn.microsoft.com/en-us/library/ms978748.aspx</a></p>
<p><img class="aligncenter size-full wp-image-19" title="kiwi1-1" src="http://www.blog.dervalp.com/wp-content/uploads/2009/05/kiwi1-1.jpg" alt="kiwi1-1" width="322" height="163" /></p>
<h2>3.       Hey oh let&#8217;s go!</h2>
<p>I know I will not work under source control, we will see that later if I needed.</p>
<p>First step, Start you visual studio 2008, File -&gt; new -&gt; Project</p>
<p>You receive this tab:</p>
<p>-          I decided to call my CMS Kiwi because it sounds sunny and funny.</p>
<p>Name: Kiwi.MVC.web. I would take a pseudo naming convention for this project. I do not know if it is the better but if it does not fit in the future, we&#8217;ll change it but I do not think it is the most important thing for the moment.</p>
<p>Location: Personally, I work with an external hard drive where I put my sources. As I do not work in source control, I take a back-up every day and I send it to my Gmail. I know it&#8217;s a bit dirty&#8230;</p>
<p><img class="aligncenter size-full wp-image-22" title="kiwi1-2" src="http://www.blog.dervalp.com/wp-content/uploads/2009/05/kiwi1-2.jpg" alt="kiwi1-2" width="628" height="452" /></p>
<p>So, I create the project and VS pops up a window about creating a Unit Test Project:</p>
<p>This project will receive all my unit tests during the development</p>
<p>I change the name to /*My project name*/.MVC.Tests and let&#8217;s go&#8230;</p>
<p><img class="aligncenter size-full wp-image-24" title="kiwi1-3" src="http://www.blog.dervalp.com/wp-content/uploads/2009/05/kiwi1-3.jpg" alt="kiwi1-3" width="475" height="321" /></p>
<h2>4.       The Service project and the data project</h2>
<p>I know what I am going to do is not the best way but I feel comfortable with that.</p>
<p>I add a new class library called Kiwi.MVC.Data to receive my model and another called Kiwi.MVC.Services who will receive my services.</p>
<p>I clean a bit and here is the result:</p>
<p><img class="aligncenter size-full wp-image-25" title="kiwi1-4" src="http://www.blog.dervalp.com/wp-content/uploads/2009/05/kiwi1-4.jpg" alt="kiwi1-4" width="237" height="163" /></p>
<p>Before saving the solution, I would like to set up the behavior of VS. I want that VS stratup the project I am currently working on and not Kiwi.MVC.Web as it is by default. To do that, right click on your solution, properties and you receive that screen:</p>
<p><img class="aligncenter size-full wp-image-26" title="kiwi1-5" src="http://www.blog.dervalp.com/wp-content/uploads/2009/05/kiwi1-5.jpg" alt="kiwi1-5" width="628" height="386" /></p>
<p>In the Startup Project, use Current selection in place of Single startup project.</p>
<p>I try to build the solution and if it builds successfully, I have now an empty project ready to go&#8230;</p>
<p>You can find the source of the empty project in Codeplex : here <a href="http://dervalp.codeplex.com/">http://dervalp.codeplex.com</a></p>
<p>I am waiting for your feedback&#8230;</p>
<h2>5.      My opinion about MVC:</h2>
<p><em>&#8220;I have never like the webforms style of ASP.NET and this MVC framework is like a breath of fresh air for me. I used MVC pattern with Cakephp and I am very exited to discover all the possibilities of the ASP.NET MVC framework. I guess Microsoft is taking the right way to build powerfull web application while complying best practises.&#8221;</em></p>
<p><em></p>
<p></em></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d7').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d7" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://blog.dervalp.com/2009/05/08/kiwi-mvc-building-the-application-part1/&amp;title=Kiwi+MVC.NET+%3A+Building+the+application+Part1" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://blog.dervalp.com/2009/05/08/kiwi-mvc-building-the-application-part1/&amp;title=Kiwi+MVC.NET+%3A+Building+the+application+Part1" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://blog.dervalp.com/2009/05/08/kiwi-mvc-building-the-application-part1/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://blog.dervalp.com/2009/05/08/kiwi-mvc-building-the-application-part1/&amp;title=Kiwi+MVC.NET+%3A+Building+the+application+Part1" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://blog.dervalp.com/2009/05/08/kiwi-mvc-building-the-application-part1/&amp;title=Kiwi+MVC.NET+%3A+Building+the+application+Part1" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://blog.dervalp.com/2009/05/08/kiwi-mvc-building-the-application-part1/&amp;title=Kiwi+MVC.NET+%3A+Building+the+application+Part1" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Kiwi+MVC.NET+%3A+Building+the+application+Part1+@+http://blog.dervalp.com/2009/05/08/kiwi-mvc-building-the-application-part1/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://blog.dervalp.com/2009/05/08/kiwi-mvc-building-the-application-part1/&amp;t=Kiwi+MVC.NET+%3A+Building+the+application+Part1" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.dervalp.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d7').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d7').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.dervalp.com/2009/05/08/kiwi-mvc-building-the-application-part1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
