<?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 de Nico-pyright(c) &#187; Test</title>
	<atom:link href="https://blog.developpez.com/nico-pyright/pcategory/test/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.developpez.com/nico-pyright</link>
	<description></description>
	<lastBuildDate>Mon, 08 Apr 2013 09:26:35 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>[Code Coverage] Bug de visual studio inférieur à 2010 sur la couverture de code</title>
		<link>https://blog.developpez.com/nico-pyright/p8692/c/code_coverage_bug_de_visual_studio_infer</link>
		<comments>https://blog.developpez.com/nico-pyright/p8692/c/code_coverage_bug_de_visual_studio_infer#comments</comments>
		<pubDate>Fri, 05 Mar 2010 20:11:53 +0000</pubDate>
		<dc:creator><![CDATA[nico-pyright(c)]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Si vous avez des résultats désespérant dans votre couverture de code, ce n&#8217;est peut-etre pas votre faute En effet, si vous utilisez du code généré (et notamment les datasets typés), ceux-ci ne génèrent pas toujours correctement l&#8217;attribut GeneratedCodeAttribute. C&#8217;est un bug connu qui est normalement corrigé dans vs2010 (j&#8217;avoue ne pas avoir testé encore). A noter qu&#8217;un nouvel attribut sera disponible avec le framework 4.0, il s&#8217;agit de [ExcludeFromCodeCoverage]. Un peu de patience et nous [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Si vous avez des résultats désespérant dans votre couverture de code, ce n&rsquo;est peut-etre pas votre faute <img src="https://blog.developpez.com/nico-pyright/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
<p>En effet, si vous utilisez du code généré (et notamment les datasets typés), ceux-ci ne génèrent pas toujours correctement l&rsquo;attribut <a href="http://msdn.microsoft.com/fr-fr/library/system.codedom.compiler.generatedcodeattribute.aspx">GeneratedCodeAttribute</a>.</p>
<p>C&rsquo;est un <a href="http://connect.microsoft.com/VisualStudio/feedback/details/349243/msdatasetgenerator-does-not-add-generatedcodeattribute-correctly">bug connu</a> qui est normalement corrigé dans vs2010 (j&rsquo;avoue ne pas avoir testé encore).</p>
<p>A noter qu&rsquo;un nouvel attribut sera disponible avec le framework 4.0, il s&rsquo;agit de <a href="http://msdn.microsoft.com/en-us/library/dd984116%28VS.100%29.aspx">[ExcludeFromCodeCoverage]</a>.</p>
<p></p>
<p>Un peu de patience et nous aurons des superbes taux de couverture de code <img src="https://blog.developpez.com/nico-pyright/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Message d&#8217;erreur suite à automatisation de couverture de code</title>
		<link>https://blog.developpez.com/nico-pyright/p8398/c/message_d_erreur_suite_a_automatisation_</link>
		<comments>https://blog.developpez.com/nico-pyright/p8398/c/message_d_erreur_suite_a_automatisation_#comments</comments>
		<pubDate>Wed, 25 Nov 2009 20:53:08 +0000</pubDate>
		<dc:creator><![CDATA[nico-pyright(c)]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Si vous tentez d&#8217;automatiser l&#8217;extraction de la couverture de code, comme je l&#8217;ai indiqué dans ce billet, vous pouvez obtenir une erreur, du genre de la suivante : System.IO.FileLoadException was unhandled &#160; Message=&#34;A procedure imported by 'Microsoft.VisualStudio.Coverage.Analysis, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.&#34; &#160; Source=&#34;WindowsFormsApplication1&#34; &#160; FileName=&#34;Microsoft.VisualStudio.Coverage.Analysis, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&#34; &#160; FusionLog=&#34;&#34; comme vu ici, il suffit de copier la dll dbghelp.dll, située dans le même répertoire que Microsoft.VisualStudio.Coverage.Analysis.dll, avec son programme/tache msbuild servant [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Si vous tentez d&rsquo;automatiser l&rsquo;extraction de la couverture de code, <a href="http://blog.developpez.com/nico-pyright/p8375/c/test-c-comment-extraire-la-couverture-de-2/">comme je l&rsquo;ai indiqué dans ce billet</a>, vous pouvez obtenir une erreur, du genre de la suivante :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">System.IO.FileLoadException was unhandled <br />
&nbsp; Message=&quot;A procedure imported by 'Microsoft.VisualStudio.Coverage.Analysis, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.&quot; <br />
&nbsp; Source=&quot;WindowsFormsApplication1&quot; <br />
&nbsp; FileName=&quot;Microsoft.VisualStudio.Coverage.Analysis, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot; <br />
&nbsp; FusionLog=&quot;&quot;</div></div>
<p><span id="more-117"></span><br />
comme vu <a href="http://social.msdn.microsoft.com/Forums/en/vstsprofiler/thread/f33660f0-896b-4e5f-aae9-b1028e888d4d">ici</a>, il suffit de copier la dll <strong>dbghelp.dll</strong>, située dans le même répertoire que Microsoft.VisualStudio.Coverage.Analysis.dll, avec son programme/tache msbuild servant à automatiser l&rsquo;extraction.</p>
<p>Chapeau, il fallait le trouver.</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[Test][C#] Comment extraire la couverture de code programmatiquement (1/2) ?</title>
		<link>https://blog.developpez.com/nico-pyright/p8375/c/test_c_comment_extraire_la_couverture_de_2</link>
		<comments>https://blog.developpez.com/nico-pyright/p8375/c/test_c_comment_extraire_la_couverture_de_2#comments</comments>
		<pubDate>Thu, 19 Nov 2009 20:19:41 +0000</pubDate>
		<dc:creator><![CDATA[nico-pyright(c)]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Le billet que je voulais écrire semble trop long, je vais donc le décomposer en 2 billets&#8230; Comme vu dans ce billet : La couverture de code avec Visual Studio, visual studio peut nous générer un rapport de couverture de code une fois les tests unitaires joués. Dans un processus d&#8217;intégration continue il est envisageable de programmer l&#8217;exécution des tests unitaires à date précise via une tache msbuild. Il est également possible de générer un [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Le billet que je voulais écrire semble trop long, je vais donc le décomposer en 2 billets&#8230;</p>
<p>Comme vu dans ce billet : <a href="http://blog.developpez.com/nico-pyright/p8299/test/test-c-la-couverture-de-code-avec-visual/" target="_blank">La couverture de code avec Visual Studio</a>, visual studio peut nous générer un rapport de couverture de code une fois les tests unitaires joués.</p>
<p>Dans un processus d&rsquo;intégration continue il est envisageable de programmer l&rsquo;exécution des tests unitaires à date précise via une tache msbuild. Il est également possible de générer un rapport de couverture de code automatiquement. Cependant, pour le consulter, on sera obligé d&rsquo;ouvrir un visual studio et de charger les tests correspondant.</p>
<p>Nous allons voir ici une solution pour extraire par code le résultat de la couverture de code afin de l&rsquo;envoyer par exemple par mail au développeur.</p>
<p><span id="more-54"></span></p>
<p>Premier constat, les résultats des tests sont générés dans un répertoire de ce genre :</p>
<p align="left">C:\TestResults\[Nom Utilisateur]_[Nom machine] [date] [heure]</p>
<p>avec comme sous répertoire </p>
<ul>
<li>C:\TestResults\[Nom Utilisateur]_[Nom machine] [date] [heure]\In\[Nom Machine] </li>
<li>C:\TestResults\[Nom Utilisateur]_[Nom machine] [date] [heure]\Out\ </li>
</ul>
<p>Dans le premier on va trouver un fichier <strong>data.coverage</strong> qui contient le résultat de la couverture de code, mais pour l&rsquo;instant inexploitable. </p>
<p>Et dans le deuxième nos dll mises en jeu par le test.</p>
<p>On va pouvoir se servir des dll fournies par visual studio pour la couverture de code pour extraire un fichier xml contenant le résultat de la couverture de code.<br />
  <br />On pourra ensuite effectuer une transformation de ce xml avec un xslt et générer un rapport html que nous pourrons envoyer par mail. </p>
<p>Voyons grosso modo le code mis en jeu, pour ce faire on utilisera l&rsquo;assembly Microsoft.VisualStudio.Coverage.Analysis :</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">using</span> Microsoft.VisualStudio.CodeCoverage;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #008000">// extraction d'un fichier xml à partir du fichier data.coverage</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> CoverageInfoManager.SymPath = @&quot;C:\TestResults\[Nom Utilisateur]_[Nom machine] [date] [heure]\Out\&quot;;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> CoverageInfoManager.ExePath = @&quot;C:\TestResults\[Nom Utilisateur]_[Nom machine] [date] [heure]\Out\<span style="color: #006080">&quot;;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> CoverageInfo ci = CoverageInfoManager.CreateInfoFromFile(@&quot;C:\TestResults\[Nom Utilisateur]_[Nom machine] [date] [heure]\In\[Nom Machine]\data.coverage&quot;);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> CoverageDS data = ci.BuildDataSet(null);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> data.WriteXml(@&quot;c:\result.xml&quot;);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #008000">// effectuer la transformation du xml </span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span><span style="color: #008000"> // envoyer le mail</span></pre>
</div>
</div>
<p>Si on utilise des taches msbuild, on pourra avoir accès à tout un tas de variable d&rsquo;environnement, dont une particulière <strong>$(TestResultsRoot)</strong> qui permet d&rsquo;obtenir le repertoire de destination des tests, dans mon exemple il s&rsquo;agit de C:\TestResults\</p>
<p>Ainsi, en passant la valeur de cette variable à notre programme (disons un programme console pour l&rsquo;instant), on pourra être capable par code de :</p>
<ul>
<li>récupérer le dernier répertoire créé </li>
<li>d&rsquo;obtenir le répertoire de sortie </li>
<li>d&rsquo;obtenir le chemin du fichier data.coverage </li>
<li>et de générer le fichier xml dans un fichier temporaire </li>
</ul>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> GetCoverageTemporaryFileName(<span style="color: #0000ff">string</span> baseDirectory) <span style="color: #008000">// baseDirectory est le nom du répertoire passé en paramètre</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     var elts = Directory.GetDirectories(baseDirectory).Select(directory =&gt; <span style="color: #0000ff">new</span> KeyValuePair&lt;<span style="color: #0000ff">string</span>, DateTime&gt;(directory, Directory.GetCreationTime(directory))).OrderByDescending(<span style="color: #0000ff">value</span> =&gt; <span style="color: #0000ff">value</span>.Value).Select(v =&gt; v.Key);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     <span style="color: #0000ff">if</span> (elts.Any())</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         <span style="color: #0000ff">string</span> directory = elts.First();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>         <span style="color: #0000ff">if</span> (!directory.EndsWith(<span style="color: #006080">@&quot;\&quot;))</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>             directory += @&quot;\<span style="color: #006080">&quot;;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         string outputPath = string.Format(&quot;{0}Out&quot;, directory);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>         if (!Directory.Exists(outputPath))</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>             throw new Exception(&quot;Impossible de trouver le répertoire de sortie, le répertoire <span style="color: #006080">&quot; + outputPath + &quot;</span> n'existe pas&quot;);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>         CoverageInfoManager.SymPath = outputPath;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span>         CoverageInfoManager.ExePath = outputPath;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span>         string inputPath = string.Format(&quot;{0}\\In\\{1}\\data.coverage&quot;, directory, Environment.MachineName);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum18">  18:</span>         if (!File.Exists(inputPath))</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum19">  19:</span>             throw new Exception(&quot;Impossible de trouver le fichier de couverture de code, le fichier &quot; + inputPath + &quot; n'existe pas&quot;);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum20">  20:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum21">  21:</span>         CoverageInfo ci = CoverageInfoManager.CreateInfoFromFile(inputPath);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum22">  22:</span>         CoverageDS data = ci.BuildDataSet(<span style="color: #0000ff">null</span>);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum23">  23:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum24">  24:</span>         <span style="color: #0000ff">string</span> tempFileName = Path.GetTempFileName();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum25">  25:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum26">  26:</span>         data.WriteXml(tempFileName);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum27">  27:</span>         <span style="color: #0000ff">return</span> tempFileName;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum28">  28:</span>     }</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum29">  29:</span>     <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</span>;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum30">  30:</span> }</pre>
</p></div>
</div>
<p>La suite dans le billet suivant : <a href="http://blog.developpez.com/nico-pyright/p8382/test/test-c-comment-extraire-la-couverture-de-3">http://blog.developpez.com/nico-pyright/p8382/test/test-c-comment-extraire-la-couverture-de-3</a></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Test][C#] Comment extraire la couverture de code programmatiquement (2/2) ?</title>
		<link>https://blog.developpez.com/nico-pyright/p8382/c/test_c_comment_extraire_la_couverture_de_3</link>
		<comments>https://blog.developpez.com/nico-pyright/p8382/c/test_c_comment_extraire_la_couverture_de_3#comments</comments>
		<pubDate>Thu, 19 Nov 2009 21:16:39 +0000</pubDate>
		<dc:creator><![CDATA[nico-pyright(c)]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Suite de mon précédent billet : Le xml obtenu a la tête suivante : &#38;lt;?xml version=&#34;1.0&#34; standalone=&#34;yes&#34;?&#38;gt;&#38;nbsp; &#38;lt;CoverageDSPriv&#38;gt;&#38;nbsp; &#38;nbsp; &#38;lt;Module&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#38;lt;ModuleName&#38;gt;DllTest2.dll&#38;lt;/ModuleName&#38;gt;&#38;nbsp; &#38;nbsp; &#160; [...]&#38;nbsp; &#38;nbsp; &#160; &#38;lt;NamespaceTable&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#160; &#38;lt;BlocksCovered&#38;gt;1&#38;lt;/BlocksCovered&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#160; &#38;lt;BlocksNotCovered&#38;gt;0&#38;lt;/BlocksNotCovered&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#160; &#38;lt;LinesCovered&#38;gt;2&#38;lt;/LinesCovered&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#160; &#38;lt;LinesNotCovered&#38;gt;0&#38;lt;/LinesNotCovered&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#160; &#38;lt;LinesPartiallyCovered&#38;gt;0&#38;lt;/LinesPartiallyCovered&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#160; &#38;lt;ModuleName&#38;gt;DllTest2.dll&#38;lt;/ModuleName&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#160; &#38;lt;NamespaceKeyName&#38;gt;DllTest2.dllDllTest2&#38;lt;/NamespaceKeyName&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#160; &#38;lt;NamespaceName&#38;gt;DllTest2&#38;lt;/NamespaceName&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#160; &#38;lt;Class&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#160; &#160; &#38;lt;ClassKeyName&#38;gt;DllTest2.dllDllTest2Class2&#38;lt;/ClassKeyName&#38;gt;&#38;nbsp; &#38;nbsp; &#160; &#160; &#160; &#38;lt;ClassName&#38;gt;Class2&#38;lt;/ClassName&#38;gt;&#38;nbsp; [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Suite de mon <a href="http://blog.developpez.com/nico-pyright/p8375/c/test-c-comment-extraire-la-couverture-de-2/">précédent billet</a> :</p>
<p>Le xml obtenu a la tête suivante :</p>
<p><span id="more-116"></span></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&amp;lt;?xml version=&quot;1.0&quot; standalone=&quot;yes&quot;?&amp;gt;&amp;nbsp;<br />
&amp;lt;CoverageDSPriv&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &amp;lt;Module&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &amp;lt;ModuleName&amp;gt;DllTest2.dll&amp;lt;/ModuleName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; [...]&amp;nbsp;<br />
&amp;nbsp; &nbsp; &amp;lt;NamespaceTable&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &amp;lt;BlocksCovered&amp;gt;1&amp;lt;/BlocksCovered&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &amp;lt;BlocksNotCovered&amp;gt;0&amp;lt;/BlocksNotCovered&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &amp;lt;LinesCovered&amp;gt;2&amp;lt;/LinesCovered&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &amp;lt;LinesNotCovered&amp;gt;0&amp;lt;/LinesNotCovered&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &amp;lt;LinesPartiallyCovered&amp;gt;0&amp;lt;/LinesPartiallyCovered&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &amp;lt;ModuleName&amp;gt;DllTest2.dll&amp;lt;/ModuleName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &amp;lt;NamespaceKeyName&amp;gt;DllTest2.dllDllTest2&amp;lt;/NamespaceKeyName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &amp;lt;NamespaceName&amp;gt;DllTest2&amp;lt;/NamespaceName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &amp;lt;Class&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;ClassKeyName&amp;gt;DllTest2.dllDllTest2Class2&amp;lt;/ClassKeyName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;ClassName&amp;gt;Class2&amp;lt;/ClassName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; [...]&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;NamespaceKeyName&amp;gt;DllTest2.dllDllTest2&amp;lt;/NamespaceKeyName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;Method&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;MethodKeyName&amp;gt;DllTest2.dll!2091&amp;lt;/MethodKeyName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;MethodName&amp;gt;Test()&amp;lt;/MethodName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;MethodFullName&amp;gt;Test()&amp;lt;/MethodFullName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;LinesCovered&amp;gt;2&amp;lt;/LinesCovered&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;LinesPartiallyCovered&amp;gt;0&amp;lt;/LinesPartiallyCovered&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;LinesNotCovered&amp;gt;0&amp;lt;/LinesNotCovered&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;BlocksCovered&amp;gt;1&amp;lt;/BlocksCovered&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;BlocksNotCovered&amp;gt;0&amp;lt;/BlocksNotCovered&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [...]&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &nbsp; &amp;lt;/Method&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &nbsp; &amp;lt;/Class&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &amp;lt;/NamespaceTable&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &amp;lt;/Module&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &amp;lt;Module&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &amp;lt;ModuleName&amp;gt;DllTest.dll&amp;lt;/ModuleName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &amp;lt;ImageSize&amp;gt;49152&amp;lt;/ImageSize&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &amp;lt;ImageLinkTime&amp;gt;0&amp;lt;/ImageLinkTime&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; [...]&amp;nbsp;<br />
&amp;nbsp; &amp;lt;/Module&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &amp;lt;SourceFileNames&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &amp;lt;SourceFileID&amp;gt;1&amp;lt;/SourceFileID&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &amp;lt;SourceFileName&amp;gt;C:\test\ExtractCoverage\DllTest2\Class1.cs&amp;lt;/SourceFileName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &amp;lt;/SourceFileNames&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &amp;lt;SourceFileNames&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &amp;lt;SourceFileID&amp;gt;2&amp;lt;/SourceFileID&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &nbsp; &amp;lt;SourceFileName&amp;gt;C:\test\ExtractCoverage\DllTest\Class1.cs&amp;lt;/SourceFileName&amp;gt;&amp;nbsp;<br />
&amp;nbsp; &amp;lt;/SourceFileNames&amp;gt;&amp;nbsp;<br />
&amp;lt;/CoverageDSPriv&amp;gt;</div></div>
<p>Une fois ce fichier xml obtenu, on pourra lui appliquer une transformation xsl. Pour ce faire, j&rsquo;ai écrit ce xsl tout simple qui gagnerait grandement a être amélioré :</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">=&quot;1.0&quot;</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">=&quot;iso-8859-1&quot;</span> ?<span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:stylesheet</span> <span style="color: #ff0000">xmlns:xsl</span><span style="color: #0000ff">=&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">=&quot;1.0&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:output</span> <span style="color: #ff0000">method</span><span style="color: #0000ff">=&quot;html&quot;</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:decimal-format</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;financial&quot;</span> <span style="color: #ff0000">decimal-separator</span><span style="color: #0000ff">=&quot;,&quot;</span> <span style="color: #ff0000">grouping-separator</span><span style="color: #0000ff">=&quot; &quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:template</span> <span style="color: #ff0000">match</span><span style="color: #0000ff">=&quot;/CoverageDSPriv&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">html</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">head</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">title</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">title</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">head</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>       <span style="color: #0000ff">&lt;</span><span style="color: #800000">body</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:for-each</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;Module&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>           <span style="color: #0000ff">&lt;</span><span style="color: #800000">table</span> <span style="color: #ff0000">border</span><span style="color: #0000ff">=&quot;1&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>             <span style="color: #0000ff">&lt;</span><span style="color: #800000">tr</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>               <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span>                 <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;ModuleName&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span>               <span style="color: #0000ff">&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span>               <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum18">  18:</span>               <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span>Not Covered<span style="color: #0000ff">&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum19">  19:</span>               <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span>Covered<span style="color: #0000ff">&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum20">  20:</span>             <span style="color: #0000ff">&lt;/</span><span style="color: #800000">tr</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum21">  21:</span>             <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:for-each</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;NamespaceTable/Class&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum22">  22:</span>               <span style="color: #0000ff">&lt;</span><span style="color: #800000">tr</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum23">  23:</span>                 <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum24">  24:</span>                   <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;ClassName&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum25">  25:</span>                 <span style="color: #0000ff">&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum26">  26:</span>                 <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum27">  27:</span>                 <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum28">  28:</span>                 <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum29">  29:</span>               <span style="color: #0000ff">&lt;/</span><span style="color: #800000">tr</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum30">  30:</span>               <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:for-each</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;Method&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum31">  31:</span>                 <span style="color: #0000ff">&lt;</span><span style="color: #800000">tr</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum32">  32:</span>                   <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum33">  33:</span>                   <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum34">  34:</span>                     <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;MethodFullName&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum35">  35:</span>                   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum36">  36:</span>                   <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum37">  37:</span>                     <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;format-number(BlocksNotCovered * 100 div (BlocksCovered + BlocksNotCovered),'# ##0,00','financial')&quot;</span> <span style="color: #0000ff">/&gt;</span>%</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum38">  38:</span>                   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum39">  39:</span>                   <span style="color: #0000ff">&lt;</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum40">  40:</span>                     <span style="color: #0000ff">&lt;</span><span style="color: #800000">xsl:value-of</span> <span style="color: #ff0000">select</span><span style="color: #0000ff">=&quot;format-number(BlocksCovered * 100 div (BlocksCovered + BlocksNotCovered),'# ##0,00','financial')&quot;</span> <span style="color: #0000ff">/&gt;</span>%</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum41">  41:</span>                   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">td</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum42">  42:</span>                 <span style="color: #0000ff">&lt;/</span><span style="color: #800000">tr</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum43">  43:</span>               <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:for-each</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum44">  44:</span>             <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:for-each</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum45">  45:</span>           <span style="color: #0000ff">&lt;/</span><span style="color: #800000">table</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum46">  46:</span>           <span style="color: #0000ff">&lt;</span><span style="color: #800000">br</span><span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum47">  47:</span>         <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:for-each</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum48">  48:</span>       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">body</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum49">  49:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">html</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum50">  50:</span>   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:template</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum51">  51:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">xsl:stylesheet</span><span style="color: #0000ff">&gt;</span></pre>
</div>
</div>
<p>J&rsquo;ai placé le fichier xsl en ressource, ce qui fait qu&rsquo;on pourra effectuer la transformation ainsi :</p>
</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> TransformCoverage(<span style="color: #0000ff">string</span> file)</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     StreamReader sr = <span style="color: #0000ff">new</span> StreamReader(file);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     XmlReader xmlReader = XmlReader.Create(sr);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     Assembly assembly = Assembly.GetExecutingAssembly();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     Stream reader = assembly.GetManifestResourceStream(<span style="color: #006080">&quot;MyNamespace.output.xsl&quot;</span>);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>     <span style="color: #0000ff">if</span> (reader != <span style="color: #0000ff">null</span>)</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>     {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>         <span style="color: #008000">// on transforme le xsl</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>         XmlReader xslReader = XmlReader.Create(reader);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>         XslCompiledTransform xslt = <span style="color: #0000ff">new</span> XslCompiledTransform();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>         xslt.Load(xslReader);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span>         StringBuilder sb = <span style="color: #0000ff">new</span> StringBuilder();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span>         TextWriter tw = <span style="color: #0000ff">new</span> StringWriter(sb);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum18">  18:</span>         xslt.Transform(xmlReader, <span style="color: #0000ff">new</span> XsltArgumentList(), tw);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum19">  19:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum20">  20:</span>         <span style="color: #0000ff">string</span> <span style="color: #0000ff">value</span> = sb.ToString();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum21">  21:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum22">  22:</span>         tw.Close();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum23">  23:</span>         xslReader.Close();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum24">  24:</span>         reader.Close();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum25">  25:</span>         <span style="color: #0000ff">return</span> <span style="color: #0000ff">value</span>;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum26">  26:</span>     }</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum27">  27:</span>     xmlReader.Close();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum28">  28:</span>     sr.Close();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum29">  29:</span>     <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> Exception(<span style="color: #006080">&quot;Impossible de récupérer le fichier xsl&quot;</span>);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum30">  30:</span> }</pre>
</p></div>
</div>
<p>Il ne restera plus qu&rsquo;à envoyer le mail, avec quelque chose du genre :</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> MailAddress from = <span style="color: #0000ff">new</span> MailAddress(<span style="color: #006080">&quot;from@email.com&quot;</span>);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> MailMessage mailMessage = <span style="color: #0000ff">new</span> MailMessage { From = from };</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> mailMessage.To.Add(<span style="color: #0000ff">new</span> MailAddress(<span style="color: #006080">&quot;to@email.com&quot;</span>););</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> mailMessage.Subject = <span style="color: #006080">&quot;Rapport de couverture de code&quot;</span>;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> mailMessage.IsBodyHtml = <span style="color: #0000ff">true</span>;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> mailMessage.Body = body; <span style="color: #008000">// résultat de TransformCoverage</span></pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>&#160; </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> SmtpClient smtpClient = <span style="color: #0000ff">new</span> SmtpClient(smtpAddress);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> smtpClient.Send(mailMessage);</pre>
</p></div>
</div>
<p>Et voilà pour l’extraction de la couverture de code avec du code C#</p>
<p>On obtient le résultat suivant :</p>
<p><img src="http://nico-pyright.developpez.com/blog/cover.png" alt="Couverture de code généré" title="Couverture de code généré" /></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Test][C#] La couverture de code avec Visual Studio</title>
		<link>https://blog.developpez.com/nico-pyright/p8299/c/test_c_la_couverture_de_code_avec_visual</link>
		<comments>https://blog.developpez.com/nico-pyright/p8299/c/test_c_la_couverture_de_code_avec_visual#comments</comments>
		<pubDate>Mon, 09 Nov 2009 20:49:00 +0000</pubDate>
		<dc:creator><![CDATA[nico-pyright(c)]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Comme dit dans Wikipédia, La couverture de code (en anglais code coverage) est une mesure utilisée en génie logiciel pour décrire le taux de code source testé d&#8217;un programme. Ceci permet de mesurer la qualité des tests effectués. Visual Studio (notamment dans sa version Visual Studio Team System Test Edition) permet de mesurer la couverture du code de nos tests unitaires. Prenons par exemple cette classe : 1: public class Class1 2: { 3: public [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://fr.wikipedia.org/wiki/Couverture_de_code" target="_blank">Comme dit dans Wikipédia</a>, La couverture de code (en anglais code coverage) est une mesure utilisée en génie logiciel pour décrire le taux de code source testé d&rsquo;un programme. Ceci permet de mesurer la qualité des tests effectués.</p>
<p>Visual Studio (notamment dans sa version <a href="http://msdn.microsoft.com/fr-fr/library/ms182409.aspx" target="_blank">Visual Studio Team System Test Edition</a>) permet de mesurer la couverture du code de nos tests unitaires.</p>
<p>Prenons par exemple cette classe : </p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Class1</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> DoStuff()</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         <span style="color: #0000ff">return</span> 10;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     }</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>  </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> DoStuffJamaisAppelee()</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>     {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>         <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> NotImplementedException();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>     }</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> }</pre>
</div>
</div>
<p>et la classe de test associée :</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> [TestClass]</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> UnitTest1</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     [TestMethod]</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> TestMethod1()</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>         Class1 class1 = <span style="color: #0000ff">new</span> Class1();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         <span style="color: #0000ff">int</span> result = class1.DoStuff();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         Assert.AreEqual(10, result);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>     }</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> }</pre>
</div>
</div>
<p>On a beau avoir tous nos tests qui passent :</p>
<p><a href="http://blog.developpez.com/media/140/WindowsLiveWriter/TestCLacouverturedecodeavecVisualStudio_D072/image_4.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.developpez.com/media/140/WindowsLiveWriter/TestCLacouverturedecodeavecVisualStudio_D072/image_thumb_1.png" width="367" height="128" /></a> </p>
<p>On voit bien, en observant le code de notre classe de test, que seule la méthode DoStuff est couverte alors que la méthode DoStuffJamaisAppelee n&rsquo;est jamais testée.</p>
<p>Dans ce cas simple, il est facile de se rendre compte qu&rsquo;il faut rajouter un test appelant la méthode DoStuffJamaisAppelee pour être bien sur que l&rsquo;ensemble de notre code est couvert par des tests unitaires. Mais si le code se rallonge, comment être bien sur que l&rsquo;on oublie rien ?</p>
<p><span id="more-115"></span></p>
<p>C&rsquo;est la qu&rsquo;intervient l&rsquo;outil de couverture de code (disponible uniquement dans certaines éditions de visual studio). Je peux obtenir un rapport sur mes tests unitaires :</p>
<p><a href="http://blog.developpez.com/media/140/WindowsLiveWriter/TestCLacouverturedecodeavecVisualStudio_D072/image_12.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="image" border="0" alt="image" src="http://blog.developpez.com/media/140/WindowsLiveWriter/TestCLacouverturedecodeavecVisualStudio_D072/image_thumb_5.png" width="787" height="167" /></a> </p>
<p>A la lecture du tableau, on se rend bien compte que DoStuff est couverte à 100% et que DoStuffJamaisAppelee aurait bien besoin d&rsquo;un petit test unitaire&#8230;</p>
<p>De plus, en double-cliquant sur les méthodes dans le rapport, Visual Studio nous amène dans notre code source et nous signale en couleur les éléments dans lesquels les tests ne sont pas passés.</p>
<p>Prenons par exemple cette classe : </p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Class1</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">bool</span> DoStuff(<span style="color: #0000ff">int</span> val)</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>         <span style="color: #0000ff">if</span> (val == 10)</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">false</span>;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>         <span style="color: #0000ff">return</span> <span style="color: #0000ff">true</span>; ;</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>     }</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> }</pre>
</div>
</div>
<p>Avec la méthode de test suivante :</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> [TestClass]</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> UnitTest1</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     [TestMethod]</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> TestMethod1()</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>         Class1 class1 = <span style="color: #0000ff">new</span> Class1();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>         <span style="color: #0000ff">bool</span> result = class1.DoStuff(5);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>         Assert.AreEqual(<span style="color: #0000ff">true</span>, result);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>     }</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> }</pre>
</div>
</div>
<p>Ici, en double cliquant sur la méthode DoStuff, on arrive dans le fichier source concerné avec :</p>
<p><a href="http://blog.developpez.com/media/140/WindowsLiveWriter/TestCLacouverturedecodeavecVisualStudio_D072/image_14.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="image" border="0" alt="image" src="http://blog.developpez.com/media/140/WindowsLiveWriter/TestCLacouverturedecodeavecVisualStudio_D072/image_thumb_6.png" width="307" height="152" /></a> </p>
<p>Et on voit tout de suite ce qui ne va pas, il manque un test de la méthode DoStuff avec en paramètre la valeur 10. Il ne reste plus qu&rsquo;à rajouter le test adéquat et la couverture sera complète.</p>
<p>Voilà pour un aperçu de la couverture de code, outil indispensable pour qui veut être bien sur de la pertinence de ses tests unitaires</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[UnitTest][C#] Tester une méthode privée</title>
		<link>https://blog.developpez.com/nico-pyright/p8265/c/unittest_tester_une_methode_privee</link>
		<comments>https://blog.developpez.com/nico-pyright/p8265/c/unittest_tester_une_methode_privee#comments</comments>
		<pubDate>Mon, 02 Nov 2009 20:21:00 +0000</pubDate>
		<dc:creator><![CDATA[nico-pyright(c)]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Sans rentrer dans le débat de &#171;&#160;Pourquoi vouloir tester une méthode privée&#160;&#187;, il est possible de tester unitairement des méthodes privées. Si c&#8217;est possible, je recommande d&#8217;utiliser plutôt le qualificateur internal plutôt que private Dans ce cas, il devient possible d&#8217;utiliser l&#8217;attribut InternalsVisibleTo afin d&#8217;indiquer que le projet de test pourra accéder aux classes/méthodes internes. Cela se fait en renseignant cet attribut dans le fichier AssemblyInfo.cs du projet contenant la classe interne. On lui indique [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Sans rentrer dans le débat de &laquo;&nbsp;Pourquoi vouloir tester une méthode privée&nbsp;&raquo;, il est possible de tester unitairement des méthodes privées.</p>
<p> <span id="more-51"></span>
<p>Si c&rsquo;est possible, je recommande d&rsquo;utiliser plutôt le qualificateur </p>
<div style="border-bottom: #000000 1px solid; border-left: #000000 1px solid; margin-left: 10pt; border-top: #000000 1px solid; margin-right: 2pt; border-right: #000000 1px solid">
<div style="background-color: #dcdcdc; white-space: nowrap; overflow: scroll"><font face=" Courier New"><font size="2"></font><font color="#0000ff">internal</font></font> </div>
</p></div>
<p>plutôt que</p>
<div style="border-bottom: #000000 1px solid; border-left: #000000 1px solid; margin-left: 10pt; border-top: #000000 1px solid; margin-right: 2pt; border-right: #000000 1px solid">
<div style="background-color: #dcdcdc; white-space: nowrap; overflow: scroll"><font face=" Courier New"><font size="2"></font><font color="#0000ff">private</font></font> </div>
</p></div>
</p>
<p>Dans ce cas, il devient possible d&rsquo;utiliser l&rsquo;attribut <a href="http://msdn.microsoft.com/fr-fr/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx" target="_blank">InternalsVisibleTo</a> afin d&rsquo;indiquer que le projet de test pourra accéder aux classes/méthodes internes.</p>
<p>Cela se fait en renseignant cet attribut dans le fichier AssemblyInfo.cs du projet contenant la classe interne. On lui indique l&rsquo;assembly qui sera autorisée à utiliser les éléments internes de la classe.</p>
<p>Par exemple :</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(<span style="color: #006080">"MonAssembly, PublicKey=laclepubliquesibesoin"</span>)]</pre>
</div>
</div>
<p>Notez que si l&rsquo;assembly est signée, il faudra renseigner la clé publique complète, que l&rsquo;on peut trouver grâce à la commande : </p>
<div style="border-bottom: #000000 1px solid; border-left: #000000 1px solid; margin-left: 10pt; border-top: #000000 1px solid; margin-right: 2pt; border-right: #000000 1px solid">
<div style="background-color: #dcdcdc; white-space: nowrap; overflow: scroll"><font face=" Courier New"><font size="2">sn.exe -Tp MonAssembly</font></font> </div>
</div>
<p>On pourra également utiliser l&rsquo;assistant de Visual Studio, grâce au menu contextuel qui s&rsquo;affiche lors du clic sur le bouton droit : </p>
<p><a href="http://blog.developpez.com/media/140/WindowsLiveWriter/UnitTestTesterunemthodeprive_C9ED/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.developpez.com/media/140/WindowsLiveWriter/UnitTestTesterunemthodeprive_C9ED/image_thumb.png" width="211" height="82" /></a> </p>
<p>Il suffira de choisir la méthode interne à tester :</p>
<p><a href="http://blog.developpez.com/media/140/WindowsLiveWriter/UnitTestTesterunemthodeprive_C9ED/image_4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.developpez.com/media/140/WindowsLiveWriter/UnitTestTesterunemthodeprive_C9ED/image_thumb_1.png" width="329" height="188" /></a> </p>
<p>Une autre solution est de, toujours avec l&rsquo;assistant, demander à Visual Studio de générer un accesseur privé afin de pouvoir tester les méthodes privées.</p>
<p>Grâce au menu contextuel, on peut :</p>
<p><a href="http://blog.developpez.com/media/140/WindowsLiveWriter/UnitTestTesterunemthodeprive_C9ED/image_6.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.developpez.com/media/140/WindowsLiveWriter/UnitTestTesterunemthodeprive_C9ED/image_thumb_2.png" width="334" height="71" /></a> </p>
<p>Il génère dans le projet de test l&rsquo;accesseur privé :</p>
<p><a href="http://blog.developpez.com/media/140/WindowsLiveWriter/UnitTestTesterunemthodeprive_C9ED/image_8.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.developpez.com/media/140/WindowsLiveWriter/UnitTestTesterunemthodeprive_C9ED/image_thumb_3.png" width="234" height="52" /></a> </p>
<p>et on pourra utiliser un code du genre pour tester sa méthode privée :</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> MonWebService_Accessor test = <span style="color: #0000ff">new</span> MonWebService_Accessor();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">int</span> <span style="color: #0000ff">value</span> = test.UneMethodePrivate();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> Assert.AreEqual(10, <span style="color: #0000ff">value</span>);</pre>
</div>
</div>
<p>Voilà pour le test de méthode privée.</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>[Tests Unitaires] Comment tester un web service WCF ?</title>
		<link>https://blog.developpez.com/nico-pyright/p8253/c/tests_unitaires_comment_tester_un_web_se</link>
		<comments>https://blog.developpez.com/nico-pyright/p8253/c/tests_unitaires_comment_tester_un_web_se#comments</comments>
		<pubDate>Wed, 28 Oct 2009 19:56:00 +0000</pubDate>
		<dc:creator><![CDATA[nico-pyright(c)]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[L&#8217;inconvénient d&#8217;un web service est qu&#8217;il a besoin d&#8217;un serveur web pour s&#8217;exécuter, comme IIS ou le serveur web de visual studio. Or, bien que cela soit possible de lancer à la main le serveur à travers visual studio et d&#8217;effectuer des tests, cela devient problématique pour toute utilisation automatisée ou souhaitant tourner dans un environnement où aucun serveur web n&#8217;est lancé. Comment faire alors pour tester son web service ? Une solution est d&#8217;utiliser [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>L&rsquo;inconvénient d&rsquo;un web service est qu&rsquo;il a besoin d&rsquo;un serveur web pour s&rsquo;exécuter, comme IIS ou le serveur web de visual studio.</p>
<p>Or, bien que cela soit possible de lancer à la main le serveur à travers visual studio et d&rsquo;effectuer des tests, cela devient problématique pour toute utilisation automatisée ou souhaitant tourner dans un environnement où aucun serveur web n&rsquo;est lancé.</p>
<p>Comment faire alors pour tester son web service ?</p>
<p> <span id="more-52"></span>
<p>Une solution est d&rsquo;utiliser la DLL WebDev.WebHost.dll <a href="http://haacked.com/archive/2006/12/12/Using_WebServer.WebDev_For_Unit_Tests.aspx" target="_blank">comme décrit ici par Phil Haack</a>.</p>
<p>Je vais vous présenter ici cette solution en m&rsquo;inspirant du post de Phil.</p>
<p>La première chose à faire est d&rsquo;avoir un projet de test et (temporairement) d&rsquo;avoir le projet contenant le svc en train de s&rsquo;exécuter afin de pouvoir naviguer sur le service web.</p>
<p><a href="http://blog.developpez.com/media/140/WindowsLiveWriter/TestsUnitairesCommenttesterunwebserviceW_FC7F/image_4.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.developpez.com/media/140/WindowsLiveWriter/TestsUnitairesCommenttesterunwebserviceW_FC7F/image_thumb_1.png" width="343" height="200" /></a> </p>
<p>On ajoute une référence service, et on utilise le bouton discover pour trouver le service web.</p>
</p>
<p><a href="http://blog.developpez.com/media/140/WindowsLiveWriter/TestsUnitairesCommenttesterunwebserviceW_FC7F/image_6.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.developpez.com/media/140/WindowsLiveWriter/TestsUnitairesCommenttesterunwebserviceW_FC7F/image_thumb_2.png" width="362" height="292" /></a> </p>
<p>Visual studio nous génère une classe proxy permettant d&rsquo;appeler le web service.</p>
<p>Reste à référencer le projet WebServiceTestUtility que vous trouverez en pièces jointes et qui contient le code nécessaire pour instancier le serveur WebDev.WebHost automatiquement.</p>
<p>On aura besoin du fichier WebDev.WebHost.dll, il faudra aller l&rsquo;extraire du GAC en y naviguant (via une invite de commande par exemple) et le copier dans son projet. Le projet WebServiceTestUtility y fait référence.</p>
<p>On instanciera la classe WebHostWebServer avec le port et l&rsquo;adresse précisée dans le web.config, comme ici :</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> [TestInitialize]</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> MyTestInitialize()</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     _webHostWebServer = <span style="color: #0000ff">new</span> WebHostWebServer(58743, <span style="color: #006080">"/"</span>);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     _webHostWebServer.Start();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     _webHostWebServer.ExtractResource(<span style="color: #006080">"MonServiceWCF.Tests.Unit.Resources.Web.config"</span>, <span style="color: #006080">"Web.config"</span>);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     _webHostWebServer.ExtractResource(<span style="color: #006080">"MonServiceWCF.Tests.Unit.Resources.MonWebService.svc"</span>, <span style="color: #006080">"MonWebService.svc"</span>);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> }</pre>
</p></div>
</div>
<p>On remarque que l&rsquo;appel à la méthode ExtractResource qui prend en paramètres deux fichiers, le web.config et le fichier svc. Ce sont des fichiers du web service qui devront être copiés dans le test unitaires et inclus en tant que ressource.</p>
<p><a href="http://blog.developpez.com/media/140/WindowsLiveWriter/TestsUnitairesCommenttesterunwebserviceW_FC7F/image_10.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.developpez.com/media/140/WindowsLiveWriter/TestsUnitairesCommenttesterunwebserviceW_FC7F/image_thumb_4.png" width="289" height="231" /></a> </p>
<p>Il ne reste plus qu&rsquo;à instancier la classe proxy et vérifier que tout se passe bien.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> [TestMethod]</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> FaitQuelqueChose_EnUtilisantLeWebDevWebHost_EstFonctionnel()</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     MonWebServiceClient monWebServiceClient = <span style="color: #0000ff">new</span> MonWebServiceClient();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     <span style="color: #0000ff">int</span> <span style="color: #0000ff">value</span> = monWebServiceClient.FaitQuelqueChose();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>  </pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     Assert.AreEqual(10, <span style="color: #0000ff">value</span>);</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> }</pre>
</p></div>
</div>
<p>Sans oublier de libérer les ressources en fin de test :</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> [TestCleanup]</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> MyTestCleanup()</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> {</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     _webHostWebServer.Stop();</pre>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> }</pre>
</p></div>
</div>
<p>Notez que pour s&rsquo;exécuter correctement, le test a besoin de pouvoir accéder à la DLL qui contient l&rsquo;implémentation du service. Il faudra donc soit l&rsquo;ajouter en tant que référence au projet afin qu&rsquo;elle soit copiée dans le répertoire de destination, soit exécuter une post-build event du type :</p>
<p>copy &laquo;&nbsp;$(SolutionDir)leRepertoire\$(OutDir)MonServiceWCF.dll&nbsp;&raquo; &laquo;&nbsp;$(TargetDir)&nbsp;&raquo;</p>
</p>
</p>
</p>
<p>Il n&rsquo;y a plus qu&rsquo;à tester :</p>
<p><a href="http://blog.developpez.com/media/140/WindowsLiveWriter/TestsUnitairesCommenttesterunwebserviceW_FC7F/image_12.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://blog.developpez.com/media/140/WindowsLiveWriter/TestsUnitairesCommenttesterunwebserviceW_FC7F/image_thumb_5.png" width="303" height="54" /></a> Et voilà, prêt pour une intégration continue <img src="https://blog.developpez.com/nico-pyright/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
<p><a href="ftp://ftp-developpez.com/nico-pyright/blog/DemoTestWebService.zip">Vous pouvez téléchargez les sources de l&rsquo;exemple ici</a></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Tests] Arrange Act Assert, une traduction ?</title>
		<link>https://blog.developpez.com/nico-pyright/p8220/test/tests_arrange_act_assert_une_traduction</link>
		<comments>https://blog.developpez.com/nico-pyright/p8220/test/tests_arrange_act_assert_une_traduction#comments</comments>
		<pubDate>Fri, 23 Oct 2009 16:29:00 +0000</pubDate>
		<dc:creator><![CDATA[nico-pyright(c)]]></dc:creator>
				<category><![CDATA[Test]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Les personnes qui écrivent des tests unitaires connaissent en général ce pattern qui consiste à organiser son test en 3 parties : Arrange => initialiser les objets mis en jeu par le test Act => Exécuter la méthode que l&#8217;on souhaite tester Assert => Vérifier que les résultats sont conforme aux attentes Je n&#8217;ai pas vu de traduction officielle de cette abréviation. Que pensez-vous de : Arranger Agir Auditer En avez vous d&#8217;autres à proposer [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Les personnes qui écrivent des tests unitaires connaissent en général ce pattern qui consiste à organiser son test en 3 parties :</p>
<ul>
<li>Arrange => initialiser les objets mis en jeu par le test </li>
<li>Act => Exécuter la méthode que l&rsquo;on souhaite tester </li>
<li>Assert => Vérifier que les résultats sont conforme aux attentes </li>
</ul>
<p>Je n&rsquo;ai pas vu de traduction officielle de cette abréviation.</p>
<p>Que pensez-vous de :</p>
<ul>
<li>Arranger </li>
<li>Agir </li>
<li>Auditer </li>
</ul>
<p>En avez vous d&rsquo;autres à proposer ? </p>
<p>Bien sur, l&rsquo;objectif est de garder les 3 A <img src="https://blog.developpez.com/nico-pyright/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>[Tests unitaires][C#] Comment tester sa couche d’accès aux données (DAL) ?</title>
		<link>https://blog.developpez.com/nico-pyright/p8194/c/tests_unitaires_comment_tester_sa_couche</link>
		<comments>https://blog.developpez.com/nico-pyright/p8194/c/tests_unitaires_comment_tester_sa_couche#comments</comments>
		<pubDate>Tue, 13 Oct 2009 19:34:00 +0000</pubDate>
		<dc:creator><![CDATA[nico-pyright(c)]]></dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Tester sa couche d&#8217;accès aux données (DAL) est toujours un calvaire pour le développeur. La principale raison réside dans la nature même d&#8217;une base de données et dans sa fonction de persistance d&#8217;état. Or, un test doit pouvoir se baser sur un contexte connu et le fait de tester des opérations CRUD sur sa base de données va forcément modifier ce contexte. On en déduit deux axes principaux : Avoir un contexte connu => i.e. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Tester sa couche d&rsquo;accès aux données (DAL) est toujours un calvaire pour le développeur. La principale raison réside dans la nature même d&rsquo;une base de données et dans sa fonction de persistance d&rsquo;état. </p>
<p>Or, un test doit pouvoir se baser sur un contexte connu et le fait de tester des opérations CRUD sur sa base de données va forcément modifier ce contexte. On en déduit deux axes principaux : </p>
<ul>
<li>Avoir un contexte connu => i.e. avoir des valeurs dans la base de données </li>
<li>Ne pas modifier le contexte => i.e. restaurer l&rsquo;état de la base comme au début du test </li>
</ul>
<p>Quelles sont les différentes pistes que nous pouvons explorer pour résoudre ce problème ? </p>
<p> <span id="more-50"></span>
<ul>
<li>Ajouter, supprimer manuellement les données qui ont pu être supprimées, ajoutées à chaque test. Cela nécessite d&rsquo;exécuter du sql en vrac à chaque test et peut être un travail laborieux et décourager le développeur quand les données sont nombreuses. </li>
<li>Restaurer un dump de la base de données de test après chaque exécution du test. Cela est très problématique si la base de données est volumineuse. </li>
<li>Avoir un moyen de mettre une base de données de test dans un certain état à chaque début de test, comme expliqué dans cet article : <a href="http://aspnet.4guysfromrolla.com/articles/040605-1.aspx" target="_blank">Unit Testing the Data Access Layer, par Tim Stall</a> ou dans celui-ci : <a href="http://msdn.microsoft.com/en-us/library/aa479010.aspx" target="_blank">Get Test Infected with NUnit: Unit Test Your .NET Data Access Layer, par Steven A. Smith</a>. Cela nécessite un gros travail pour mettre sa base en état (construction de script sql pour vider la base, construire la structure, ajouter les données, etc &#8230;) et un temps non négligeable d&rsquo;exécution à chaque test. Cela peut aussi être gênant lorsqu&rsquo;on travaille à plusieurs sur la même base de test. </li>
<li>Avoir une base de données de test et exécuter chaque opération CRUD dans une transaction (par exemple <a href="http://http://msdn.microsoft.com/fr-fr/library/system.data.sqlclient.sqltransaction%28VS.80%29.aspx" target="_blank">la classe SqlTransaction</a>), comme on peut le retrouver dans le livre <a href="http://www.amazon.fr/Test-Driven-Development-Microsoft-James-Newkirk/dp/0735619484" target="_blank">Test-Driven Development in Microsoft .Net de James Newkirk et Alexei A. Vorontsov</a>) qui sera ensuite annulée. Cela nécessite de rajouter du code spécifique dans nos tests pour créer et annuler la transaction. </li>
<li>Utiliser <a href="http://msdn.microsoft.com/fr-fr/library/ms973847.aspx" target="_blank">COM+ entreprise services</a> (ou COM+ 1.5) et utiliser une classe de base pour ses tests qui encapsule la création et l&rsquo;annulation de la transaction, comme décrit dans l&rsquo;article <a href="http://msdn.microsoft.com/en-us/magazine/cc163772.aspx" target="_blank">Simplify Data Layer Unit Testing using Enterprise Services de Roy Osherove</a>. Cela nécessite d&rsquo;avoir un provider ADO.NET qui supporte les transactions distribuées, ce qui est quand même le cas de bon nombre d&rsquo;entre eux et nécessite d&rsquo;exécuter que des commandes sql qui peuvent être utilisées dans une transaction distribuée. </li>
<li>Des frameworks de test (<a href="http://mbunit.tigris.org/" target="_blank">MbUnit</a>, <a href="http://teamagile.com/mainpages/downloads.html" target="_blank">XtUnit</a>, <a href="http://www.osherove.com/" target="_blank">NunitX</a>) semblent utiliser des attributs à poser sur ses tests pour effectuer la restauration des données altérées) </li>
</ul>
<p>Et vous, comment testez-vous vos DAL ?</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
