﻿<?xml version="1.0" encoding="utf-8"?>
<!-- 
XSLT Schema for generating build reports for CCNet Dashboard from unit test report generated by MSTest utility (v. 8.0.50727.26)
Author: Roman V. Gavrilov (clavrg@hotmail.com)
Modified by Richard Fennell (richard@blackmarble.co.uk) for use with Visual Studio 2008 (MSTest V9.x)
-->

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:a ="http://microsoft.com/schemas/VisualStudio/TeamTest/2006">

	<xsl:param name="today"></xsl:param>
	<xsl:param name="results"></xsl:param>
	<xsl:param name="pass" select='Passed'/>
	<xsl:param name="fail" select="Failed"/>
	<xsl:template match="/">

		<html>

			<body style="font-family:Verdana; font-size:10pt">

				<xsl:variable name="pass_count" select="count(//a:UnitTestResult/@outcome[.='Passed'])"/>
				<xsl:variable name="inconclusive_count" select="count(//a:UnitTestResult/@outcome[.='Inconclusive'])"/>
				<xsl:variable name="failed_count" select="count(//a:UnitTestResult/@outcome[.='Failed'])"/>
				<xsl:variable name="total_count" select="count(//a:UnitTestResult/@outcome)"/>

				<table class="section-table" width="100%">
					<tr>
						<td class="sectionheader">
							Tests run: <xsl:value-of select="$total_count"/>, Failures: <xsl:value-of select="$failed_count"/>, Inconclusive: <xsl:value-of select="$inconclusive_count"/>
						</td>
					</tr>

					<tr>
						<td>
							<table>
								<tr>
									<td width="100">
										<b>Passed:</b>
									</td>
									<td>
										<xsl:value-of select="$pass_count"/>
									</td>
								</tr>
								<tr>
									<td>
										<b>Failed:</b>
									</td>
									<td>
										<xsl:value-of select="$failed_count"/>
									</td>
								</tr>
								<tr>
									<td>
										<b>Inconclusive:</b>
									</td>
									<td>
										<xsl:value-of select="$inconclusive_count"/>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<!-- BAR -->
					<tr>
						<td width="100%">
							<table border="1" width="100%">
								<tr height="20">
									<xsl:choose>
										<xsl:when test="$total_count=$pass_count">
											<td bgcolor="00FF33" align="center">
												<b>PASSED</b>
											</td>
										</xsl:when>
										<xsl:otherwise>
											<td bgcolor="FF0000" align="center">
												<b>FAILED</b>
											</td>
										</xsl:otherwise>
									</xsl:choose>
								</tr>
							</table>
						</td>
					</tr>
					<!-- DETAILS TABLE -->
					<tr>
						<td>
							<table border="1" width="100%" frame="box">
								<tr bgcolor="#2288FF">
									<th align="center" width="40">Code</th>
									<th align="left">Method</th>
									<th align="left">Class</th>
									<th align="left">Message</th>
									<th align="left">Duration</th>
								</tr>

								<xsl:for-each select="//a:UnitTestResult">
									<tr>
										<xsl:choose>
											<xsl:when test="contains(@outcome,'Passed')">
												<td bgcolor="00FF33" align="center"> P </td>
											</xsl:when>
											<xsl:when test="contains(@outcome,'Failed')">
												<td bgcolor="FF0000" align="center"> F </td>
											</xsl:when>
											<xsl:when test="contains(@outcome,'Inconclusive')">
												<td bgcolor="FFCC00" align="center"> I </td>
											</xsl:when>
											<xsl:otherwise>
												<td bgcolor="3399FF" align="center"> ? </td>
											</xsl:otherwise>
										</xsl:choose>
										<td>
											<xsl:value-of select="@testName"/>
										</td>
										<td>
											
											
											
											
											<xsl:variable name="testId" select="@testId"/>
											<xsl:variable name="className" select="//a:UnitTest[@id=$testId]/a:TestMethod/@className"/>

			
											<script type="text/javascript">
												var str= &quot; <xsl:value-of select="$className"/> &quot;
												var pos=str.indexOf(",");
												if (pos>=0) { var cs = str.substring(0, pos); document.write(cs); }
												else { document.write("&lt; class name not specified&gt;"); }
											</script>
										</td>
										<td>
											<xsl:value-of select="."/>
											
										</td>
										
										<td>
											<xsl:value-of select="concat(substring-before(@duration,'.'),'.',substring(substring-after(@duration,'.'),1,2))"/>
										</td>
									</tr>
								</xsl:for-each>
							</table>
						</td>
					</tr>
				</table>			
			</body>

		</html>		
		
	</xsl:template>

</xsl:stylesheet>

