MsTestSummaryStylesheetTest.cs :  » Build-Systems » CruiseControl.NET » ThoughtWorks » CruiseControl » UnitTests » Xsl » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Build Systems » CruiseControl.NET 
CruiseControl.NET » ThoughtWorks » CruiseControl » UnitTests » Xsl » MsTestSummaryStylesheetTest.cs
using System;
using NUnit.Framework;

namespace ThoughtWorks.CruiseControl.UnitTests.Xsl{
  [TestFixture, Ignore("Ignore until example xml can be retrieved from new version of MSTest")]
  public class MsTestSummaryStylesheetTest : StylesheetTestFixture
  {
    protected override string Stylesheet
    {
      get { return @"xsl\MsTestSummary.xsl"; }
    }

    [Test]
    public void ShouldNotRenderAnyOutputIfRootNodeIsMissing()
    {
      string xml = WrapInBuildResultsElement("<foo>bar</foo>");
      string actualXml = LoadStylesheetAndTransformInput(xml);
      Assert.AreEqual("", actualXml);
    }

    [Test]
    public void ShouldRenderTotalTestsWhenAllTestsPass()
    {
      string xml = WrapInTestsElement(@"<TestRun type=""Microsoft.VisualStudio.TestTools.Common.TestRun"">
<result type=""Microsoft.VisualStudio.TestTools.Common.RunResultAndStatistics"">
  <totalTestCount type=""System.Int32"">29</totalTestCount> 
  <executedTestCount type=""System.Int32"">29</executedTestCount> 
  <passedTestCount type=""System.Int32"">29</passedTestCount> 
</result></TestRun>");
      string actualXml = LoadStylesheetAndTransformInput(xml);
      Console.Out.WriteLine("actualXml = {0}", actualXml);
      CustomAssertion.AssertContains("Tests run: 29", actualXml);
      CustomAssertion.AssertContains("Failures: 0", actualXml);
      CustomAssertion.AssertContains("Not run: 0", actualXml);
      CustomAssertion.AssertContains("All tests passed.", actualXml);
      CustomAssertion.AssertNotContains("FooTest", actualXml);
    }

    [Test]
    public void ShouldRenderFailedTests()
    {
      string xml = WrapInTestsElement(@"<TestRun type=""Microsoft.VisualStudio.TestTools.Common.TestRun"">
<result type=""Microsoft.VisualStudio.TestTools.Common.RunResultAndStatistics"">
  <totalTestCount type=""System.Int32"">29</totalTestCount> 
  <executedTestCount type=""System.Int32"">28</executedTestCount> 
  <passedTestCount type=""System.Int32"">27</passedTestCount> 
</result></TestRun>
<UnitTestResult type=""Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestResult, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"">
  <outcome type=""Microsoft.VisualStudio.TestTools.Common.TestOutcome"">
    <value__ type=""System.Int32"">1</value__>
  </outcome>
  <errorInfo type=""Microsoft.VisualStudio.TestTools.Common.TestResultErrorInfo"">
    <message type=""System.String"">
    Test method Com.Suncor.Olt.Common.DataAccess.DatabaseGatewayTest.ShouldNotAcceptWrongNumberOfParameters threw exception:  System.ApplicationException: Received 7 parameters for InsertFoo, expected 1.
    </message>
    <stackTrace type=""System.String"">
    at Com.Suncor.Olt.Common.DataAccess.DatabaseGateway.CheckNumberOfInputParameters(IDbCommand command, String procedureName, Object[] parameters) in C:\Projects\OLT\src\Common\App\DataAccess\DatabaseGateway.cs:line 148
   at Com.Suncor.Olt.Common.DataAccess.DatabaseGateway.ExecuteNonQuery(String procedureName, Object[] parameters) in C:\Projects\OLT\src\Common\App\DataAccess\DatabaseGateway.cs:line 78
   at Com.Suncor.Olt.Common.DataAccess.DatabaseGatewayTest.ShouldNotAcceptWrongNumberOfParameters() in C:\Projects\OLT\src\Common\Test.UnitTest\DataAccess\DatabaseGatewayTest.cs:line 90
    </stackTrace>
  </errorInfo>
  <testName type=""System.String"">ShouldNotAcceptWrongNumberOfParameters</testName>
</UnitTestResult>
<UnitTestResult type=""Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestResult, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"">
  <outcome type=""Microsoft.VisualStudio.TestTools.Common.TestOutcome"">
    <value__ type=""System.Int32"">10</value__>
  </outcome>
  <testName type=""System.String"">FooTest</testName>
</UnitTestResult>");
      string actualXml = LoadStylesheetAndTransformInput(xml);
      CustomAssertion.AssertContains("Tests run: 28", actualXml);
      CustomAssertion.AssertContains("Failures: 1", actualXml);
      CustomAssertion.AssertContains("Not run: 1", actualXml);
      CustomAssertion.AssertNotContains("All tests passed.", actualXml);
      CustomAssertion.AssertContains("ShouldNotAcceptWrongNumberOfParameters", actualXml);
      CustomAssertion.AssertContains("System.ApplicationException", actualXml);
      CustomAssertion.AssertContains("Stacktrace", actualXml);
      CustomAssertion.AssertNotContains("FooTest", actualXml);
    }

    private string WrapInTestsElement(string xml)
    {
      return WrapInBuildResultsElement(string.Format(@"<Tests>{0}</Tests>", xml));
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.