RequestWrappingCruiseRequestTest.cs :  » Build-Systems » CruiseControl.NET » ThoughtWorks » CruiseControl » UnitTests » WebDashboard » IO » 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 » WebDashboard » IO » RequestWrappingCruiseRequestTest.cs
using NMock;
using System.Collections.Specialized;
using NUnit.Framework;
using ThoughtWorks.CruiseControl.WebDashboard.IO;
using ThoughtWorks.CruiseControl.WebDashboard.MVC;
using ThoughtWorks.CruiseControl.Core.Reporting.Dashboard.Navigation;

namespace ThoughtWorks.CruiseControl.UnitTests.WebDashboard.IO{
  [TestFixture]
  public class RequestWrappingCruiseRequestTest
  {
    private NameValueCollection queryString;
    private IRequest underlyingRequest;
    private RequestWrappingCruiseRequest cruiseRequest;
    private string applicationPath;

    [SetUp]
    public void Setup()
    {
      queryString = new NameValueCollection();
      applicationPath = "http://bar/";
      CreateCruiseRequest("baz.html");
    }

    private void CreateCruiseRequest(string relativePath)
    {
            DynamicMock urlBuilderMock = new DynamicMock(typeof(ICruiseUrlBuilder));
            underlyingRequest = new NameValueCollectionRequest(queryString, null, applicationPath + relativePath, null, applicationPath);
            cruiseRequest = new RequestWrappingCruiseRequest(underlyingRequest, (ICruiseUrlBuilder)urlBuilderMock.MockInstance, null);
    }

    [Test]
    public void ReturnsEmptyStringIfNoProjectSpecified()
    {
      Assert.AreEqual(string.Empty, cruiseRequest.ProjectName);
    }

    [Test]
    public void ReturnsProjectNameIfProjectSpecified()
    {
      CreateCruiseRequest("server/myserver/project/myproject/baz.html");
      Assert.AreEqual("myproject", cruiseRequest.ProjectName);
    }

    [Test]
    public void ReturnsEmptyStringIfNoServerSpecified()
    {
      Assert.AreEqual(string.Empty, cruiseRequest.ServerName);
    }

    [Test]
    public void ReturnsServerNameIfServerSpecified()
    {
      CreateCruiseRequest("server/myserver/baz.html");
      Assert.AreEqual("myserver", cruiseRequest.ServerName);
    }

    [Test]
    public void ReturnsEmptyStringIfNoBuildSpecified()
    {
      Assert.AreEqual(string.Empty, cruiseRequest.BuildName);
    }

    [Test]
    public void ReturnsBuildNameIfBuildSpecified()
    {
      CreateCruiseRequest("server/myserver/project/myproject/build/mybuild/baz.html");
      Assert.AreEqual("mybuild", cruiseRequest.BuildName);
    }

    [Test]
    public void DecodeServerName()
    {
      CreateCruiseRequest("server/my+server/baz.html");
      Assert.AreEqual("my server", cruiseRequest.ServerName);
    }

    [Test]
    public void DecodeProjectName()
    {
      CreateCruiseRequest("server/my+server/project/my+project%232/baz.html");
      Assert.AreEqual("my project#2", cruiseRequest.ProjectName);
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.