Permalink
Browse files

First hack at the test harness described in #213. Still missing auto-…

…build of Glimpse packages, auto-build of test site, iis express support, iis support and auto nuget package updating.
  • Loading branch information...
nikmd23 committed Dec 19, 2012
1 parent 0da12bd commit b882562496d96a297fd054bce00ffe08da86c56c
Showing with 10,149 additions and 1 deletion.
  1. +1 −1 Glimpse.All.sln
  2. +50 −0 Glimpse.Integration.sln
  3. +3 −0 Glimpse.Integration.sln.DotSettings
  4. +24 −0 default.ps1
  5. +8 −0 integration.xunit
  6. +11 −0 source/Glimpse.Test.Integration.Site/Code/DomainData.cs
  7. +169 −0 source/Glimpse.Test.Integration.Site/Code/DomainRoute.cs
  8. +75 −0 source/Glimpse.Test.Integration.Site/Content/Site.css
  9. +12 −0 source/Glimpse.Test.Integration.Site/Controllers/HomeController.cs
  10. +14 −0 source/Glimpse.Test.Integration.Site/Controllers/RoutingController.cs
  11. +156 −0 source/Glimpse.Test.Integration.Site/Glimpse.Test.Integration.Site.csproj
  12. +30 −0 source/Glimpse.Test.Integration.Site/GlimpseSecurityPolicy.cs
  13. +1 −0 source/Glimpse.Test.Integration.Site/Global.asax
  14. +43 −0 source/Glimpse.Test.Integration.Site/Global.asax.cs
  15. +28 −0 source/Glimpse.Test.Integration.Site/IntegrationTestTab.cs
  16. +35 −0 source/Glimpse.Test.Integration.Site/Properties/AssemblyInfo.cs
  17. +7,117 −0 source/Glimpse.Test.Integration.Site/Scripts/MicrosoftAjax.debug.js
  18. +6 −0 source/Glimpse.Test.Integration.Site/Scripts/MicrosoftAjax.js
  19. +408 −0 source/Glimpse.Test.Integration.Site/Scripts/MicrosoftMvcAjax.debug.js
  20. +25 −0 source/Glimpse.Test.Integration.Site/Scripts/MicrosoftMvcAjax.js
  21. +883 −0 source/Glimpse.Test.Integration.Site/Scripts/MicrosoftMvcValidation.debug.js
  22. +55 −0 source/Glimpse.Test.Integration.Site/Scripts/MicrosoftMvcValidation.js
  23. +165 −0 source/Glimpse.Test.Integration.Site/Scripts/jquery.unobtrusive-ajax.js
  24. +5 −0 source/Glimpse.Test.Integration.Site/Scripts/jquery.unobtrusive-ajax.min.js
  25. +319 −0 source/Glimpse.Test.Integration.Site/Scripts/jquery.validate.unobtrusive.js
  26. +5 −0 source/Glimpse.Test.Integration.Site/Scripts/jquery.validate.unobtrusive.min.js
  27. +3 −0 source/Glimpse.Test.Integration.Site/Views/Home/Index.cshtml
  28. +7 −0 source/Glimpse.Test.Integration.Site/Views/Routing/Subdomain.cshtml
  29. +15 −0 source/Glimpse.Test.Integration.Site/Views/Shared/Error.cshtml
  30. +11 −0 source/Glimpse.Test.Integration.Site/Views/Shared/_Layout.cshtml
  31. +58 −0 source/Glimpse.Test.Integration.Site/Views/Web.config
  32. +3 −0 source/Glimpse.Test.Integration.Site/Views/_ViewStart.cshtml
  33. +30 −0 source/Glimpse.Test.Integration.Site/Web.Debug.config
  34. +31 −0 source/Glimpse.Test.Integration.Site/Web.Release.config
  35. +71 −0 source/Glimpse.Test.Integration.Site/Web.config
  36. BIN source/Glimpse.Test.Integration.Site/favicon.ico
  37. +7 −0 source/Glimpse.Test.Integration.Site/packages.config
  38. +21 −0 source/Glimpse.Test.Integration/BrowserFactory.cs
  39. +83 −0 source/Glimpse.Test.Integration/Glimpse.Test.Integration.csproj
  40. +80 −0 source/Glimpse.Test.Integration/GlimpseShould.cs
  41. +36 −0 source/Glimpse.Test.Integration/Properties/AssemblyInfo.cs
  42. BIN source/Glimpse.Test.Integration/Tests.xls
  43. +37 −0 source/Glimpse.Test.Integration/WebDriverExtensions.cs
  44. +8 −0 source/Glimpse.Test.Integration/packages.config
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 2010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{CCFACE51-18FA-4C5D-9F89-EC58881786A9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{A3097EAF-9D1B-416A-822E-F679D768BC55}"
@@ -0,0 +1,50 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{0352975D-08B7-435E-B444-A77292D4F6E1}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
.nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glimpse.Test.Integration", "source\Glimpse.Test.Integration\Glimpse.Test.Integration.csproj", "{8354ECF9-3E63-4A7E-AC9C-5D67119B1297}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glimpse.Test.Integration.Site", "source\Glimpse.Test.Integration.Site\Glimpse.Test.Integration.Site.csproj", "{2947CE84-2B3C-4B8A-BEFB-02D71B257238}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8354ECF9-3E63-4A7E-AC9C-5D67119B1297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8354ECF9-3E63-4A7E-AC9C-5D67119B1297}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8354ECF9-3E63-4A7E-AC9C-5D67119B1297}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{8354ECF9-3E63-4A7E-AC9C-5D67119B1297}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{8354ECF9-3E63-4A7E-AC9C-5D67119B1297}.Debug|x86.ActiveCfg = Debug|Any CPU
{8354ECF9-3E63-4A7E-AC9C-5D67119B1297}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8354ECF9-3E63-4A7E-AC9C-5D67119B1297}.Release|Any CPU.Build.0 = Release|Any CPU
{8354ECF9-3E63-4A7E-AC9C-5D67119B1297}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8354ECF9-3E63-4A7E-AC9C-5D67119B1297}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8354ECF9-3E63-4A7E-AC9C-5D67119B1297}.Release|x86.ActiveCfg = Release|Any CPU
{2947CE84-2B3C-4B8A-BEFB-02D71B257238}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2947CE84-2B3C-4B8A-BEFB-02D71B257238}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2947CE84-2B3C-4B8A-BEFB-02D71B257238}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2947CE84-2B3C-4B8A-BEFB-02D71B257238}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2947CE84-2B3C-4B8A-BEFB-02D71B257238}.Debug|x86.ActiveCfg = Debug|Any CPU
{2947CE84-2B3C-4B8A-BEFB-02D71B257238}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2947CE84-2B3C-4B8A-BEFB-02D71B257238}.Release|Any CPU.Build.0 = Release|Any CPU
{2947CE84-2B3C-4B8A-BEFB-02D71B257238}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2947CE84-2B3C-4B8A-BEFB-02D71B257238}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2947CE84-2B3C-4B8A-BEFB-02D71B257238}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue">&lt;data&gt;&lt;IncludeFilters /&gt;&lt;ExcludeFilters /&gt;&lt;/data&gt;</s:String>
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue">&lt;data /&gt;</s:String></wpf:ResourceDictionary>
@@ -196,6 +196,30 @@ task push {
task buildjs {
}

task int {
"Integration Testing"

"`nInstalling Glimpse"
#cd $base_dir\.NuGet

#nuget update -source "c:\glimpse\builds\local" -Id Glimpse.MVC3;Glimpse.AspNet;Glimpse -Verbose "c:\glimpse\source\Glimpse.Test.Integration.Cassini\packages.config"
#exec { & .\nuget.exe update -source $build_dir\local -id "Glimpse.MVC3, Glimpse.AspNet, Glimpse" }




"`nEnding Cassini"
kill -name WebDev.WebServer*

"`nStarting Cassini"
&WebDev.WebServer40.EXE /port:234 /path:"$source_dir\Glimpse.Test.Integration.Cassini"

"`nRunning Tests"
New-Item $build_dir\local\artifacts -Type directory -Force > $null
cd $package_dir\xunit.runners*\tools\
exec { & .\xunit.console.clr4.x86 $base_dir\integration.xunit }
}

#functions ---------------------------------------------------------------------------------------------------------

function Push-Packages($uri)
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<xunit>
<assemblies>
<assembly filename="source\Glimpse.Test.Integration\bin\Release\Glimpse.Test.Integration.dll" shadow-copy="true">
<output type="xml" filename="builds\local\artifacts\test.integration.xml" />
</assembly>
</assemblies>
</xunit>
@@ -0,0 +1,11 @@
namespace Glimpse.Test.Integration.Site.Code
{
public class DomainData
{
public string Protocol { get; set; }

public string HostName { get; set; }

public string Fragment { get; set; }
}
}
@@ -0,0 +1,169 @@
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Glimpse.Test.Integration.Site.Code
{
public class DomainRoute : Route
{
private Regex domainRegex;
private Regex pathRegex;

public DomainRoute(string domain, string url, RouteValueDictionary defaults) : base(url, defaults, new MvcRouteHandler())
{
Domain = domain;
}

public DomainRoute(string domain, string url, RouteValueDictionary defaults, IRouteHandler routeHandler) : base(url, defaults, routeHandler)
{
Domain = domain;
}

public DomainRoute(string domain, string url, object defaults) : base(url, new RouteValueDictionary(defaults), new MvcRouteHandler())
{
Domain = domain;
}

public DomainRoute(string domain, string url, object defaults, IRouteHandler routeHandler) : base(url, new RouteValueDictionary(defaults), routeHandler)
{
Domain = domain;
}

public string Domain { get; set; }

public override RouteData GetRouteData(HttpContextBase httpContext)
{
// Build regex
domainRegex = CreateRegex(Domain);
pathRegex = CreateRegex(Url);

// Request information
string requestDomain = httpContext.Request.Headers["host"];
if (!string.IsNullOrEmpty(requestDomain))
{
if (requestDomain.IndexOf(":") > 0)
{
requestDomain = requestDomain.Substring(0, requestDomain.IndexOf(":"));
}
}
else
{
requestDomain = httpContext.Request.Url.Host;
}
string requestPath = httpContext.Request.AppRelativeCurrentExecutionFilePath.Substring(2) + httpContext.Request.PathInfo;

// Match domain and route
Match domainMatch = domainRegex.Match(requestDomain);
Match pathMatch = pathRegex.Match(requestPath);

// Route data
RouteData data = null;
if (domainMatch.Success && pathMatch.Success)
{
data = new RouteData(this, RouteHandler);

// Add defaults first
if (Defaults != null)
{
foreach (KeyValuePair<string, object> item in Defaults)
{
data.Values[item.Key] = item.Value;
}
}

// Iterate matching domain groups
for (int i = 1; i < domainMatch.Groups.Count; i++)
{
Group group = domainMatch.Groups[i];
if (group.Success)
{
string key = domainRegex.GroupNameFromNumber(i);

if (!string.IsNullOrEmpty(key) && !char.IsNumber(key, 0))
{
if (!string.IsNullOrEmpty(group.Value))
{
data.Values[key] = group.Value;
}
}
}
}

// Iterate matching path groups
for (int i = 1; i < pathMatch.Groups.Count; i++)
{
Group group = pathMatch.Groups[i];
if (group.Success)
{
string key = pathRegex.GroupNameFromNumber(i);

if (!string.IsNullOrEmpty(key) && !char.IsNumber(key, 0))
{
if (!string.IsNullOrEmpty(group.Value))
{
data.Values[key] = group.Value;
}
}
}
}
}

return data;
}

public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
{
return base.GetVirtualPath(requestContext, RemoveDomainTokens(values));
}

public DomainData GetDomainData(RequestContext requestContext, RouteValueDictionary values)
{
// Build hostname
string hostname = Domain;
foreach (KeyValuePair<string, object> pair in values)
{
hostname = hostname.Replace("{" + pair.Key + "}", pair.Value.ToString());
}

// Return domain data
return new DomainData
{
Protocol = "http",
HostName = hostname,
Fragment = ""
};
}

private Regex CreateRegex(string source)
{
// Perform replacements
source = source.Replace("/", @"\/?");
source = source.Replace(".", @"\.?");
source = source.Replace("-", @"\-?");
source = source.Replace("{", @"(?<");
source = source.Replace("}", @">([a-zA-Z0-9_]*))");

return new Regex("^" + source + "$");
}

private RouteValueDictionary RemoveDomainTokens(RouteValueDictionary values)
{
Regex tokenRegex = new Regex(@"({[a-zA-Z0-9_]*})*-?\.?\/?({[a-zA-Z0-9_]*})*-?\.?\/?({[a-zA-Z0-9_]*})*-?\.?\/?({[a-zA-Z0-9_]*})*-?\.?\/?({[a-zA-Z0-9_]*})*-?\.?\/?({[a-zA-Z0-9_]*})*-?\.?\/?({[a-zA-Z0-9_]*})*-?\.?\/?({[a-zA-Z0-9_]*})*-?\.?\/?({[a-zA-Z0-9_]*})*-?\.?\/?({[a-zA-Z0-9_]*})*-?\.?\/?({[a-zA-Z0-9_]*})*-?\.?\/?({[a-zA-Z0-9_]*})*-?\.?\/?");
Match tokenMatch = tokenRegex.Match(Domain);
for (int i = 0; i < tokenMatch.Groups.Count; i++)
{
Group group = tokenMatch.Groups[i];
if (group.Success)
{
string key = group.Value.Replace("{", "").Replace("}", "");
if (values.ContainsKey(key))
values.Remove(key);
}
}

return values;
}
}
}
@@ -0,0 +1,75 @@
body
{
font-size: .85em;
font-family: "Trebuchet MS", Verdana, Helvetica, Sans-Serif;
color: #232323;
background-color: #fff;
}

header,
footer,
nav,
section {
display: block;
}

/* Styles for basic forms
-----------------------------------------------------------*/

fieldset
{
border:1px solid #ddd;
padding:0 1.4em 1.4em 1.4em;
margin:0 0 1.5em 0;
}

legend
{
font-size:1.2em;
font-weight: bold;
}

textarea
{
min-height: 75px;
}

.editor-label
{
margin: 1em 0 0 0;
}

.editor-field
{
margin:0.5em 0 0 0;
}


/* Styles for validation helpers
-----------------------------------------------------------*/
.field-validation-error
{
color: #ff0000;
}

.field-validation-valid
{
display: none;
}

.input-validation-error
{
border: 1px solid #ff0000;
background-color: #ffeeee;
}

.validation-summary-errors
{
font-weight: bold;
color: #ff0000;
}

.validation-summary-valid
{
display: none;
}
@@ -0,0 +1,12 @@
using System.Web.Mvc;

namespace Glimpse.Test.Integration.Site.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
}
@@ -0,0 +1,14 @@
using System.Web.Mvc;

namespace Glimpse.Test.Integration.Site.Controllers
{
public class RoutingController : Controller
{
public ActionResult Subdomain()
{
HttpContext.Items.Add(IntegrationTestTab.Expected, RouteData.Values["subdomain"]);

return View();
}
}
}
Oops, something went wrong.

0 comments on commit b882562

Please sign in to comment.