<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>AzamSharp</title>
        <link>http://geekswithblogs.net/AzamSharp/Default.aspx</link>
        <description>Some day I will know everything. I hope that day never comes.</description>
        <language>en-US</language>
        <copyright>Mohammad Azam</copyright>
        <managingEditor>azamsharp@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <image>
            <title>AzamSharp</title>
            <url>http://geekswithblogs.net/images/RSS2Image.gif</url>
            <link>http://geekswithblogs.net/AzamSharp/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Select All CheckBoxes in GridView Using JQuery</title>
            <link>http://geekswithblogs.net/AzamSharp/archive/2008/05/10/122048.aspx</link>
            <description>&lt;p&gt;Selecting checkboxes inside the GridView control is a very common operation and that is why I have several articles and videos dedicated to this subject. &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.gridviewguy.com/Articles/228_GridView_CheckBox_Selection_With_a_Twist.aspx"&gt;Selecting CheckBoxes Inside GridView With a Twist&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.gridviewguy.com/Videos/397_Selecting_CheckBoxes_Inside_GridView_Control.aspx"&gt;VIDEO: Selecting CheckBoxes Inside GridView&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Recently, I was playing around with &lt;a href="http://jquery.com/"&gt;JQuery&lt;/a&gt; library and thought of implementing the same scenario using the library. Here is the code used to perform the SelectAll and DeSelectAll function. &lt;/p&gt; &lt;p&gt;&amp;lt;script language="javascript" type="text/javascript"&amp;gt;&lt;/p&gt; &lt;p&gt;$(document).ready(function() &lt;br /&gt;{&lt;br /&gt;    $("#chkAll").click(function() &lt;br /&gt;    {&lt;br /&gt;        // I don't like this line!     &lt;br /&gt;        this.checked = !(this.checked == true); &lt;br /&gt;    &lt;br /&gt;        $("#gvCategories input:checkbox").attr("checked",function() &lt;br /&gt;        {&lt;br /&gt;            this.checked = !(this.checked == true); &lt;br /&gt;        });&lt;br /&gt;        &lt;br /&gt;    });&lt;br /&gt;});&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/p&gt; &lt;p&gt;Yup! that's all the code you need to perform this operation. If you think you can even refactor this out then please post your refactorings at &lt;a href="http://refactorcode.com/Refactorings/17_Selecting_All_CheckBoxes_of_the_CheckBoxList_Control.aspx"&gt;Selecting CheckBoxes Inside the Table&lt;/a&gt;. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122048"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122048" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AzamSharp/aggbug/122048.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Azam</dc:creator>
            <guid>http://geekswithblogs.net/AzamSharp/archive/2008/05/10/122048.aspx</guid>
            <pubDate>Sat, 10 May 2008 22:52:29 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AzamSharp/comments/122048.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AzamSharp/archive/2008/05/10/122048.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/AzamSharp/comments/commentRss/122048.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/AzamSharp/services/trackbacks/122048.aspx</trackback:ping>
        </item>
        <item>
            <title>Two New Features to www.RefactorCode.com</title>
            <link>http://geekswithblogs.net/AzamSharp/archive/2008/05/09/122035.aspx</link>
            <description>&lt;p&gt;I just added few more features to &lt;a href="http://www.RefactorCode.com"&gt;www.RefactorCode.com&lt;/a&gt;. These features include the following: &lt;/p&gt; &lt;p&gt;1) My Refactorings Page: The "My Refactorings" page simply displays the posts that the user has made and the posts that user has participated in. &lt;/p&gt; &lt;p&gt;2) Categories Menu Updated. The Categories menu have been updated and now it displays the number of posts in the particular category.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;There are many different features that I am currently working on which includes rating the refactored code, option to follow the thread using email etc. &lt;/p&gt; &lt;p&gt;Come on let's refactor! &lt;/p&gt; &lt;p&gt;&lt;img src="http://farm3.static.flickr.com/2177/2479865320_c7fef09a1b.jpg" /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122035"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=122035" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AzamSharp/aggbug/122035.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Azam</dc:creator>
            <guid>http://geekswithblogs.net/AzamSharp/archive/2008/05/09/122035.aspx</guid>
            <pubDate>Sat, 10 May 2008 03:33:01 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AzamSharp/comments/122035.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AzamSharp/archive/2008/05/09/122035.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/AzamSharp/comments/commentRss/122035.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/AzamSharp/services/trackbacks/122035.aspx</trackback:ping>
        </item>
        <item>
            <title>ASP.NET MVC Framework Videos on ASPALLIANCE</title>
            <link>http://geekswithblogs.net/AzamSharp/archive/2008/05/08/121998.aspx</link>
            <description>&lt;p&gt;ASP.NET MVC is going pretty HOT these days so I thought I should post some links to the ASP.NET MVC Videos which are hosted on &lt;a href="http://www.AspAlliance.com"&gt;www.AspAlliance.com&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;&lt;a href="http://aspalliance.com/1561_Video_Introduction_to_the_ASPNET_MVC_Framework"&gt;&lt;font color="#0000ff"&gt;Video: Introduction to the ASP.NET MVC Framework&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://aspalliance.com/1568_Video_ASPNET_MVC_Framework_Unit_Testing"&gt;&lt;font color="#0000ff"&gt;Video: ASP.NET MVC Framework Unit Testing&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://aspalliance.com/1575_Video_Passing_Parameters_Across_Pages_Using_ASPNET_MVC_Framework"&gt;&lt;font color="#0000ff"&gt;Video: Passing Parameters Across Pages Using ASP.NET MVC Framework&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://aspalliance.com/1581_Video_Url_Rewriting_Using_ASPNET_MVC_Framework"&gt;&lt;font color="#0000ff"&gt;Video: Url Rewriting Using ASP.NET MVC Framework&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://aspalliance.com/1594_Video_Introduction_to_the_MVC_Toolkit"&gt;&lt;font color="#0000ff"&gt;Video: Introduction to the MVC Toolkit&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://aspalliance.com/1608_Video_Using_JavaScript_with_the_ASPNET_MVC_Framework_"&gt;&lt;font color="#0000ff"&gt;Video: Using JavaScript with the ASP.NET MVC Framework&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://aspalliance.com/1620_Video_Implementing_Controller_Action_Authentication_in_the_ASPNET_MVC_Framework"&gt;&lt;font color="#0000ff"&gt;Video: Implementing Controller Action Authentication in the ASP.NET MVC Framework&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://aspalliance.com/1629_Video_Caching_ASPNET_MVC_Controller_Actions"&gt;&lt;font color="#0000ff"&gt;Video: Caching ASP.NET MVC Controller Actions&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://aspalliance.com/1634_Video_Authenticating_Controller_Actions_Using_Custom_Role_Filter"&gt;&lt;font color="#0000ff"&gt;Video: Authenticating Controller Actions Using Custom Role Filter&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://aspalliance.com/1638_Video_Compressing_HttpResponse_Using_ASPNET_MVC_Framework"&gt;&lt;font color="#0000ff"&gt;Video: Compressing HttpResponse Using ASP.NET MVC Framework&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;All the videos are totally FREE the only thing you need to do is to set up an account on AspAlliance and that's it. There are more than 90 videos hosted on AspAlliance covering different aspects of the .NET technology. &lt;/p&gt; &lt;p&gt;Enjoy!&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121998"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121998" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AzamSharp/aggbug/121998.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Azam</dc:creator>
            <guid>http://geekswithblogs.net/AzamSharp/archive/2008/05/08/121998.aspx</guid>
            <pubDate>Thu, 08 May 2008 17:17:34 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AzamSharp/comments/121998.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AzamSharp/archive/2008/05/08/121998.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/AzamSharp/comments/commentRss/121998.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/AzamSharp/services/trackbacks/121998.aspx</trackback:ping>
        </item>
        <item>
            <title>UrlRewrite Using RewritePath Article Published</title>
            <link>http://geekswithblogs.net/AzamSharp/archive/2008/05/06/121949.aspx</link>
            <description>&lt;p&gt;I have just published an article on &lt;a href="http://www.gridviewguy.com"&gt;www.gridviewguy.com&lt;/a&gt;. The article explores the workings of URL Rewriting mechanism using RewritePath. You can check out the article using the link below: &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.gridviewguy.com/ArticleDetails.aspx?articleID=402_Url_Rewriting_Using_RewritePath"&gt;Url Rewriting Using RewritePath&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121949"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121949" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AzamSharp/aggbug/121949.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Azam</dc:creator>
            <guid>http://geekswithblogs.net/AzamSharp/archive/2008/05/06/121949.aspx</guid>
            <pubDate>Wed, 07 May 2008 02:36:49 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AzamSharp/comments/121949.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AzamSharp/archive/2008/05/06/121949.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/AzamSharp/comments/commentRss/121949.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/AzamSharp/services/trackbacks/121949.aspx</trackback:ping>
        </item>
        <item>
            <title>UrlRewriting Pains and Fixes!!!</title>
            <link>http://geekswithblogs.net/AzamSharp/archive/2008/05/06/121933.aspx</link>
            <description>&lt;p&gt;&lt;/p&gt; &lt;p&gt;When developing &lt;a href="http://www.RefactorCode.com"&gt;www.RefactorCode.com&lt;/a&gt; I was advised to create friendly URLS so that search engines like Google, Yahoo, Live Search etc would be able to index it. &lt;a href="http://flux88.com/"&gt;Ben Sheirman&lt;/a&gt; suggested that I should try out IRouteHandler interface which was originally part of the &lt;a href="http://asp.net/mvc/"&gt;ASP.NET MVC Framework&lt;/a&gt;. I implemented the URL-Rewriting solution which worked on my local machine but failed on the production. The web host guys told me that currently they don't support ASP.NET 3.5 Extensions Preview (I don't think that was the problem.)&lt;/p&gt; &lt;p&gt;My next solution involved using the RewritePath method of ASP.NET. For that I created a small class called "Route" which will hold the new routes. &lt;/p&gt; &lt;p&gt; public class Route&lt;br /&gt;    {&lt;br /&gt;        private string _key;&lt;br /&gt;        private string _url;&lt;/p&gt; &lt;p&gt;        public string Key&lt;br /&gt;        {&lt;br /&gt;            get { return _key; }&lt;br /&gt;            set { _key = value; }&lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;        public string Url&lt;br /&gt;        {&lt;br /&gt;            get { return _url; }&lt;br /&gt;            set { _url = value; }&lt;br /&gt;        } &lt;br /&gt;    }&lt;/p&gt; &lt;p&gt;The routes are setup in the Application_Start event in the Global.asax file. &lt;/p&gt; &lt;p&gt;public class Global : System.Web.HttpApplication&lt;br /&gt;    {&lt;br /&gt;        private static List&amp;lt;Route&amp;gt; routes = null;&lt;/p&gt; &lt;p&gt;        protected void Application_Start(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // initialize the routes &lt;br /&gt;            routes = new List&amp;lt;Route&amp;gt;()&lt;br /&gt;            { new Route() { Key = "Categories", Url = "~/ProductsByCategory.aspx?id=" },&lt;br /&gt;                 new Route() { Key = "Refactorings", Url = "~/SubmissionDetails.aspx?id=" }&lt;br /&gt;            };&lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;     public static List&amp;lt;Route&amp;gt; GetRoutes()&lt;br /&gt;        {&lt;br /&gt;            return routes; &lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;In the above code I am setting up two routes one for the Categories key and the other for the Refactorings key. The HttpModule "UrlRewrite" is used to forward the route to the correct address.&lt;/p&gt; &lt;p&gt;public class UrlRewrite : IHttpModule&lt;br /&gt;    {       &lt;/p&gt; &lt;p&gt;        public void Dispose()&lt;br /&gt;        {&lt;br /&gt;                   &lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;        public void Init(HttpApplication httpApplication)&lt;br /&gt;        {&lt;br /&gt;            // attach the begin request!&lt;br /&gt;            httpApplication.BeginRequest += new EventHandler(httpApplication_BeginRequest);         &lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;        void httpApplication_BeginRequest(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            RegisterRoutes();&lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;       &lt;br /&gt;        // Register the routes!        &lt;br /&gt;        private static void RegisterRoutes()&lt;br /&gt;        {&lt;br /&gt;            HttpContext context = HttpContext.Current; &lt;br /&gt;            string oldPath = context.Request.Url.ToString();&lt;/p&gt; &lt;p&gt;            var newRoute = (from route in Global.GetRoutes()&lt;br /&gt;                            where oldPath.IndexOf(route.Key) &amp;gt; -1&lt;br /&gt;                            select route).SingleOrDefault();&lt;/p&gt; &lt;p&gt;            if (newRoute == null) return;&lt;/p&gt; &lt;p&gt;            int i = oldPath.IndexOf(newRoute.Key);&lt;br /&gt;           &lt;br /&gt;                if (i &amp;gt; -1)&lt;br /&gt;                {&lt;br /&gt;                    int underScoreIndex = oldPath.IndexOf("_");&lt;br /&gt;                    int startIndex = (i + newRoute.Key.Length + 1);&lt;br /&gt;                    int numberOfCharacters = underScoreIndex - startIndex;&lt;/p&gt; &lt;p&gt;                    int id = Int32.Parse(oldPath.Substring(startIndex, numberOfCharacters));&lt;br /&gt;                    context.RewritePath(newRoute.Url + id, false);&lt;br /&gt;                }                                 &lt;br /&gt;        }       &lt;br /&gt;    }&lt;/p&gt; &lt;p&gt;Now, I need to display list of items with a custom URL. Here is the implementation of the CreateFriendlyUrlsForCategories method which is used to create custom URLS: &lt;/p&gt; &lt;p&gt; public static string CreateFriendlyUrlsForCategories(int id, string title)&lt;br /&gt;        {&lt;br /&gt;            return String.Format("Categories/{0}_{1}", id, title.Replace(" ","_")); &lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;This will generate the following URL: &lt;/p&gt; &lt;p&gt;&lt;img src="http://farm3.static.flickr.com/2218/2470489669_0aa82e60c9.jpg" /&gt; &lt;/p&gt; &lt;p&gt;This is much cleaner than &lt;a href="http://localhost:1688/ProductsByCategory?id=10"&gt;http://localhost:1688/ProductsByCategory?id=10&lt;/a&gt;. This will work fine on your local machine but as soon as you deploy it to the production it will result in a "404 Page Not Found" error. After much research and hair pulling I concluded that IIS6 is not capable of handling URLS with no file extensions (Please correct me if my assumption is wrong). So, to fix this problem I made a small change in my CreateFriendlyUrlsForCategories method. &lt;/p&gt; &lt;p&gt; public static string CreateFriendlyUrlsForCategories(int id, string title)&lt;br /&gt;        {&lt;br /&gt;            return String.Format("Categories/{0}_{1}&lt;strong&gt;&lt;font size="4"&gt;.aspx&lt;/font&gt;&lt;/strong&gt;", id, title.Replace(" ","_")); &lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;Now, the requests for the pages will succeed and they will be routed correctly. I am pretty sure that you can also use the IRouteHandler for UrlRewriting with this change it will work correctly. Now the URLS will be generated like this: &lt;/p&gt; &lt;p&gt;&lt;img src="http://farm4.static.flickr.com/3174/2471487752_5d62d34dea_o.jpg" /&gt; &lt;/p&gt; &lt;p&gt;One other thing that you must be careful with is using the ResolveUrl method when creating friendly URLs. Check out the code below: &lt;/p&gt; &lt;p&gt;&amp;lt;asp:Repeater ID="repCategories" runat="server"&amp;gt;&lt;/p&gt; &lt;p&gt;&amp;lt;ItemTemplate&amp;gt;&lt;/p&gt; &lt;p&gt;&amp;lt;div&amp;gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&amp;lt;asp:HyperLink ID="hlCategoryName" NavigateUrl='&amp;lt;%# ResolveUrl(UrlRewritingDemo.Helpers.SiteHelper.CreateFriendlyUrlsForCategories((int)Eval("id"),(string)Eval("CategoryName"))) %&amp;gt;'&lt;br /&gt; runat="server" Text='&amp;lt;%# Eval("CategoryName") %&amp;gt;' /&amp;gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&amp;lt;/div&amp;gt;&lt;/p&gt; &lt;p&gt;&amp;lt;/ItemTemplate&amp;gt;&lt;/p&gt; &lt;p&gt;&amp;lt;/asp:Repeater&amp;gt;&lt;/p&gt; &lt;p&gt;The ResolveUrl will make sure that the URL you are referring is correct even though you are inside sub directories. &lt;/p&gt; &lt;p&gt;I will write an article on this topic and publish a link to that article on this post. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121933"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121933" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AzamSharp/aggbug/121933.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Azam</dc:creator>
            <guid>http://geekswithblogs.net/AzamSharp/archive/2008/05/06/121933.aspx</guid>
            <pubDate>Tue, 06 May 2008 17:01:52 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AzamSharp/comments/121933.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AzamSharp/archive/2008/05/06/121933.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/AzamSharp/comments/commentRss/121933.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/AzamSharp/services/trackbacks/121933.aspx</trackback:ping>
        </item>
        <item>
            <title>RefactorCode Released!!! ..... BETA :)</title>
            <link>http://geekswithblogs.net/AzamSharp/archive/2008/05/03/121874.aspx</link>
            <description>&lt;p&gt;For the past couple of days I have been working on a new website called &lt;a href="http://www.RefactorCode.com"&gt;www.RefactorCode.com&lt;/a&gt;. The purpose of the website is that user's can submit their code and other users can help to improve the existing code hence, refactoring the code. Below you can read the "&lt;strong&gt;About&lt;/strong&gt;" section of the RefactorCode website. &lt;/p&gt; &lt;p&gt;Refactoring is a technique to change the existing ugly code and make it beautiful without changing the workings of the code. &lt;br /&gt;In short, making the code suck less! &lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;Our website RefactorCode is developed to help developers refactor the code, therefore improving programming skills and overcome many challenges one faces when coding. You can submit your ugly code and other developers can find ways to improve it. &lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;Presenting to you, your very own refractor code station!&lt;/p&gt; &lt;p&gt;The website is currently in &lt;strong&gt;BETA&lt;/strong&gt; version but you will still be able to post your code and get refactorings. I would like to thank &lt;a href="http://aspadvice.com/blogs/ssmith/"&gt;Steven Smith&lt;/a&gt; for his help in coming up with a nice logo and &lt;a href="http://flux88.com/"&gt;Ben Scheirman&lt;/a&gt; for his help and contributions. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.refactorcode.com" atomicselection="true"&gt;&lt;img src="http://farm3.static.flickr.com/2388/2462742978_c689f218cc.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121874"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121874" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AzamSharp/aggbug/121874.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Azam</dc:creator>
            <guid>http://geekswithblogs.net/AzamSharp/archive/2008/05/03/121874.aspx</guid>
            <pubDate>Sat, 03 May 2008 21:40:43 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AzamSharp/comments/121874.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AzamSharp/archive/2008/05/03/121874.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/AzamSharp/comments/commentRss/121874.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/AzamSharp/services/trackbacks/121874.aspx</trackback:ping>
        </item>
        <item>
            <title>Silverlight BETA 1 Installation Messed Up!!!!!!</title>
            <link>http://geekswithblogs.net/AzamSharp/archive/2008/04/29/121770.aspx</link>
            <description>&lt;p&gt;It seems like the installation part of this product is totally messed up. Take a look at the image below in which the left window is running a game created in Silverlight BETA 1 and the right window is displaying the message saying "Install Silverlight". The installation part of the Silverlight is completely messed up!!!!!&lt;/p&gt; &lt;p&gt;&lt;img src="http://farm4.static.flickr.com/3079/2453012018_178a58ca1a_b.jpg" /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121770"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121770" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AzamSharp/aggbug/121770.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Azam</dc:creator>
            <guid>http://geekswithblogs.net/AzamSharp/archive/2008/04/29/121770.aspx</guid>
            <pubDate>Tue, 29 Apr 2008 20:54:08 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AzamSharp/comments/121770.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AzamSharp/archive/2008/04/29/121770.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/AzamSharp/comments/commentRss/121770.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/AzamSharp/services/trackbacks/121770.aspx</trackback:ping>
        </item>
        <item>
            <title>PODCAST: Introduction to the ASP.NET MVC Framework</title>
            <link>http://geekswithblogs.net/AzamSharp/archive/2008/04/28/121734.aspx</link>
            <description>&lt;p&gt;I just published a new podcast on &lt;a href="http://www.gridviewguy.com"&gt;www.gridviewguy.com&lt;/a&gt;. In the podcast I talk about the new ASP.NET MVC Framework. You can download the podcast using the link below: &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.gridviewguy.com/ArticleDetails.aspx?articleID=400_Introduction_to_the_ASP.NET_MVC_Framework"&gt;Introduction to the ASP.NET MVC Framework&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121734"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121734" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AzamSharp/aggbug/121734.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Azam</dc:creator>
            <guid>http://geekswithblogs.net/AzamSharp/archive/2008/04/28/121734.aspx</guid>
            <pubDate>Tue, 29 Apr 2008 03:27:54 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AzamSharp/comments/121734.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AzamSharp/archive/2008/04/28/121734.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/AzamSharp/comments/commentRss/121734.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/AzamSharp/services/trackbacks/121734.aspx</trackback:ping>
        </item>
        <item>
            <title>Creating Bar Chart Using .NET Graphics API =&amp;gt; Article Published</title>
            <link>http://geekswithblogs.net/AzamSharp/archive/2008/04/27/121702.aspx</link>
            <description>&lt;p&gt;I just published an article on &lt;a href="http://www.gridviewguy.com"&gt;www.gridviewguy.com&lt;/a&gt;. The article demonstrates how to create simple bar charts using the graphics API provided by the .NET API. You can check out the article using the following link: &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.gridviewguy.com/ArticleDetails.aspx?articleID=399_Creating_Bar_Chart_Using_.NET_Graphics_API"&gt;Creating Bar Charts Using .NET Graphics API&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121702"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121702" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AzamSharp/aggbug/121702.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Azam</dc:creator>
            <guid>http://geekswithblogs.net/AzamSharp/archive/2008/04/27/121702.aspx</guid>
            <pubDate>Mon, 28 Apr 2008 03:13:07 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AzamSharp/comments/121702.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AzamSharp/archive/2008/04/27/121702.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/AzamSharp/comments/commentRss/121702.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/AzamSharp/services/trackbacks/121702.aspx</trackback:ping>
        </item>
        <item>
            <title>Understanding Mock Objects</title>
            <link>http://geekswithblogs.net/AzamSharp/archive/2008/04/27/121695.aspx</link>
            <description>&lt;p&gt;Mock object is basically a mirage of the real object as they posses the same qualities by don't do anything. Mock objects really shines when working with some entity that continuously changes like time, temperature, air speed etc. In this post I will introduce mock objects and how can they be useful when unit testing such entities. &lt;/p&gt; &lt;p&gt;I took the idea from a great article published on &lt;a href="http://www.aspalliance.com"&gt;AspAlliance&lt;/a&gt;. The article "&lt;a href="http://aspalliance.com/1400_Beginning_to_Mock_with_Rhino_Mocks_and_MbUnit__Part_1"&gt;Beginning to Mock Using Rhino Mocks and MbUnit&lt;/a&gt;" is written by &lt;a href="http://aspalliance.com/author.aspx?uId=60607"&gt;Ben Hall&lt;/a&gt;. The idea is that we are testing that your method returns the correct image. The correctness of the image depends on the time of the day. So, if it is day time then "sun.jpg" is returned and if it is night time then "moon.jpg" is returned. Let's first see the implementation without using the Mock objects. &lt;/p&gt; &lt;p&gt; [Test]&lt;br /&gt;        public void should_return_sun_image_when_it_is_day_time()&lt;br /&gt;        {&lt;br /&gt;            string imageName = ImageOfTheDayService.GetImage(DateTime.Now);&lt;br /&gt;            Assert.AreEqual(imageName, "sun.jpg");&lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;The above method is used to test for the image during the day time. Let's check out the implementation of the ImageOfTheDayService.GetImage method. &lt;/p&gt; &lt;p&gt;  public static string GetImage(DateTime dt)&lt;br /&gt;        {&lt;br /&gt;            int hour = dt.Hour;&lt;/p&gt; &lt;p&gt;            if (hour &amp;gt; 6 &amp;amp;&amp;amp; hour &amp;lt; 21) return "sun.jpg";&lt;/p&gt; &lt;p&gt;            return "moon.jpg";       &lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;The problem is that you can only test the day time result during the day and the night time result during night. This is inconvenient. You can hack the implementation of your tests and force the day time and night time to happen. Check out the implementation below: &lt;/p&gt; &lt;p&gt; [Test]&lt;br /&gt;        public void should_return_sun_image_when_it_is_day_time()&lt;br /&gt;        {&lt;br /&gt;            DateTime dt = DateTime.Parse("02/02/02 5:00 AM");            &lt;/p&gt; &lt;p&gt;            int hour = dt.Hour;                       &lt;/p&gt; &lt;p&gt;            int lessHour = 0;&lt;/p&gt; &lt;p&gt;            if (hour &amp;lt; 6)&lt;br /&gt;                lessHour = 15 - hour;&lt;/p&gt; &lt;p&gt;            if (hour &amp;gt; 21)&lt;br /&gt;                lessHour = 15 - hour; &lt;/p&gt; &lt;p&gt;            string imageName = ImageOfTheDayService.GetImage(dt.AddHours(lessHour));&lt;br /&gt;            Assert.AreEqual(imageName, "sun.jpg");&lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;        [Test]&lt;br /&gt;        public void should_return_night_image_when_it_is_night_time()&lt;br /&gt;        {&lt;br /&gt;            int hour = DateTime.Now.Hour;&lt;br /&gt;            int lessHour = 0;&lt;/p&gt; &lt;p&gt;            if (hour &amp;lt; 21)&lt;br /&gt;            {&lt;br /&gt;                lessHour = 21 - hour;&lt;br /&gt;            }&lt;/p&gt; &lt;p&gt;            string imageName = ImageOfTheDayService.GetImage(DateTime.Now.AddHours(lessHour));&lt;br /&gt;            Assert.AreEqual(imageName, "moon.jpg");&lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;In the should_return_sun_image_when_it_is_day_time test I am using 5:00 AM as the start time. The problem is that 5:00 AM is still night (according to the demo application). In order to a successful test I need to provide the day time. So, I do some funky stuff and crank the time to 3:00 PM which is the time during the day. Now, I test my GetImage method using the new fake time. &lt;/p&gt; &lt;p&gt;The funky hack makes the test pass but leaves behind ugliness in the test methods. Now, let's introduce the Mock objects to clear out this mess. I am using &lt;a href="http://code.google.com/p/moq/"&gt;Moq&lt;/a&gt; framework to create my mock objects but you can use any framework you like. First, I need to create an interface for the DateTime which I can feed to the Moq framework to return me a mocked object. &lt;/p&gt; &lt;p&gt; public interface IDateTime&lt;br /&gt;    {&lt;br /&gt;        int GetHour(); &lt;br /&gt;    }&lt;/p&gt; &lt;p&gt;Now, the GetImage method of the ImageOfTheDayService will take the IDateTime as the parameter instead of the DateTime. &lt;/p&gt; &lt;p&gt; public static string GetImage(IDateTime mock)&lt;br /&gt;        {&lt;br /&gt;            int hour = mock.GetHour();&lt;/p&gt; &lt;p&gt;            if (hour &amp;gt; 6 &amp;amp;&amp;amp; hour &amp;lt; 21) return "sun.jpg"; &lt;/p&gt; &lt;p&gt;            return "moon.jpg";            &lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;Now, let's check out the test using &lt;strong&gt;mock&lt;/strong&gt; objects. &lt;/p&gt; &lt;p&gt; [Test]&lt;br /&gt;        public void MOCKING_should_return_sun_image_when_it_is_day_time()&lt;br /&gt;        {            &lt;br /&gt;            var mock = new Mock&amp;lt;IDateTime&amp;gt;();                       &lt;br /&gt;            mock.Expect(e =&amp;gt; e.GetHour()).Returns(15); // 3:00 PM&lt;/p&gt; &lt;p&gt;            Assert.AreEqual("sun.jpg", ImageOfTheDayService.GetImage(mock.Object)); &lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;        [Test]&lt;br /&gt;        public void MOCKING_should_return_night_image_when_it_is_night_time()&lt;br /&gt;        {&lt;br /&gt;            var mock = new Mock&amp;lt;IDateTime&amp;gt;(); &lt;br /&gt;            mock.Expect(e =&amp;gt; e.GetHour()).Returns(21); // 9:00 PM&lt;/p&gt; &lt;p&gt;            Assert.AreEqual("moon.jpg", ImageOfTheDayService.GetImage(mock.Object)); &lt;br /&gt;        }&lt;/p&gt; &lt;p&gt;The test becomes much simpler now. All we are saying is that we expect a call on the "GetHour()" method of the IDateTime interface. The method will return "15" (day test). We are not concerned about what is the current time of the day since we are putting expectations and results. Finally, we pass the IDateTime to the GetImage method and compares the output with our expected results. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121695"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=121695" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/AzamSharp/aggbug/121695.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Mohammad Azam</dc:creator>
            <guid>http://geekswithblogs.net/AzamSharp/archive/2008/04/27/121695.aspx</guid>
            <pubDate>Sun, 27 Apr 2008 23:08:04 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/AzamSharp/comments/121695.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/AzamSharp/archive/2008/04/27/121695.aspx#feedback</comments>
            <slash:comments>10</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/AzamSharp/comments/commentRss/121695.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/AzamSharp/services/trackbacks/121695.aspx</trackback:ping>
        </item>
    </channel>
</rss>