<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/"><channel><title>C#</title><link>http://blogs.clearscreen.com/ragc/category/13.aspx</link><description>C#</description><managingEditor>Raúl Alarcón García-Cuevas</managingEditor><dc:language>es-ES</dc:language><generator>.Text Version 0.95.2004.102</generator><item><dc:creator>Raúl Alarcón García-Cuevas</dc:creator><title>.NET Exception Handling</title><link>http://blogs.clearscreen.com/ragc/archive/2005/02/23/1083.aspx</link><pubDate>Wed, 23 Feb 2005 10:14:00 GMT</pubDate><guid>http://blogs.clearscreen.com/ragc/archive/2005/02/23/1083.aspx</guid><wfw:comment>http://blogs.clearscreen.com/ragc/comments/1083.aspx</wfw:comment><comments>http://blogs.clearscreen.com/ragc/archive/2005/02/23/1083.aspx#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/ragc/comments/commentRss/1083.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/ragc/services/trackbacks/1083.aspx</trackback:ping><description>&lt;p&gt;&lt;a href="http://www.codeproject.com/dotnet/exceptionbestpractices.asp" target="_blank"&gt;Here&lt;/a&gt; is an article, from "The Code Project" factory, about best practices for exception handling in .NET. The article covers all aspects about this matter, sometimes risky when we are writing code. Everybody knows that exception handling is one of the &lt;span&gt;mechanism provided by high level languages with which coders must deal daily, in my opinion, only the forty percent of the wrote code is related with the logic of the problem, the other sixty percent is wrote to control errors and exceptions, this is the importance of exception handling!.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Enjoy the article!&lt;/span&gt;&lt;/p&gt;&lt;img src ="http://blogs.clearscreen.com/ragc/aggbug/1083.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p><a href="http://www.codeproject.com/dotnet/exceptionbestpractices.asp" target="_blank">Here</a> is an article, from "The Code Project" factory, about best practices for exception handling in .NET. The article covers all aspects about this matter, sometimes risky when we are writing code. Everybody knows that exception handling is one of the <span>mechanism provided by high level languages with which coders must deal daily, in my opinion, only the forty percent of the wrote code is related with the logic of the problem, the other sixty percent is wrote to control errors and exceptions, this is the importance of exception handling!.</span></p>
<p><span>Enjoy the article!</span></p><img src ="http://blogs.clearscreen.com/ragc/aggbug/1083.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Raúl Alarcón García-Cuevas</dc:creator><title>NHibernate, gathering the Java experience saving objects to Relation Databases</title><link>http://blogs.clearscreen.com/ragc/archive/2005/01/31/884.aspx</link><pubDate>Mon, 31 Jan 2005 11:22:00 GMT</pubDate><guid>http://blogs.clearscreen.com/ragc/archive/2005/01/31/884.aspx</guid><wfw:comment>http://blogs.clearscreen.com/ragc/comments/884.aspx</wfw:comment><comments>http://blogs.clearscreen.com/ragc/archive/2005/01/31/884.aspx#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/ragc/comments/commentRss/884.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/ragc/services/trackbacks/884.aspx</trackback:ping><description>&lt;p&gt;January is ending, to avoid pass this month without writing to my blog I have decided write about &lt;strong&gt;NHibernate&lt;/strong&gt;, available from &lt;strong&gt;&lt;a href="http://nhibernate.sourceforge.net/"&gt;http://nhibernate.sourceforge.net/&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt;.&lt;/strong&gt; This open source project, from SourceForge, is a port from &lt;a href="http://hibernate.org/"&gt;Hibernate&lt;/a&gt;, a mature java relational persistence tool currently in the 2.0 version.&lt;/p&gt;
&lt;p&gt;I don't have tested this tool, but reading the &lt;strong&gt;&lt;a href="http://nhibernate.sourceforge.net/quickstart.html"&gt;QuickStart&lt;/a&gt;&lt;/strong&gt; guide I feel that it could be a very useful approach to save objects to relational databases. You can start designing the objects or designing the database, NHibernate establish a bridge to connect both. Furthermore, you can change the back-end database server without modifying the objects in your code, anyway you must extend the Dialect name space if the new database manager is not supported. &lt;/p&gt;
&lt;p&gt;Currently, the release (0.6.0.0) is been developed, I expect so much from the first version. Keep your eyes on this project, smell like this will be helpful in the future development process.&lt;/p&gt;&lt;img src ="http://blogs.clearscreen.com/ragc/aggbug/884.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>January is ending, to avoid pass this month without writing to my blog I have decided write about <strong>NHibernate</strong>, available from <strong><a href="http://nhibernate.sourceforge.net/">http://nhibernate.sourceforge.net/</a></strong><strong>.</strong> This open source project, from SourceForge, is a port from <a href="http://hibernate.org/">Hibernate</a>, a mature java relational persistence tool currently in the 2.0 version.</p>
<p>I don't have tested this tool, but reading the <strong><a href="http://nhibernate.sourceforge.net/quickstart.html">QuickStart</a></strong> guide I feel that it could be a very useful approach to save objects to relational databases. You can start designing the objects or designing the database, NHibernate establish a bridge to connect both. Furthermore, you can change the back-end database server without modifying the objects in your code, anyway you must extend the Dialect name space if the new database manager is not supported. </p>
<p>Currently, the release (0.6.0.0) is been developed, I expect so much from the first version. Keep your eyes on this project, smell like this will be helpful in the future development process.</p><img src ="http://blogs.clearscreen.com/ragc/aggbug/884.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Raúl Alarcón García-Cuevas</dc:creator><title>Formating Numbers in .NET</title><link>http://blogs.clearscreen.com/ragc/archive/2004/12/22/674.aspx</link><pubDate>Wed, 22 Dec 2004 09:24:00 GMT</pubDate><guid>http://blogs.clearscreen.com/ragc/archive/2004/12/22/674.aspx</guid><wfw:comment>http://blogs.clearscreen.com/ragc/comments/674.aspx</wfw:comment><comments>http://blogs.clearscreen.com/ragc/archive/2004/12/22/674.aspx#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/ragc/comments/commentRss/674.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/ragc/services/trackbacks/674.aspx</trackback:ping><description>&lt;P&gt;Yesterday I was looking for a simple way to&amp;nbsp;print a double number in currency&amp;nbsp;format. I have found this blog,&amp;nbsp;&amp;nbsp;&lt;A href="http://weblogs.asp.net/bclteam/archive/2004/10/17/243636.aspx"&gt;http://weblogs.asp.net/bclteam/archive/2004/10/17/243636.aspx&lt;/A&gt;,&amp;nbsp;with extensive information about formating numbers, cultures, and so on...&lt;/P&gt;
&lt;P&gt;Enjoy it!&lt;/P&gt;&lt;img src ="http://blogs.clearscreen.com/ragc/aggbug/674.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Raúl Alarcón García-Cuevas</dc:creator><title>Setting NFTS Permissions with C#</title><link>http://blogs.clearscreen.com/ragc/archive/2004/12/13/655.aspx</link><pubDate>Mon, 13 Dec 2004 17:36:00 GMT</pubDate><guid>http://blogs.clearscreen.com/ragc/archive/2004/12/13/655.aspx</guid><wfw:comment>http://blogs.clearscreen.com/ragc/comments/655.aspx</wfw:comment><comments>http://blogs.clearscreen.com/ragc/archive/2004/12/13/655.aspx#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/ragc/comments/commentRss/655.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/ragc/services/trackbacks/655.aspx</trackback:ping><description>&lt;P&gt;I was looking for something to put NTFS permissions to a directory form C# without&amp;nbsp;sailing in the complex (more or less)&amp;nbsp;WMI / ADSI world. I have found this:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/cumpsd/archive/2004/02/08/69403.aspx"&gt;http://weblogs.asp.net/cumpsd/archive/2004/02/08/69403.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Great!&lt;/P&gt;&lt;img src ="http://blogs.clearscreen.com/ragc/aggbug/655.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Raúl Alarcón García-Cuevas</dc:creator><title>Installer.HelpText does not replace the scape characters when is invoked thought InstallUtil.exe</title><link>http://blogs.clearscreen.com/ragc/archive/2004/12/09/648.aspx</link><pubDate>Thu, 09 Dec 2004 13:08:00 GMT</pubDate><guid>http://blogs.clearscreen.com/ragc/archive/2004/12/09/648.aspx</guid><wfw:comment>http://blogs.clearscreen.com/ragc/comments/648.aspx</wfw:comment><comments>http://blogs.clearscreen.com/ragc/archive/2004/12/09/648.aspx#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/ragc/comments/commentRss/648.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/ragc/services/trackbacks/648.aspx</trackback:ping><description>&lt;P&gt;Curiously, when you make a custom installer class (inherited from &lt;FONT size=2&gt;System.Configuration.Install.Installer), &lt;/FONT&gt;if you override the HelpText property to show a descriptive message and your message includes some escape characters ("\n", "\r", "\t") these escape characters appears in the help text when you use the "/help" switch in the "InstallUtil.exe" command. &lt;/P&gt;
&lt;P&gt;You can test this issue using the msdn example to this property: &lt;BR&gt;// Override the property 'HelpText'.&lt;BR&gt;public override string HelpText&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp; get&lt;BR&gt;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Installer Description : This is a sample Installer\n"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + "HelpText is used to provide useful information about the "&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + "installer.";&lt;BR&gt;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;BR&gt;Source: &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemConfigurationInstallInstallerClassHelpTextTopic.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemConfigurationInstallInstallerClassHelpTextTopic.asp&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Then, from the command prompt use: "InstallUtil /help myAssembly.dll and you can realize that the "\n" escape character is not replaced with the new line char.&lt;/P&gt;
&lt;P&gt;To work around this issue I come back to the ASCII codes...&lt;BR&gt;public override string HelpText&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp; get&lt;BR&gt;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Installer Description : This is a sample Installer" + &lt;STRONG&gt;Convert.ToChar(10).ToString() + Convert.ToChar(13).ToString()&lt;/STRONG&gt; + &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + "HelpText is used to provide useful information about the "&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + "installer.";&lt;BR&gt;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;... It could be another .NET Framework bug??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src ="http://blogs.clearscreen.com/ragc/aggbug/648.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Raúl Alarcón García-Cuevas</dc:creator><title>Possible .NET Framework Bug</title><link>http://blogs.clearscreen.com/ragc/archive/2004/11/18/598.aspx</link><pubDate>Thu, 18 Nov 2004 18:21:00 GMT</pubDate><guid>http://blogs.clearscreen.com/ragc/archive/2004/11/18/598.aspx</guid><wfw:comment>http://blogs.clearscreen.com/ragc/comments/598.aspx</wfw:comment><comments>http://blogs.clearscreen.com/ragc/archive/2004/11/18/598.aspx#Feedback</comments><slash:comments>31</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/ragc/comments/commentRss/598.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/ragc/services/trackbacks/598.aspx</trackback:ping><description>&lt;P&gt;Yesterday, I was working on a feature to modify a ".config" file. Well, I have loaded the ".config" file in a XmlDocument, then i wrote the following code:&lt;/P&gt;
&lt;P&gt;...&lt;BR&gt;XmlDocument doc = new XmlDocument();&lt;BR&gt;doc.Load(configFile);&lt;BR&gt;//... some modifications over doc&lt;BR&gt;doc.Save("Aux.xml");&lt;BR&gt;File.Copy(configFile, configFile + ".bak", true); //Backup config file&lt;BR&gt;File.Copy("Aux.xml", configFile); //Overwrite the configFile with modifications&lt;BR&gt;...&lt;/P&gt;
&lt;P&gt;What was my surprise when I've got the following exception in the doc.Save("Aux.xml") instruction... &lt;BR&gt;&lt;EM&gt;System.ArgumentException:&lt;STRONG&gt; FileStream will not open Win32 devices such as disk partitions and tape drives.&amp;nbsp; Don't use "&lt;/STRONG&gt;&lt;/EM&gt;&lt;A href="file://\\.\"&gt;&lt;EM&gt;&lt;STRONG&gt;\\.\&lt;/STRONG&gt;&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;&lt;STRONG&gt;" in your path.&lt;BR&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Xml.XmlTextWriter..ctor(String filename, Encoding encoding)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Xml.XmlDOMTextWriter..ctor(String filename, Encoding encoding)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Xml.XmlDocument.Save(String filename)&lt;BR&gt;&amp;nbsp;&amp;nbsp; at GdN.Car.Install.SetUpCar.SetMachineConfigData() in d:\gen2\apps\car\src\gdn.car.install\setupcar.cs:line 496&lt;BR&gt;&amp;nbsp;&amp;nbsp; at GdN.Car.Install.SetUpCar.Install(IDictionary stateSaver) in d:\gen2\apps\car\src\gdn.car.install\setupcar.cs:line 82&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Automatically the error disappears when the "Aux.xml" file name was changed by "ConfigFile.xml"... &lt;BR&gt;This topic requires more investigation because all points to the System.IO.FileStream Type as responsible, but I don't have time to spent in.&lt;/P&gt;&lt;img src ="http://blogs.clearscreen.com/ragc/aggbug/598.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Raúl Alarcón García-Cuevas</dc:creator><title>X509Certificate.GetSerialNumberString()</title><link>http://blogs.clearscreen.com/ragc/archive/2004/11/05/561.aspx</link><pubDate>Fri, 05 Nov 2004 19:48:00 GMT</pubDate><guid>http://blogs.clearscreen.com/ragc/archive/2004/11/05/561.aspx</guid><wfw:comment>http://blogs.clearscreen.com/ragc/comments/561.aspx</wfw:comment><comments>http://blogs.clearscreen.com/ragc/archive/2004/11/05/561.aspx#Feedback</comments><slash:comments>12</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/ragc/comments/commentRss/561.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/ragc/services/trackbacks/561.aspx</trackback:ping><description>&lt;P&gt;As we can see in the .NET documentation, the method &lt;STRONG&gt;GetSerialNumberString() &lt;/STRONG&gt;of the&lt;STRONG&gt; X509Certificate class&lt;/STRONG&gt;, retrieve the certificate&amp;nbsp;serial number. &lt;/P&gt;
&lt;P&gt;Well,&amp;nbsp;if you compare the result with the serial number retrieved through CAPICOM or in the properties of the certificate (through the Internet explorer i.e.) you can realize that the method retrieve the reverse value of the serial number, that is, if the serial number is AABBCCDDEEFF the property return FFEEDDCCBBAA... curiosly... &lt;/P&gt;
&lt;P&gt;Anybody knows why? Is this a bug?&lt;/P&gt;&lt;img src ="http://blogs.clearscreen.com/ragc/aggbug/561.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Raúl Alarcón García-Cuevas</dc:creator><title>Testing with Mock Objects and C#</title><link>http://blogs.clearscreen.com/ragc/archive/2004/08/31/395.aspx</link><pubDate>Tue, 31 Aug 2004 09:16:00 GMT</pubDate><guid>http://blogs.clearscreen.com/ragc/archive/2004/08/31/395.aspx</guid><wfw:comment>http://blogs.clearscreen.com/ragc/comments/395.aspx</wfw:comment><comments>http://blogs.clearscreen.com/ragc/archive/2004/08/31/395.aspx#Feedback</comments><slash:comments>16</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/ragc/comments/commentRss/395.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/ragc/services/trackbacks/395.aspx</trackback:ping><description>&lt;P&gt;Mock objects present an alternative way to make tests for our classes simplifying the testing process and making possible test specific behaviour of our classes when this behaviour relies in other complex classes or subsystems.When we are making unit tests and our class uses other complex classes or subsystems, we could find the following problems:&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;a) The preparation for the test is hard because of the environment required by the collaborative classes (or subsystems) is complex.&amp;nbsp;In example, think in classes that rely in other classes to retrieve information from the database. To test this kind of classes we need configure a basic data set in the database that represents a snapshot with the concrete context for our testing purposes.&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;b) We can&amp;#8217;t use the subsystem classes because of they had not been developed yet. In early stages of development process, different teams are owners of different parts or subsystems in the global solution. Mock objects let us the opportunity of advance in the development process despites other required subsystem is not available yet.&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;c) The behaviour that we are trying to test depends on a remotely situation happened in the subsystem. In example, to check if the exception handling when the subsystem rises a technical error, we need to produce&amp;nbsp;the technical error in the real subsystem. This would be impossible if we are dealing with a real subsystem in a production environment.&lt;/P&gt;
&lt;P&gt;In all of these situations, we can consider substitute the subsystem with a &amp;#8220;mock object&amp;#8221;&amp;nbsp; that simulate the expected behaviour required to check our system, we get a really big independency from the subsystem&amp;nbsp; enabling us make our tests more simple, more effective and quickly.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;To illustrate the mock object concept, look at this dummy C# example:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;We are going to use an existing weather web service to make a little class witch get the weather conditions for the current day. Within the web service methods there is the following:&lt;/P&gt;
&lt;P&gt;- &lt;EM&gt;GetWeatherConditions(string callerName)&lt;/EM&gt;, returns an integer value representing the weather condition (0 &amp;#8211; Sunny, 1 &amp;#8211; Cloudy, 2 &amp;#8211; Rainy&amp;#8230; )&lt;/P&gt;
&lt;P&gt;We have developed the &amp;#8220;CurrentWeather&amp;#8221; class. The constructor will be like:&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; CurrentWeather()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;...&lt;BR&gt;&amp;nbsp;_webServiceUrl &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; ConfigurationSettings.AppSettings[&lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Url"&lt;/SPAN&gt;];&lt;BR&gt;&amp;nbsp;...&lt;BR&gt;}&lt;BR&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;The class has the &amp;#8220;GetWeather()&amp;#8221; method witch connect to the web service, get the weather conditions and save it in suitable private variables. The method always use the string &amp;#8220;CurrentWeatherClass&amp;#8221; as caller name to make the &amp;#8220;GetWeatherConditions&amp;#8221; call. We assume that the method has been tested before.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;We want in our class a new property to get an image name representing the current weather conditions. To develop this method we are going to start with the test:&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;BR&gt;&amp;nbsp;[Test]&lt;BR&gt;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; GetWeaderConditionsPictureTest()&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;CurrentWeather todayWeather &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; CurrentWather();&lt;BR&gt;&amp;nbsp;&amp;nbsp;todayWeather.GetWeather(); &lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt; pictureName &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; todayWeather.Picture;&lt;BR&gt;&amp;nbsp;&amp;nbsp;Assert.IsTrue(pictureName.Length &amp;gt; 0);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//We need check if the Picture really fits &lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//the weather condition&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;Assert.Fails();&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;In the test, we need check if the picture really fits with the weather conditions retrieved from the web service. In this case, if we use the real subsystem we fall in the following inconveniences:&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;a) The picture name that the property &amp;#8220;Picture&amp;#8221; return depends on the real weather, we doesn&amp;#8217;t know the weather before the test runs, therefore, we can&amp;#8217;t make the correct assertion.&lt;BR&gt;b) If we don&amp;#8217;t have a valid connection to the weather web service, the test will fails always.&lt;/P&gt;
&lt;P&gt;To avoid it, we can make a Mock Object that represents the web service; in that case we can make another .NET web service with the same signature as the real web service. In the &amp;#8220;GetWeatherConditions&amp;#8221; method we put logic helping us to make possible the testing:&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;BR&gt;&amp;nbsp;[WebMethod]&lt;BR&gt;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/SPAN&gt; GetWeatherConditions(&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt; callerName)&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/SPAN&gt; result;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;switch&lt;/SPAN&gt;(callerName)&lt;BR&gt;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;case&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"TestingSunny"&lt;/SPAN&gt;: &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;break&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;case&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"TestingCloudy"&lt;/SPAN&gt;:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; 1;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;break&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;case&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"TestingRainy"&lt;/SPAN&gt;:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; 2;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;break&lt;/SPAN&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;BR&gt;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;After we have the mock-object ready, we must refactor the &amp;#8220;CurrentWeather&amp;#8221; class to make possible use it from tests, in that case we overload the constructor to provide a way to specify the web service URL to be used, as well as the caller name, the new constructor looks like:&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; CurrentWeather(&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt; callerName, &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt; serviceUrl): &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;base&lt;/SPAN&gt;()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;...&lt;BR&gt;&amp;nbsp;_webServiceUrl &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; serviceUrl;&lt;BR&gt;&amp;nbsp;_callerName &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; callerName;&lt;BR&gt;&amp;nbsp;...&lt;BR&gt;}&lt;BR&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The unique change required in the original constructor is to put the default caller name:&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; CurrentWeather()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;...&lt;BR&gt;&amp;nbsp;&amp;nbsp;_webServiceUrl &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; ConfigurationSettings.AppSettings[&lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Url"&lt;/SPAN&gt;];&lt;BR&gt;&amp;nbsp;_callerName &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &amp;#8220;CurrentWeatherClass&amp;#8221;;&lt;BR&gt;&amp;nbsp;...&lt;BR&gt;}&lt;BR&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Now we refactor the &amp;#8220;GetWeather&amp;#8221; method to pass the private variable with the caller name:&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; GetWeather()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;...&lt;BR&gt;&amp;nbsp;WeatherWebService service &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; WeatherWebService();&lt;BR&gt;&amp;nbsp;service.Url &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; _webServiceUrl;&lt;BR&gt;&amp;nbsp;_currentWeather &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; service.GetCurrentWeather(_callerName);&lt;BR&gt;&amp;nbsp;...&lt;BR&gt;}&lt;BR&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;At this point, we can make the required test to check the &amp;#8220;Picture&amp;#8221; property:&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;BR&gt;&amp;nbsp;[Test]&lt;BR&gt;&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; GetWeaderConditionsPictureTest()&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;CurrentWeather todayWeather;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt; pictureName;&lt;BR&gt;&lt;BR&gt;todayWeather &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; CurrentWather(&amp;#8220;TestingSunny&amp;#8221;, @&amp;#8220;http:&lt;SPAN style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//localhost/WeatherMock&amp;#8221;);&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;todayWeather.GetWeather(); &lt;BR&gt;&amp;nbsp;&amp;nbsp;Assert.AreEquals(&amp;#8220;Sunny.jpg&amp;#8221;, todayWeather.Picture);&lt;BR&gt;&lt;BR&gt;todayWeather &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; CurrentWather(&amp;#8220;TestingCloudy&amp;#8221;, @&amp;#8220;http:&lt;SPAN style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//localhost/WeatherMock&amp;#8221;);&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;todayWeather.GetWeather(); &lt;BR&gt;&amp;nbsp;&amp;nbsp;Assert.AreEquals(&amp;#8220;Cloudy.jpg&amp;#8221;, todayWeather.Picture);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;BR&gt;todayWeather &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; CurrentWather(&amp;#8220;TestingRainy&amp;#8221;, @&amp;#8220;http:&lt;SPAN style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//localhost/WeatherMock&amp;#8221;);&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;todayWeather.GetWeather(); &lt;BR&gt;&amp;nbsp;&amp;nbsp;Assert.AreEquals(&amp;#8220;Rainy.jpg&amp;#8221;, todayWeather.Picture);&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;And that&amp;#8217;s all... well, the &amp;#8220;GetWeatherConditionsPictureTest&amp;#8221; smells like if needs a refactoring ;)&lt;/P&gt;
&lt;P&gt;In summary, the mock objects provide us a way to test classes that uses complex subsystems. Introduce mock objects in our solution cause a little extra-coding tasks, refactoring the class to be tested and implementing the mock-object logic, anyway, the extra-coding tasks provide more flexibility in the class to be tested making it better.&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;There are a lot of alternatives to implement mock objects, for further information checks these URLs:&lt;BR&gt;&lt;A href="http://www.pragmaticprogrammer.com/starter_kit/ut/mockobjects.pdf" target=blank&gt;http://www.pragmaticprogrammer.com/starter_kit/ut/mockobjects.pdf&lt;/A&gt;&lt;BR&gt;&lt;A href="http://www-106.ibm.com/developerworks/library/j-mocktest.html" target=blank&gt;http://www-106.ibm.com/developerworks/library/j-mocktest.html&lt;/A&gt;&lt;BR&gt;&lt;A href="http://c2.com/cgi/wiki?MockObject" target=blank&gt;http://c2.com/cgi/wiki?MockObject&lt;/A&gt;&lt;/P&gt;&lt;img src ="http://blogs.clearscreen.com/ragc/aggbug/395.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Raúl Alarcón García-Cuevas</dc:creator><title>Embedding Files into Assemblies</title><link>http://blogs.clearscreen.com/ragc/archive/2004/06/09/316.aspx</link><pubDate>Wed, 09 Jun 2004 11:46:00 GMT</pubDate><guid>http://blogs.clearscreen.com/ragc/archive/2004/06/09/316.aspx</guid><wfw:comment>http://blogs.clearscreen.com/ragc/comments/316.aspx</wfw:comment><comments>http://blogs.clearscreen.com/ragc/archive/2004/06/09/316.aspx#Feedback</comments><slash:comments>15</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/ragc/comments/commentRss/316.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/ragc/services/trackbacks/316.aspx</trackback:ping><description>&lt;P&gt;With Visual Studio .NET 2003,&amp;nbsp;we can specify the "&lt;STRONG&gt;Build Action&lt;/STRONG&gt;" property of any file in the solution. This feature bring us the opportunity to embed the content of any file into the result assembly (assemblies) after compilation. It is so simple and can help us when we need&amp;nbsp;some constant data&amp;nbsp;to&amp;nbsp;be deployed with our solution, by example, our application uses an XML schema that (after the application is completed) never changes, and we doesn't like to deploy a separate file with the schema content. Here is a step by step procedure to embed a file into the solution:&lt;BR&gt;1. In the &lt;EM&gt;Solution Explorer&lt;/EM&gt;, right click over the project where we want to have the embedded file, Add / Add Existing Item.&lt;BR&gt;2. Select the file to embed.&lt;BR&gt;3. Show the &lt;EM&gt;Property&lt;/EM&gt; window of the file, and in the property "Build Action", &amp;nbsp;select "Embedded Resource"&lt;/P&gt;
&lt;P&gt;After that, when we compile the solution, we have the content of that file into the assembly, but... how we can read this data? Well, here is a method to extract the content of any embedded resource from the assembly using reflection and stream readers:&lt;/P&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;using&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; System.Reflection;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;using&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; System.IO;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; getEmbeddedResourceContent(&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;resourceFileName)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Assembly myAsembly = Assembly.GetExecutingAssembly();&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string&lt;/FONT&gt;&lt;FONT size=2&gt; resName = String.Empty;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; resourceName &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;in&lt;/FONT&gt;&lt;FONT size=2&gt; myAsembly.GetManifestResourceNames())&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (resourceName.IndexOf(resourceFileName)&amp;gt;=0)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resName = resourceName;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/FONT&gt;&lt;FONT size=2&gt; (resName.&lt;FONT size=2&gt;Length &lt;/FONT&gt;&amp;gt; 0&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT size=2&gt;Stream s = myAsembly.GetManifestResourceStream(resName);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; StreamReader sr = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; StreamReader(s, System.Text.Encoding.GetEncoding(1252));&amp;nbsp;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/FONT&gt;&lt;FONT size=2&gt; sr.ReadToEnd();&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; Exception("The resource can't be found");&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;Note that this method only works with text files and that we can use other assemblies distinct of the executing assembly to host the embedded resources.&lt;/P&gt;&lt;img src ="http://blogs.clearscreen.com/ragc/aggbug/316.aspx" width = "1" height = "1" /&gt;</description></item><item><dc:creator>Raúl Alarcón García-Cuevas</dc:creator><title>An introduction to TDD (Test Driven Development)</title><link>http://blogs.clearscreen.com/ragc/archive/2004/05/10/189.aspx</link><pubDate>Mon, 10 May 2004 19:24:00 GMT</pubDate><guid>http://blogs.clearscreen.com/ragc/archive/2004/05/10/189.aspx</guid><wfw:comment>http://blogs.clearscreen.com/ragc/comments/189.aspx</wfw:comment><comments>http://blogs.clearscreen.com/ragc/archive/2004/05/10/189.aspx#Feedback</comments><slash:comments>11</slash:comments><wfw:commentRss>http://blogs.clearscreen.com/ragc/comments/commentRss/189.aspx</wfw:commentRss><trackback:ping>http://blogs.clearscreen.com/ragc/services/trackbacks/189.aspx</trackback:ping><description>&lt;P&gt;Here is a very useful&amp;nbsp;article to intruduce you in TDD world, it covers all first questions abount unit testing and how to integrate it in your develop lifetime. The article show fantasticaly how to use NUnit as unit testing tool integrated with C#.&lt;/P&gt;
&lt;P&gt;&lt;A href=http://msdn.microsoft.com/msdnmag/issues/04/04/ExtremeProgramming/ target="_blank"&gt;http://msdn.microsoft.com/msdnmag/issues/04/04/ExtremeProgramming/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;After you have read the article... think about the following questions:&lt;/P&gt;
&lt;P&gt;Are private methods requiered to be unit-tested?&lt;BR&gt;If they are... how you can do it?&lt;/P&gt;&lt;img src ="http://blogs.clearscreen.com/ragc/aggbug/189.aspx" width = "1" height = "1" /&gt;</description></item></channel></rss>