Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial import of FubuMVC.SelfHost

  • Loading branch information...
commit f42f380cba71c874804a60a0504fd7f1e87a29db 1 parent d6eedcf
@jeremydmiller jeremydmiller authored
Showing with 1,957 additions and 155 deletions.
  1. +1 −0  .gitignore
  2. +1 −1  bottles.cmd
  3. +3 −6 rakefile.rb
  4. +3 −3 src/AspNetApplication/AspNetApplication.csproj
  5. +3 −3 src/AspNetApplication/packages.config
  6. +3 −3 src/AssemblyPackage/AssemblyPackage.csproj
  7. +3 −3 src/AssemblyPackage/packages.config
  8. +4 −4 src/Fubu/Fubu.csproj
  9. +4 −4 src/Fubu/packages.config
  10. +3 −3 src/FubuKayak/FubuKayak.csproj
  11. +3 −3 src/FubuKayak/packages.config
  12. +4 −4 src/FubuMVC.AspNetTesting/FubuMVC.AspNetTesting.csproj
  13. +4 −4 src/FubuMVC.AspNetTesting/packages.config
  14. +4 −4 src/FubuMVC.Core/FubuMVC.Core.csproj
  15. +4 −4 src/FubuMVC.Core/packages.config
  16. +2 −2 src/FubuMVC.GettingStarted/FubuMVC.GettingStarted.csproj
  17. +2 −2 src/FubuMVC.GettingStarted/packages.config
  18. +3 −3 src/FubuMVC.HelloWorld/FubuMVC.HelloWorld.csproj
  19. +3 −3 src/FubuMVC.HelloWorld/packages.config
  20. +4 −4 src/FubuMVC.IntegrationTesting/FubuMVC.IntegrationTesting.csproj
  21. +4 −4 src/FubuMVC.IntegrationTesting/packages.config
  22. +2 −2 src/FubuMVC.OwinHost.Testing/FubuMVC.OwinHost.Testing.csproj
  23. +2 −2 src/FubuMVC.OwinHost.Testing/packages.config
  24. +1 −1  src/FubuMVC.OwinHost/FubuMVC.OwinHost.csproj
  25. +1 −1  src/FubuMVC.OwinHost/packages.config
  26. +5 −5 src/FubuMVC.Razor.Tests/FubuMVC.Razor.Tests.csproj
  27. +5 −5 src/FubuMVC.Razor.Tests/packages.config
  28. +3 −3 src/FubuMVC.Razor/FubuMVC.Razor.csproj
  29. +3 −3 src/FubuMVC.Razor/packages.config
  30. +14 −0 src/FubuMVC.SelfHost.Testing/Fake.cs
  31. +142 −0 src/FubuMVC.SelfHost.Testing/FubuMVC.SelfHost.Testing.csproj
  32. +149 −0 src/FubuMVC.SelfHost.Testing/Harness.cs
  33. +72 −0 src/FubuMVC.SelfHost.Testing/HeaderKeyValuesTester.cs
  34. +8 −0 src/FubuMVC.SelfHost.Testing/Properties/AssemblyInfo.cs
  35. +57 −0 src/FubuMVC.SelfHost.Testing/SelfHostCurrentHttpRequestIntegratedTester.cs
  36. +1 −0  src/FubuMVC.SelfHost.Testing/Test.txt
  37. +40 −0 src/FubuMVC.SelfHost.Testing/binding_against_form_data.cs
  38. +44 −0 src/FubuMVC.SelfHost.Testing/binding_against_querystring_values.cs
  39. +30 −0 src/FubuMVC.SelfHost.Testing/handling_501_responses.cs
  40. +17 −0 src/FubuMVC.SelfHost.Testing/handling_a_404.cs
  41. +18 −0 src/FubuMVC.SelfHost.Testing/packages.config
  42. +91 −0 src/FubuMVC.SelfHost.Testing/reading_and_writing_json_and_xml_thru_conneg.cs
  43. +51 −0 src/FubuMVC.SelfHost.Testing/reading_request_headers.cs
  44. +34 −0 src/FubuMVC.SelfHost.Testing/reading_route_data.cs
  45. +45 −0 src/FubuMVC.SelfHost.Testing/writing_a_file_to_output.cs
  46. +34 −0 src/FubuMVC.SelfHost.Testing/writing_a_non_default_status_code.cs
  47. +107 −0 src/FubuMVC.SelfHost.Testing/writing_response_headers.cs
  48. +27 −0 src/FubuMVC.SelfHost.Testing/writing_string_output.cs
  49. +111 −0 src/FubuMVC.SelfHost/FubuMVC.SelfHost.csproj
  50. +41 −0 src/FubuMVC.SelfHost/PortFinder.cs
  51. +8 −0 src/FubuMVC.SelfHost/Properties/AssemblyInfo.cs
  52. +12 −0 src/FubuMVC.SelfHost/SelfHostClientConnectivity.cs
  53. +29 −0 src/FubuMVC.SelfHost/SelfHostCookies.cs
  54. +46 −0 src/FubuMVC.SelfHost/SelfHostCurrentHttpRequest.cs
  55. +20 −0 src/FubuMVC.SelfHost/SelfHostHttpContext.cs
  56. +83 −0 src/FubuMVC.SelfHost/SelfHostHttpMessageHandler.cs
  57. +33 −0 src/FubuMVC.SelfHost/SelfHostHttpRequest.cs
  58. +57 −0 src/FubuMVC.SelfHost/SelfHostHttpServer.cs
  59. +123 −0 src/FubuMVC.SelfHost/SelfHostHttpWriter.cs
  60. +114 −0 src/FubuMVC.SelfHost/SelfHostRequestData.cs
  61. +44 −0 src/FubuMVC.SelfHost/SelfHostResponse.cs
  62. +33 −0 src/FubuMVC.SelfHost/SelfHostServiceArguments.cs
  63. +22 −0 src/FubuMVC.SelfHost/SelfHostStreamingData.cs
  64. +13 −0 src/FubuMVC.SelfHost/packages.config
  65. +5 −5 src/FubuMVC.Spark.Tests/FubuMVC.Spark.Tests.csproj
  66. +5 −5 src/FubuMVC.Spark.Tests/packages.config
  67. +3 −3 src/FubuMVC.Spark/FubuMVC.Spark.csproj
  68. +3 −3 src/FubuMVC.Spark/packages.config
  69. +3 −3 src/FubuMVC.StructureMap/FubuMVC.StructureMap.csproj
  70. +3 −3 src/FubuMVC.StructureMap/packages.config
  71. +4 −4 src/FubuMVC.TestingHarness/FubuMVC.TestingHarness.csproj
  72. +4 −4 src/FubuMVC.TestingHarness/packages.config
  73. +6 −6 src/FubuMVC.Tests/FubuMVC.Tests.csproj
  74. +6 −6 src/FubuMVC.Tests/packages.config
  75. +34 −0 src/FubuMVC.sln
  76. +4 −4 src/QuickStart/QuickStart.csproj
  77. +4 −4 src/QuickStart/packages.config
  78. +3 −3 src/TestPackage1/TestPackage1.csproj
  79. +3 −3 src/TestPackage1/packages.config
  80. +1 −1  src/TestPackage2/TestPackage2.csproj
  81. +1 −1  src/TestPackage2/packages.config
  82. +4 −4 src/fubu.Testing/fubu.Testing.csproj
  83. +4 −4 src/fubu.Testing/packages.config
View
1  .gitignore
@@ -56,3 +56,4 @@ deploymentplan.html
deployment
!docs/source/topics/deployment
*ncrunch*
+fubu.cmd
View
2  bottles.cmd
@@ -1 +1 @@
-src\packages\Bottles.0.9.1.357\tools\BottleRunner.exe %*
+src\packages\Bottles.0.9.1.360\tools\BottleRunner.exe %*
View
9 rakefile.rb
@@ -83,7 +83,7 @@ def waitfor(&block)
end
desc "Compiles the app"
-task :compile => [:restore_if_missing, :clean, :version, :bottle_diagnostics] do
+task :compile => [:restore_if_missing, :clean, :version] do
MSBuildRunner.compile :compilemode => COMPILE_TARGET, :solutionfile => 'src/FubuMVC.sln', :clrversion => CLR_TOOLS_VERSION
copyOutputFiles "src/fubu/bin/#{COMPILE_TARGET}", "fubu.exe", props[:stage]
@@ -105,7 +105,7 @@ def copyOutputFiles(fromDir, filePattern, outDir)
desc "Runs unit tests"
task :unit_test => :compile do
runner = NUnitRunner.new :compilemode => COMPILE_TARGET, :source => 'src', :platform => 'x86'
- runner.executeTests ['FubuMVC.Tests', 'FubuMVC.Spark.Tests', 'FubuMVC.Razor.Tests', 'FubuMVC.OwinHost.Testing', 'fubu.Testing']
+ runner.executeTests ['FubuMVC.Tests', 'FubuMVC.Spark.Tests', 'FubuMVC.Razor.Tests', 'FubuMVC.OwinHost.Testing', 'fubu.Testing', 'FubuMVC.SelfHost.Testing']
end
desc "Runs the integration tests"
@@ -132,10 +132,7 @@ def copyOutputFiles(fromDir, filePattern, outDir)
fubu("assembly-pak src/FubuMVC.GettingStarted --proj-file FubuMVC.GettingStarted.csproj")
end
-desc "Packages the FubuMVC.Diagnostics bottle files"
-task :bottle_diagnostics do
- bottles("assembly-pak src/FubuMVC.Diagnostics --proj-file FubuMVC.Diagnostics.csproj")
-end
+
def self.bottles(args)
bottles = Platform.runtime(Nuget.tool("Bottles", "BottleRunner.exe"))
View
6 src/AspNetApplication/AspNetApplication.csproj
@@ -34,13 +34,13 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
- <HintPath>..\packages\Bottles.0.9.1.357\lib\Bottles.dll</HintPath>
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
- <HintPath>..\packages\HtmlTags.1.1.0.110\lib\4.0\HtmlTags.dll</HintPath>
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="StructureMap, Version=2.6.3.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223, processorArchitecture=MSIL">
View
6 src/AspNetApplication/packages.config
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Bottles" version="0.9.1.357" />
- <package id="FubuCore" version="0.9.9.179" />
- <package id="HtmlTags" version="1.1.0.110" />
+ <package id="Bottles" version="0.9.1.360" />
+ <package id="FubuCore" version="0.9.9.180" />
+ <package id="HtmlTags" version="1.1.0.111" />
<package id="structuremap" version="2.6.3" />
</packages>
View
6 src/AssemblyPackage/AssemblyPackage.csproj
@@ -32,13 +32,13 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
- <HintPath>..\packages\Bottles.0.9.1.357\lib\Bottles.dll</HintPath>
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
- <HintPath>..\packages\HtmlTags.1.1.0.110\lib\4.0\HtmlTags.dll</HintPath>
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
View
6 src/AssemblyPackage/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Bottles" version="0.9.1.357" />
- <package id="FubuCore" version="0.9.9.179" />
- <package id="HtmlTags" version="1.1.0.110" />
+ <package id="Bottles" version="0.9.1.360" />
+ <package id="FubuCore" version="0.9.9.180" />
+ <package id="HtmlTags" version="1.1.0.111" />
</packages>
View
8 src/Fubu/Fubu.csproj
@@ -36,10 +36,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
- <HintPath>..\packages\Bottles.0.9.1.357\lib\Bottles.dll</HintPath>
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="Gate, Version=0.1.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Gate.0.1.4\lib\Gate.dll</HintPath>
@@ -48,7 +48,7 @@
<HintPath>..\packages\Gate.Kayak.0.1.4\lib\Gate.Kayak.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
- <HintPath>..\packages\HtmlTags.1.1.0.110\lib\4.0\HtmlTags.dll</HintPath>
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
</Reference>
<Reference Include="Ionic.Zip">
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
@@ -58,7 +58,7 @@
</Reference>
<Reference Include="Microsoft.Build.Engine" />
<Reference Include="Milkman">
- <HintPath>..\packages\Milkman.0.9.1.357\lib\Milkman.dll</HintPath>
+ <HintPath>..\packages\Milkman.0.9.1.360\lib\Milkman.dll</HintPath>
</Reference>
<Reference Include="Milkman.Deployers.Iis">
<HintPath>..\packages\Milkman.Deployers.IIS.0.9.1.51538\lib\Milkman.Deployers.Iis.dll</HintPath>
View
8 src/Fubu/packages.config
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Bottles" version="0.9.1.357" />
+ <package id="Bottles" version="0.9.1.360" />
<package id="DotNetZip" version="1.9.1.8" />
- <package id="FubuCore" version="0.9.9.179" />
+ <package id="FubuCore" version="0.9.9.180" />
<package id="Gate" version="0.1.4" />
<package id="Gate.Kayak" version="0.1.4" />
- <package id="HtmlTags" version="1.1.0.110" />
+ <package id="HtmlTags" version="1.1.0.111" />
<package id="Kayak" version="0.7.2" />
- <package id="Milkman" version="0.9.1.357" />
+ <package id="Milkman" version="0.9.1.360" />
<package id="Milkman.Deployers.IIS" version="0.9.1.51538" />
<package id="structuremap" version="2.6.3" />
</packages>
View
6 src/FubuKayak/FubuKayak.csproj
@@ -39,10 +39,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
- <HintPath>..\packages\Bottles.0.9.1.357\lib\Bottles.dll</HintPath>
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="Gate">
<HintPath>..\packages\Gate.0.1.4\lib\Gate.dll</HintPath>
@@ -51,7 +51,7 @@
<HintPath>..\packages\Gate.Kayak.0.1.4\lib\Gate.Kayak.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
- <HintPath>..\packages\HtmlTags.1.1.0.110\lib\4.0\HtmlTags.dll</HintPath>
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
</Reference>
<Reference Include="Kayak">
<HintPath>..\packages\Kayak.0.7.2\lib\Kayak.dll</HintPath>
View
6 src/FubuKayak/packages.config
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Bottles" version="0.9.1.357" />
- <package id="FubuCore" version="0.9.9.179" />
+ <package id="Bottles" version="0.9.1.360" />
+ <package id="FubuCore" version="0.9.9.180" />
<package id="Gate" version="0.1.4" />
<package id="Gate.Kayak" version="0.1.4" />
- <package id="HtmlTags" version="1.1.0.110" />
+ <package id="HtmlTags" version="1.1.0.111" />
<package id="Kayak" version="0.7.2" />
</packages>
View
8 src/FubuMVC.AspNetTesting/FubuMVC.AspNetTesting.csproj
@@ -32,16 +32,16 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
- <HintPath>..\packages\Bottles.0.9.1.357\lib\Bottles.dll</HintPath>
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="FubuTestingSupport">
- <HintPath>..\packages\FubuTestingSupport.0.9.9.179\lib\FubuTestingSupport.dll</HintPath>
+ <HintPath>..\packages\FubuTestingSupport.0.9.9.180\lib\FubuTestingSupport.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
- <HintPath>..\packages\HtmlTags.1.1.0.110\lib\4.0\HtmlTags.dll</HintPath>
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
View
8 src/FubuMVC.AspNetTesting/packages.config
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Bottles" version="0.9.1.357" />
- <package id="FubuCore" version="0.9.9.179" />
- <package id="FubuTestingSupport" version="0.9.9.179" />
- <package id="HtmlTags" version="1.1.0.110" />
+ <package id="Bottles" version="0.9.1.360" />
+ <package id="FubuCore" version="0.9.9.180" />
+ <package id="FubuTestingSupport" version="0.9.9.180" />
+ <package id="HtmlTags" version="1.1.0.111" />
<package id="NUnit" version="2.5.10.11092" />
<package id="RhinoMocks" version="3.6.1" />
<package id="structuremap" version="2.6.3" />
View
8 src/FubuMVC.Core/FubuMVC.Core.csproj
@@ -35,16 +35,16 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
- <HintPath>..\packages\Bottles.0.9.1.357\lib\Bottles.dll</HintPath>
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="FubuLocalization">
- <HintPath>..\packages\FubuLocalization.0.9.5.77\lib\FubuLocalization.dll</HintPath>
+ <HintPath>..\packages\FubuLocalization.0.9.5.78\lib\FubuLocalization.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
- <HintPath>..\packages\HtmlTags.1.1.0.110\lib\4.0\HtmlTags.dll</HintPath>
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
</Reference>
<Reference Include="Ionic.Zip">
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
View
8 src/FubuMVC.Core/packages.config
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Bottles" version="0.9.1.357" />
+ <package id="Bottles" version="0.9.1.360" />
<package id="DotNetZip" version="1.9.1.8" />
- <package id="FubuCore" version="0.9.9.179" />
- <package id="FubuLocalization" version="0.9.5.77" />
- <package id="HtmlTags" version="1.1.0.110" />
+ <package id="FubuCore" version="0.9.9.180" />
+ <package id="FubuLocalization" version="0.9.5.78" />
+ <package id="HtmlTags" version="1.1.0.111" />
<package id="structuremap" version="2.6.3" />
</packages>
View
4 src/FubuMVC.GettingStarted/FubuMVC.GettingStarted.csproj
@@ -32,10 +32,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
- <HintPath>..\packages\HtmlTags.1.1.0.110\lib\4.0\HtmlTags.dll</HintPath>
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
View
4 src/FubuMVC.GettingStarted/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="FubuCore" version="0.9.9.179" />
- <package id="HtmlTags" version="1.1.0.110" />
+ <package id="FubuCore" version="0.9.9.180" />
+ <package id="HtmlTags" version="1.1.0.111" />
</packages>
View
6 src/FubuMVC.HelloWorld/FubuMVC.HelloWorld.csproj
@@ -36,13 +36,13 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
- <HintPath>..\packages\Bottles.0.9.1.357\lib\Bottles.dll</HintPath>
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
- <HintPath>..\packages\HtmlTags.1.1.0.110\lib\4.0\HtmlTags.dll</HintPath>
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
</Reference>
<Reference Include="RazorEngine, Version=3.0.8.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
View
6 src/FubuMVC.HelloWorld/packages.config
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Bottles" version="0.9.1.357" />
- <package id="FubuCore" version="0.9.9.179" />
- <package id="HtmlTags" version="1.1.0.110" />
+ <package id="Bottles" version="0.9.1.360" />
+ <package id="FubuCore" version="0.9.9.180" />
+ <package id="HtmlTags" version="1.1.0.111" />
<package id="RazorEngine" version="3.0.8" />
<package id="structuremap" version="2.6.3" />
</packages>
View
8 src/FubuMVC.IntegrationTesting/FubuMVC.IntegrationTesting.csproj
@@ -36,19 +36,19 @@
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Bottles">
- <HintPath>..\packages\Bottles.0.9.1.357\lib\Bottles.dll</HintPath>
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="Castle.Core">
<HintPath>..\packages\Castle.Core.3.0.0.4001\lib\net40-client\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="FubuTestingSupport">
- <HintPath>..\packages\FubuTestingSupport.0.9.9.179\lib\FubuTestingSupport.dll</HintPath>
+ <HintPath>..\packages\FubuTestingSupport.0.9.9.180\lib\FubuTestingSupport.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
- <HintPath>..\packages\HtmlTags.1.1.0.110\lib\4.0\HtmlTags.dll</HintPath>
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
</Reference>
<Reference Include="Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
View
8 src/FubuMVC.IntegrationTesting/packages.config
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Bottles" version="0.9.1.357" />
+ <package id="Bottles" version="0.9.1.360" />
<package id="Castle.Core" version="3.0.0.4001" />
<package id="DotNetZip" version="1.9.1.8" />
- <package id="FubuCore" version="0.9.9.179" />
- <package id="FubuTestingSupport" version="0.9.9.179" />
- <package id="HtmlTags" version="1.1.0.110" />
+ <package id="FubuCore" version="0.9.9.180" />
+ <package id="FubuTestingSupport" version="0.9.9.180" />
+ <package id="HtmlTags" version="1.1.0.111" />
<package id="NUnit" version="2.5.10.11092" />
<package id="RhinoMocks" version="3.6.1" />
<package id="structuremap" version="2.6.3" />
View
4 src/FubuMVC.OwinHost.Testing/FubuMVC.OwinHost.Testing.csproj
@@ -32,10 +32,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="FubuTestingSupport">
- <HintPath>..\packages\FubuTestingSupport.0.9.9.179\lib\FubuTestingSupport.dll</HintPath>
+ <HintPath>..\packages\FubuTestingSupport.0.9.9.180\lib\FubuTestingSupport.dll</HintPath>
</Reference>
<Reference Include="Gate">
<HintPath>..\packages\Gate.0.1.4\lib\Gate.dll</HintPath>
View
4 src/FubuMVC.OwinHost.Testing/packages.config
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="FubuCore" version="0.9.9.179" />
- <package id="FubuTestingSupport" version="0.9.9.179" />
+ <package id="FubuCore" version="0.9.9.180" />
+ <package id="FubuTestingSupport" version="0.9.9.180" />
<package id="Gate" version="0.1.4" />
<package id="NUnit" version="2.5.10.11092" />
<package id="RhinoMocks" version="3.6.1" />
View
2  src/FubuMVC.OwinHost/FubuMVC.OwinHost.csproj
@@ -32,7 +32,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="Gate">
<HintPath>..\packages\Gate.0.1.4\lib\Gate.dll</HintPath>
View
2  src/FubuMVC.OwinHost/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="FubuCore" version="0.9.9.179" />
+ <package id="FubuCore" version="0.9.9.180" />
<package id="Gate" version="0.1.4" />
</packages>
View
10 src/FubuMVC.Razor.Tests/FubuMVC.Razor.Tests.csproj
@@ -32,19 +32,19 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
- <HintPath>..\packages\Bottles.0.9.1.357\lib\Bottles.dll</HintPath>
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="FubuLocalization">
- <HintPath>..\packages\FubuLocalization.0.9.5.77\lib\FubuLocalization.dll</HintPath>
+ <HintPath>..\packages\FubuLocalization.0.9.5.78\lib\FubuLocalization.dll</HintPath>
</Reference>
<Reference Include="FubuTestingSupport">
- <HintPath>..\packages\FubuTestingSupport.0.9.9.179\lib\FubuTestingSupport.dll</HintPath>
+ <HintPath>..\packages\FubuTestingSupport.0.9.9.180\lib\FubuTestingSupport.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
- <HintPath>..\packages\HtmlTags.1.1.0.110\lib\4.0\HtmlTags.dll</HintPath>
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
View
10 src/FubuMVC.Razor.Tests/packages.config
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Bottles" version="0.9.1.357" />
- <package id="FubuCore" version="0.9.9.179" />
- <package id="FubuLocalization" version="0.9.5.77" />
- <package id="FubuTestingSupport" version="0.9.9.179" />
- <package id="HtmlTags" version="1.1.0.110" />
+ <package id="Bottles" version="0.9.1.360" />
+ <package id="FubuCore" version="0.9.9.180" />
+ <package id="FubuLocalization" version="0.9.5.78" />
+ <package id="FubuTestingSupport" version="0.9.9.180" />
+ <package id="HtmlTags" version="1.1.0.111" />
<package id="NUnit" version="2.5.10.11092" />
<package id="RazorEngine" version="3.0.8" />
<package id="RhinoMocks" version="3.6.1" />
View
6 src/FubuMVC.Razor/FubuMVC.Razor.csproj
@@ -32,13 +32,13 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Bottles">
- <HintPath>..\packages\Bottles.0.9.1.357\lib\Bottles.dll</HintPath>
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
</Reference>
<Reference Include="FubuCore">
- <HintPath>..\packages\FubuCore.0.9.9.179\lib\FubuCore.dll</HintPath>
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
</Reference>
<Reference Include="HtmlTags">
- <HintPath>..\packages\HtmlTags.1.1.0.110\lib\4.0\HtmlTags.dll</HintPath>
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
</Reference>
<Reference Include="RazorEngine, Version=3.0.8.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
View
6 src/FubuMVC.Razor/packages.config
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Bottles" version="0.9.1.357" />
- <package id="FubuCore" version="0.9.9.179" />
- <package id="HtmlTags" version="1.1.0.110" />
+ <package id="Bottles" version="0.9.1.360" />
+ <package id="FubuCore" version="0.9.9.180" />
+ <package id="HtmlTags" version="1.1.0.111" />
<package id="RazorEngine" version="3.0.8" />
</packages>
View
14 src/FubuMVC.SelfHost.Testing/Fake.cs
@@ -0,0 +1,14 @@
+using NUnit.Framework;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class Fake
+ {
+ [Test]
+ public void something()
+ {
+ Assert.IsTrue(true);
+ }
+ }
+}
View
142 src/FubuMVC.SelfHost.Testing/FubuMVC.SelfHost.Testing.csproj
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{C4FEF224-35FF-49FD-B733-FB11CF9F6673}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>FubuMVC.SelfHost.Testing</RootNamespace>
+ <AssemblyName>FubuMVC.SelfHost.Testing</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Bottles">
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
+ </Reference>
+ <Reference Include="FubuCore">
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
+ </Reference>
+ <Reference Include="FubuLocalization">
+ <HintPath>..\packages\FubuLocalization.0.9.5.78\lib\FubuLocalization.dll</HintPath>
+ </Reference>
+ <Reference Include="FubuTestingSupport">
+ <HintPath>..\packages\FubuTestingSupport.0.9.9.180\lib\FubuTestingSupport.dll</HintPath>
+ </Reference>
+ <Reference Include="HtmlTags">
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
+ </Reference>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\packages\Newtonsoft.Json.4.5.9\lib\net40\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.mocks">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="pnunit.framework">
+ <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="Rhino.Mocks">
+ <HintPath>..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="StructureMap">
+ <HintPath>..\packages\structuremap.2.6.3\lib\StructureMap.dll</HintPath>
+ </Reference>
+ <Reference Include="StructureMap.AutoMocking">
+ <HintPath>..\packages\structuremap.automocking.2.6.3\lib\StructureMap.AutoMocking.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Net.Http">
+ <HintPath>..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.Formatting">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.20710.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.WebRequest">
+ <HintPath>..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.WebRequest.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Http">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.20710.0\lib\net40\System.Web.Http.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Http.SelfHost">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.SelfHost.4.0.20710.0\lib\net40\System.Web.Http.SelfHost.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\CommonAssemblyInfo.cs">
+ <Link>CommonAssemblyInfo.cs</Link>
+ </Compile>
+ <Compile Include="binding_against_form_data.cs" />
+ <Compile Include="binding_against_querystring_values.cs" />
+ <Compile Include="Fake.cs" />
+ <Compile Include="handling_501_responses.cs" />
+ <Compile Include="handling_a_404.cs" />
+ <Compile Include="Harness.cs" />
+ <Compile Include="HeaderKeyValuesTester.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="reading_and_writing_json_and_xml_thru_conneg.cs" />
+ <Compile Include="reading_request_headers.cs" />
+ <Compile Include="reading_route_data.cs" />
+ <Compile Include="SelfHostCurrentHttpRequestIntegratedTester.cs" />
+ <Compile Include="writing_a_file_to_output.cs" />
+ <Compile Include="writing_a_non_default_status_code.cs" />
+ <Compile Include="writing_response_headers.cs" />
+ <Compile Include="writing_string_output.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Test.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\FubuMVC.Core\FubuMVC.Core.csproj">
+ <Project>{E18FD922-0E7A-49CD-B89F-473826077B9D}</Project>
+ <Name>FubuMVC.Core</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\FubuMVC.SelfHost\FubuMVC.SelfHost.csproj">
+ <Project>{E8DC2BF6-4F59-43BF-86B9-82C52803B5C0}</Project>
+ <Name>FubuMVC.SelfHost</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\FubuMVC.StructureMap\FubuMVC.StructureMap.csproj">
+ <Project>{ABFEA520-820C-4B77-9015-6A09E24252FA}</Project>
+ <Name>FubuMVC.StructureMap</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
149 src/FubuMVC.SelfHost.Testing/Harness.cs
@@ -0,0 +1,149 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Xml;
+using FubuCore;
+using FubuMVC.Core;
+using FubuMVC.Core.Endpoints;
+using FubuMVC.Core.Runtime;
+using FubuMVC.Core.Urls;
+using FubuMVC.StructureMap;
+using FubuTestingSupport;
+using NUnit.Framework;
+using StructureMap;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [SetUpFixture]
+ public class HarnessBootstrapper
+ {
+ [SetUp]
+ public void SetUp()
+ {
+ Harness.Start();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Harness.Shutdown();
+ }
+ }
+
+ public static class Harness
+ {
+ private static SelfHostHttpServer _server;
+ private static EndpointDriver _endpoints;
+
+ public static void Start()
+ {
+ _server = new SelfHostHttpServer(5500);
+ var runtime = FubuApplication.For<HarnessRegistry>().StructureMap(new Container()).Bootstrap();
+
+
+ _server.Start(runtime, GetRootDirectory());
+
+ var urls = runtime.Facility.Get<IUrlRegistry>();
+ urls.As<UrlRegistry>().RootAt(_server.BaseAddress);
+
+ UrlContext.Stub(_server.BaseAddress);
+
+ _endpoints = new EndpointDriver(urls);
+ }
+
+ public static string GetRootDirectory()
+ {
+ return AppDomain.CurrentDomain.BaseDirectory.ParentDirectory().ParentDirectory();
+ }
+
+ public static string Root
+ {
+ get
+ {
+ return _server.BaseAddress;
+ }
+ }
+
+ public static EndpointDriver Endpoints
+ {
+ get
+ {
+ return _endpoints;
+ }
+ }
+
+ public static void Shutdown()
+ {
+ _server.SafeDispose();
+ }
+ }
+
+ public class HarnessRegistry : FubuRegistry
+ {
+
+ }
+
+ public static class HttpResponseExtensions
+ {
+ public static HttpResponse ShouldHaveHeader(this HttpResponse response, HttpResponseHeader header)
+ {
+ response.ResponseHeaderFor(header).ShouldNotBeEmpty();
+ return response;
+ }
+
+ public static HttpResponse ContentShouldBe(this HttpResponse response, MimeType mimeType, string content)
+ {
+ response.ContentType.ShouldEqual(mimeType.Value);
+ response.ReadAsText().ShouldEqual(content);
+
+ return response;
+ }
+
+ public static HttpResponse ContentTypeShouldBe(this HttpResponse response, MimeType mimeType)
+ {
+ response.ContentType.ShouldEqual(mimeType.Value);
+
+ return response;
+ }
+
+ public static HttpResponse LengthShouldBe(this HttpResponse response, int length)
+ {
+ response.ContentLength().ShouldEqual(length);
+
+ return response;
+ }
+
+ public static HttpResponse ContentShouldBe(this HttpResponse response, string mimeType, string content)
+ {
+ response.ContentType.ShouldEqual(mimeType);
+ response.ReadAsText().ShouldEqual(content);
+
+ return response;
+ }
+
+
+ public static HttpResponse StatusCodeShouldBe(this HttpResponse response, HttpStatusCode code)
+ {
+ response.StatusCode.ShouldEqual(code);
+
+ return response;
+ }
+
+ public static string FileEscape(this string file)
+ {
+ return "\"{0}\"".ToFormat(file);
+ }
+
+ public static IEnumerable<string> ScriptNames(this HttpResponse response)
+ {
+ var document = response.ReadAsXml();
+ var tags = document.DocumentElement.SelectNodes("//script");
+
+ foreach (XmlElement tag in tags)
+ {
+ var name = tag.GetAttribute("src");
+ yield return name.Substring(name.IndexOf('_'));
+ }
+ }
+ }
+}
View
72 src/FubuMVC.SelfHost.Testing/HeaderKeyValuesTester.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using NUnit.Framework;
+using FubuTestingSupport;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class HeaderKeyValuesTester
+ {
+ private HttpRequestHeaders theHeaders;
+ private HeaderKeyValues theKeyValues;
+
+ [SetUp]
+ public void SetUp()
+ {
+ var request = new HttpRequestMessage();
+ theHeaders = request.Headers;
+
+ theKeyValues = new HeaderKeyValues(theHeaders);
+ }
+
+ [Test]
+ public void has_negative()
+ {
+ theKeyValues.Has(Core.Http.HttpRequestHeaders.Warning).ShouldBeFalse();
+ }
+
+ [Test]
+ public void has_positive()
+ {
+ theHeaders.Add("x-extension", "737060cd8c284d8af7ad3082f209582d");
+ theKeyValues.Has("x-extension").ShouldBeTrue();
+ }
+
+ [Test]
+ public void get()
+ {
+ theHeaders.Add("x-extension", "737060cd8c284d8af7ad3082f209582d");
+ theKeyValues.Get("x-extension").ShouldEqual("737060cd8c284d8af7ad3082f209582d");
+ }
+
+ [Test]
+ public void get_all_keys()
+ {
+ theHeaders.Add("x-1", "a");
+ theHeaders.Add("x-2", "a");
+ theHeaders.Add("x-3", "a");
+
+ theKeyValues.GetKeys().ShouldHaveTheSameElementsAs("x-1", "x-2", "x-3");
+ }
+
+ [Test]
+ public void ForValue_miss()
+ {
+ theKeyValues.ForValue("x-1", (x, y) => Assert.Fail("should not be here")).ShouldBeFalse();
+ }
+
+ [Test]
+ public void ForValue_positive()
+ {
+ theHeaders.Add("x-1", "a");
+
+ theKeyValues.ForValue("x-1", (key, value) =>
+ {
+ value.ShouldEqual("a");
+ key.ShouldEqual("x-1");
+ }).ShouldBeTrue();
+ }
+ }
+}
View
8 src/FubuMVC.SelfHost.Testing/Properties/AssemblyInfo.cs
@@ -0,0 +1,8 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("FubuMVC.SelfHost.Testing")]
View
57 src/FubuMVC.SelfHost.Testing/SelfHostCurrentHttpRequestIntegratedTester.cs
@@ -0,0 +1,57 @@
+using FubuMVC.Core.Http;
+using NUnit.Framework;
+using FubuTestingSupport;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class SelfHostCurrentHttpRequestIntegratedTester
+ {
+ [Test]
+ public void read_raw_url()
+ {
+ var request = Harness.Endpoints.Get<HttpCurrentRequestEndpoints>(x => x.get_request_data())
+ .ReadAsJson<HttpRequestData>();
+
+ var root = Harness.Root;
+
+ request.RawUrl.ShouldEqual(root + "/request/data");
+ request.RelativeUrl.ShouldEqual("request/data");
+ request.HttpMethod.ShouldEqual("GET");
+ request.FullUrl.ShouldEqual(root + "/request/data");
+ }
+ }
+
+ public class HttpRequestData
+ {
+ public string RawUrl { get; set; }
+ public string RelativeUrl { get; set; }
+ public string FullUrl { get; set; }
+ public string HttpMethod { get; set; }
+ }
+
+ public class HttpCurrentRequestEndpoints
+ {
+ private readonly ICurrentHttpRequest _request;
+
+ public HttpCurrentRequestEndpoints(ICurrentHttpRequest request)
+ {
+ _request = request;
+ }
+
+ public HttpRequestData post_request_data()
+ {
+ return get_request_data();
+ }
+
+ public HttpRequestData get_request_data()
+ {
+ return new HttpRequestData{
+ FullUrl = _request.FullUrl(),
+ HttpMethod = _request.HttpMethod(),
+ RawUrl = _request.RawUrl(),
+ RelativeUrl = _request.RelativeUrl()
+ };
+ }
+ }
+}
View
1  src/FubuMVC.SelfHost.Testing/Test.txt
@@ -0,0 +1 @@
+Some text here
View
40 src/FubuMVC.SelfHost.Testing/binding_against_form_data.cs
@@ -0,0 +1,40 @@
+using NUnit.Framework;
+using FubuTestingSupport;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class binding_against_form_data
+ {
+ [Test]
+ public void can_bind_to_form_post_data()
+ {
+ var model = new FormInput{
+ Color = "Orange",
+ Direction = "South"
+ };
+
+ Harness.Endpoints.PostAsForm(model).ReadAsText()
+ .ShouldEqual(model.ToString());
+ }
+ }
+
+ public class FormBindingEndpoint
+ {
+ public string post_form_values(FormInput input)
+ {
+ return input.ToString();
+ }
+ }
+
+ public class FormInput
+ {
+ public string Color { get; set; }
+ public string Direction { get; set; }
+
+ public override string ToString()
+ {
+ return string.Format("Color: {0}, Direction: {1}", Color, Direction);
+ }
+ }
+}
View
44 src/FubuMVC.SelfHost.Testing/binding_against_querystring_values.cs
@@ -0,0 +1,44 @@
+using FubuMVC.Core;
+using NUnit.Framework;
+using FubuTestingSupport;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class binding_against_querystring_values
+ {
+ [Test]
+ public void can_bind_against_querystring_parameters()
+ {
+ var model = new QueryStringModel{
+ Color = "Green",
+ Direction = "South"
+ };
+
+ Harness.Endpoints.GetByInput(model).ReadAsText()
+ .ShouldEqual(model.ToString());
+ }
+ }
+
+ public class QueryStringEndpoint
+ {
+ public string get_querystring_data(QueryStringModel model)
+ {
+ return model.ToString();
+ }
+ }
+
+ public class QueryStringModel
+ {
+ [QueryString]
+ public string Color { get; set; }
+
+ [QueryString]
+ public string Direction { get; set; }
+
+ public override string ToString()
+ {
+ return string.Format("Color: {0}, Direction: {1}", Color, Direction);
+ }
+ }
+}
View
30 src/FubuMVC.SelfHost.Testing/handling_501_responses.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Net;
+using NUnit.Framework;
+using FubuTestingSupport;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class handling_501_responses
+ {
+ [Test]
+ public void handle_the_exception_with_a_501_and_the_exception_message()
+ {
+ var response = Harness.Endpoints.Get<ExceptionEndpoint>(x => x.get_exception());
+
+ response.StatusCode.ShouldEqual(HttpStatusCode.InternalServerError);
+ var text = response.ReadAsText();
+
+ text.ShouldContain("I did not like this");
+ }
+ }
+
+ public class ExceptionEndpoint
+ {
+ public string get_exception()
+ {
+ throw new ApplicationException("I did not like this");
+ }
+ }
+}
View
17 src/FubuMVC.SelfHost.Testing/handling_a_404.cs
@@ -0,0 +1,17 @@
+using System.Net;
+using NUnit.Framework;
+using FubuTestingSupport;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class handling_a_404
+ {
+ [Test]
+ public void get_response_for_non_existent_route()
+ {
+ var response = Harness.Endpoints.Get(Harness.Root + "/nonexistent");
+ response.StatusCode.ShouldEqual(HttpStatusCode.NotFound);
+ }
+ }
+}
View
18 src/FubuMVC.SelfHost.Testing/packages.config
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Bottles" version="0.9.1.360" />
+ <package id="FubuCore" version="0.9.9.180" />
+ <package id="FubuLocalization" version="0.9.5.78" />
+ <package id="FubuMVC.References" version="0.9.8.1168" />
+ <package id="FubuTestingSupport" version="0.9.9.180" />
+ <package id="HtmlTags" version="1.1.0.111" />
+ <package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" />
+ <package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" />
+ <package id="Microsoft.AspNet.WebApi.SelfHost" version="4.0.20710.0" />
+ <package id="Microsoft.Net.Http" version="2.0.20710.0" />
+ <package id="Newtonsoft.Json" version="4.5.9" />
+ <package id="NUnit" version="2.5.10.11092" />
+ <package id="RhinoMocks" version="3.6.1" />
+ <package id="structuremap" version="2.6.3" />
+ <package id="structuremap.automocking" version="2.6.3" />
+</packages>
View
91 src/FubuMVC.SelfHost.Testing/reading_and_writing_json_and_xml_thru_conneg.cs
@@ -0,0 +1,91 @@
+using System.Diagnostics;
+using System.IO;
+using System.Net;
+using System.Xml;
+using System.Xml.Serialization;
+using FubuMVC.Core.Runtime;
+using NUnit.Framework;
+using FubuTestingSupport;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class reading_and_writing_json_and_xml_thru_conneg
+ {
+ [Test]
+ public void read_and_write_json()
+ {
+ var message = new Message{
+ Color = "Blue",
+ Direction = "East"
+ };
+
+ var response = Harness.Endpoints.PostJson(message, contentType:"text/json", accept:"text/json");
+
+ response.StatusCodeShouldBe(HttpStatusCode.OK);
+ response.ContentType.ShouldEqual("text/json");
+
+ response.ReadAsJson<Message>().ShouldEqual(message);
+ }
+
+ [Test]
+ public void read_and_write_xml()
+ {
+ var message = new Message
+ {
+ Color = "Blue",
+ Direction = "East"
+ };
+
+ var response = Harness.Endpoints.PostXml(message, contentType: "text/xml", accept: "text/xml");
+
+ response.StatusCodeShouldBe(HttpStatusCode.OK);
+ response.ContentType.ShouldEqual("text/xml");
+
+ var serializer = new XmlSerializer(typeof (Message));
+ serializer.Deserialize(new XmlTextReader(new StringReader(response.ReadAsText()))).ShouldEqual(message);
+ }
+ }
+
+ public class ConnegEndpoint
+ {
+ public Message post_message(Message message)
+ {
+ return message;
+ }
+ }
+
+ public class Message
+ {
+ public string Color { get; set; }
+ public string Direction { get; set; }
+
+ public override string ToString()
+ {
+ return string.Format("Color: {0}, Direction: {1}", Color, Direction);
+ }
+
+ public bool Equals(Message other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return Equals(other.Color, Color) && Equals(other.Direction, Direction);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Message)) return false;
+ return Equals((Message) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return ((Color != null ? Color.GetHashCode() : 0)*397) ^ (Direction != null ? Direction.GetHashCode() : 0);
+ }
+ }
+ }
+}
View
51 src/FubuMVC.SelfHost.Testing/reading_request_headers.cs
@@ -0,0 +1,51 @@
+using FubuCore.Binding;
+using FubuMVC.Core.Http;
+using NUnit.Framework;
+using FubuTestingSupport;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class reading_request_headers
+ {
+ [Test]
+ public void read_custom_header()
+ {
+ Harness.Endpoints.GetByInput(new HeaderRequest{
+ Name = "x-1"
+ }, configure: req => req.Headers["x-1"] = "A").ReadAsText().ShouldEqual("A");
+ }
+
+ [Test]
+ public void read_build_in_header()
+ {
+ Harness.Endpoints.GetByInput(new HeaderRequest
+ {
+ Name = HttpRequestHeaders.IfNoneMatch
+ }, configure: req => req.Headers[HttpRequestHeaders.IfNoneMatch] = "A").ReadAsText().ShouldEqual("A");
+ }
+ }
+
+ public class RequestHeadersEndpoint
+ {
+ private readonly IRequestHeaders _headers;
+
+ public RequestHeadersEndpoint(IRequestHeaders headers)
+ {
+ _headers = headers;
+ }
+
+ public string get_header_Name(HeaderRequest request)
+ {
+ string text = null;
+ _headers.Value<string>(request.Name, x => text = x);
+
+ return text;
+ }
+ }
+
+ public class HeaderRequest
+ {
+ public string Name { get; set; }
+ }
+}
View
34 src/FubuMVC.SelfHost.Testing/reading_route_data.cs
@@ -0,0 +1,34 @@
+using NUnit.Framework;
+using FubuCore;
+using FubuTestingSupport;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class reading_route_data
+ {
+ [Test]
+ public void bind_data_against_routing_data()
+ {
+ Harness.Endpoints.GetByInput(new RouteInput{
+ Name = "Jeremy",
+ Age = 38
+ }).ReadAsText()
+ .ShouldEqual("Name=Jeremy, Age=38");
+ }
+ }
+
+ public class ReadingRouteEndpoint
+ {
+ public string get_routing_data_Name_Age(RouteInput input)
+ {
+ return "Name={0}, Age={1}".ToFormat(input.Name, input.Age);
+ }
+ }
+
+ public class RouteInput
+ {
+ public string Name { get; set; }
+ public int Age { get; set; }
+ }
+}
View
45 src/FubuMVC.SelfHost.Testing/writing_a_file_to_output.cs
@@ -0,0 +1,45 @@
+using FubuMVC.Core.Runtime;
+using FubuMVC.Core.Runtime.Files;
+using NUnit.Framework;
+using FubuTestingSupport;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class writing_a_file_to_output
+ {
+ [Test]
+ public void can_write_the_contents_of_a_file_to_the_output()
+ {
+ var response = Harness.Endpoints.GetByInput(new FileInput{
+ Name = "Test.txt"
+ });
+
+ response.ContentTypeShouldBe(MimeType.Text);
+ response.ReadAsText().ShouldContain("Some text here");
+ }
+ }
+
+ public class FileWriterEndpoint
+ {
+ private readonly IOutputWriter _writer;
+ private readonly IFubuApplicationFiles _files;
+
+ public FileWriterEndpoint(IOutputWriter writer, IFubuApplicationFiles files)
+ {
+ _writer = writer;
+ _files = files;
+ }
+
+ public void get_file_contents_Name(FileInput input)
+ {
+ var file = _files.Find(input.Name);
+ _writer.WriteFile(MimeType.Text, file.Path, input.Name);
+ }
+ }
+
+ public class FileInput
+ {
+ public string Name { get; set;}
+ }
+}
View
34 src/FubuMVC.SelfHost.Testing/writing_a_non_default_status_code.cs
@@ -0,0 +1,34 @@
+using System.Net;
+using FubuMVC.Core.Runtime;
+using NUnit.Framework;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class writing_a_non_default_status_code
+ {
+ [Test]
+ public void can_write_a_different_status_code()
+ {
+ Harness.Endpoints.Get<StatusCodeEndpoint>(x => x.get_not_modified())
+ .StatusCodeShouldBe(HttpStatusCode.NotModified);
+ }
+ }
+
+ public class StatusCodeEndpoint
+ {
+ private readonly IOutputWriter _writer;
+
+ public StatusCodeEndpoint(IOutputWriter writer)
+ {
+ _writer = writer;
+ }
+
+ public string get_not_modified()
+ {
+ _writer.WriteResponseCode(HttpStatusCode.NotModified, "No changes here");
+
+ return "Nothing to see here";
+ }
+ }
+}
View
107 src/FubuMVC.SelfHost.Testing/writing_response_headers.cs
@@ -0,0 +1,107 @@
+using System.Net.Http;
+using System.Net.Http.Headers;
+using FubuMVC.Core.Http;
+using FubuMVC.Core.Runtime;
+using NUnit.Framework;
+using FubuTestingSupport;
+using HttpResponseHeaders = FubuMVC.Core.Http.HttpResponseHeaders;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class writing_response_headers
+ {
+ [Test]
+ public void can_write_extension_headers()
+ {
+ var response = Harness.Endpoints.Get<ResponseHeadersEndpoint>(x => x.get_response_headers());
+
+ response.ResponseHeaderFor("x-1").ShouldEqual("a");
+ response.ResponseHeaderFor("x-2").ShouldEqual("b");
+ }
+
+ [Test]
+ public void can_write_built_in_response_headers()
+ {
+ var response = Harness.Endpoints.Get<ResponseHeadersEndpoint>(x => x.get_response_headers());
+ response.ResponseHeaderFor(HttpResponseHeaders.KeepAlive).ShouldEqual("True");
+ response.ResponseHeaderFor(HttpResponseHeaders.Server).ShouldStartWith("Server1");
+
+ }
+
+ [Test]
+ public void can_write_etag()
+ {
+ var response = Harness.Endpoints.Get<ResponseHeadersEndpoint>(x => x.get_etag());
+
+ response.ResponseHeaderFor(HttpResponseHeaders.ETag).ShouldEqual("123456");
+ }
+
+ [Test]
+ public void can_write_content_headers()
+ {
+ var response = Harness.Endpoints.Get<ResponseHeadersEndpoint>(x => x.get_content_headers());
+
+ response.ResponseHeaderFor(HttpResponseHeaders.ContentMd5).ShouldEqual("A");
+ response.ResponseHeaderFor(HttpResponseHeaders.ContentDisposition).ShouldEqual("B");
+ response.ResponseHeaderFor(HttpResponseHeaders.ContentLocation).ShouldEqual("C");
+ response.ResponseHeaderFor(HttpResponseHeaders.Allow).ShouldEqual("D");
+ response.ResponseHeaderFor(HttpResponseHeaders.ContentEncoding).ShouldEqual("UTF-16");
+ response.ResponseHeaderFor(HttpResponseHeaders.ContentLength).ShouldEqual("19");
+ response.ResponseHeaderFor(HttpResponseHeaders.ContentLanguage).ShouldEqual("jp-JP");
+ response.ResponseHeaderFor(HttpResponseHeaders.ContentRange).ShouldEqual("E");
+ response.ResponseHeaderFor(HttpResponseHeaders.Expires).ShouldEqual("5");
+ response.ResponseHeaderFor(HttpResponseHeaders.LastModified).ShouldEqual("12345");
+
+ }
+ }
+
+ public class ResponseHeadersEndpoint
+ {
+ private readonly IResponse _response;
+ private readonly IOutputWriter _writer;
+
+ public ResponseHeadersEndpoint(IResponse response, IOutputWriter writer)
+ {
+ _response = response;
+ _writer = writer;
+ }
+
+ public string get_response_headers()
+ {
+ _writer.AppendHeader("x-1", "a");
+ _writer.AppendHeader("x-2", "b");
+
+ _writer.AppendHeader(HttpResponseHeaders.KeepAlive, true.ToString());
+ _writer.AppendHeader(HttpResponseHeaders.Server, "Server1");
+
+ return "Nothing to see here";
+ }
+
+ public string get_content_headers()
+ {
+ _writer.AppendHeader(HttpResponseHeaders.ContentMd5, "A");
+ _writer.AppendHeader(HttpResponseHeaders.ContentDisposition, "B");
+ _writer.AppendHeader(HttpResponseHeaders.ContentLocation, "C");
+ _writer.AppendHeader(HttpResponseHeaders.Allow, "D");
+ _writer.AppendHeader(HttpResponseHeaders.ContentEncoding, "UTF-16");
+ _writer.AppendHeader(HttpResponseHeaders.ContentLength, "Nothing to see here".Length.ToString());
+ _writer.AppendHeader(HttpResponseHeaders.ContentLanguage, "jp-JP");
+ _writer.AppendHeader(HttpResponseHeaders.ContentRange, "E");
+ _writer.AppendHeader(HttpResponseHeaders.Expires, "5");
+ _writer.AppendHeader(HttpResponseHeaders.LastModified, "12345");
+
+
+
+
+ return "Nothing to see here";
+ }
+
+ public string get_etag()
+ {
+ _writer.AppendHeader(HttpResponseHeaders.ETag, "123456");
+
+ return "Nothing to see here";
+ }
+ }
+}
View
27 src/FubuMVC.SelfHost.Testing/writing_string_output.cs
@@ -0,0 +1,27 @@
+using System.Net;
+using FubuMVC.Core.Runtime;
+using NUnit.Framework;
+using FubuTestingSupport;
+
+namespace FubuMVC.SelfHost.Testing
+{
+ [TestFixture]
+ public class writing_string_output
+ {
+ [Test]
+ public void can_write_strings_to_the_output()
+ {
+ Harness.Endpoints.Get<StringEndpoint>(x => x.get_hello())
+ .ContentShouldBe(MimeType.Text, "Hello.")
+ .StatusCode.ShouldEqual(HttpStatusCode.OK);
+ }
+ }
+
+ public class StringEndpoint
+ {
+ public string get_hello()
+ {
+ return "Hello.";
+ }
+ }
+}
View
111 src/FubuMVC.SelfHost/FubuMVC.SelfHost.csproj
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{E8DC2BF6-4F59-43BF-86B9-82C52803B5C0}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>FubuMVC.SelfHost</RootNamespace>
+ <AssemblyName>FubuMVC.SelfHost</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Bottles">
+ <HintPath>..\packages\Bottles.0.9.1.360\lib\Bottles.dll</HintPath>
+ </Reference>
+ <Reference Include="FubuCore">
+ <HintPath>..\packages\FubuCore.0.9.9.180\lib\FubuCore.dll</HintPath>
+ </Reference>
+ <Reference Include="FubuLocalization">
+ <HintPath>..\packages\FubuLocalization.0.9.5.78\lib\FubuLocalization.dll</HintPath>
+ </Reference>
+ <Reference Include="HtmlTags">
+ <HintPath>..\packages\HtmlTags.1.1.0.111\lib\4.0\HtmlTags.dll</HintPath>
+ </Reference>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\packages\Newtonsoft.Json.4.5.9\lib\net40\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Net" />
+ <Reference Include="System.Net.Http">
+ <HintPath>..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.Formatting">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.20710.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.WebRequest">
+ <HintPath>..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.WebRequest.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web" />
+ <Reference Include="System.Web.Http">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.20710.0\lib\net40\System.Web.Http.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Http.SelfHost">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.SelfHost.4.0.20710.0\lib\net40\System.Web.Http.SelfHost.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Routing" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\CommonAssemblyInfo.cs">
+ <Link>CommonAssemblyInfo.cs</Link>
+ </Compile>
+ <Compile Include="SelfHostStreamingData.cs" />
+ <Compile Include="PortFinder.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="SelfHostClientConnectivity.cs" />
+ <Compile Include="SelfHostCookies.cs" />
+ <Compile Include="SelfHostCurrentHttpRequest.cs" />
+ <Compile Include="SelfHostHttpContext.cs" />
+ <Compile Include="SelfHostHttpMessageHandler.cs" />
+ <Compile Include="SelfHostHttpRequest.cs" />
+ <Compile Include="SelfHostHttpServer.cs" />
+ <Compile Include="SelfHostHttpWriter.cs" />
+ <Compile Include="SelfHostRequestData.cs" />
+ <Compile Include="SelfHostResponse.cs" />
+ <Compile Include="SelfHostServiceArguments.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\FubuMVC.Core\FubuMVC.Core.csproj">
+ <Project>{E18FD922-0E7A-49CD-B89F-473826077B9D}</Project>
+ <Name>FubuMVC.Core</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
41 src/FubuMVC.SelfHost/PortFinder.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Net;
+using System.Net.Sockets;
+using FubuCore;
+
+namespace FubuMVC.SelfHost
+{
+ public static class PortFinder
+ {
+ public static int FindPort(int start)
+ {
+ for (int i = start; i < start + 50; i++)
+ {
+ if (tryPort(i)) return i;
+ }
+
+ throw new InvalidOperationException("Could not find a port to bind to");
+ }
+
+ private static bool tryPort(int port)
+ {
+ var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
+ var endpoint = new IPEndPoint(IPAddress.Any, port);
+
+ try
+ {
+ socket.Bind(endpoint);
+ return true;
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ finally
+ {
+ socket.SafeDispose();
+ }
+
+ }
+ }
+}
View
8 src/FubuMVC.SelfHost/Properties/AssemblyInfo.cs
@@ -0,0 +1,8 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("FubuMVC.SelfHost")]
View
12 src/FubuMVC.SelfHost/SelfHostClientConnectivity.cs
@@ -0,0 +1,12 @@
+using FubuMVC.Core.Http;
+
+namespace FubuMVC.SelfHost
+{
+ public class SelfHostClientConnectivity : IClientConnectivity
+ {
+ public bool IsClientConnected()
+ {
+ return false; // we simply don't know
+ }
+ }
+}
View
29 src/FubuMVC.SelfHost/SelfHostCookies.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Net.Http;
+using System.Web;
+using FubuMVC.Core.Http;
+
+namespace FubuMVC.SelfHost
+{
+ public class SelfHostCookies : ICookies
+ {
+ private readonly HttpRequestMessage _request;
+ private readonly HttpResponseMessage _response;
+
+ public SelfHostCookies(HttpRequestMessage request, HttpResponseMessage response)
+ {
+ _request = request;
+ _response = response;
+ }
+
+ public HttpCookieCollection Request
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public HttpCookieCollection Response
+ {
+ get { throw new NotImplementedException(); }
+ }
+ }
+}
View
46 src/FubuMVC.SelfHost/SelfHostCurrentHttpRequest.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Net.Http;
+using System.Web.Http.SelfHost;
+using FubuMVC.Core;
+using FubuMVC.Core.Http;
+using FubuCore;
+
+namespace FubuMVC.SelfHost
+{
+ public class SelfHostCurrentHttpRequest : ICurrentHttpRequest
+ {
+ private readonly HttpRequestMessage _request;
+ private readonly HttpSelfHostConfiguration _configuration;
+
+ public SelfHostCurrentHttpRequest(HttpRequestMessage request, HttpSelfHostConfiguration configuration)
+ {
+ _request = request;
+ _configuration = configuration;
+ }
+
+ public string RawUrl()
+ {
+ return _request.RequestUri.OriginalString;
+ }
+
+ public string RelativeUrl()
+ {
+ return _request.RequestUri.AbsolutePath.TrimStart('/');
+ }
+
+ public string FullUrl()
+ {
+ return ToFullUrl(RelativeUrl());
+ }
+
+ public string ToFullUrl(string url)
+ {
+ return url.ToAbsoluteUrl(_configuration.BaseAddress.OriginalString);
+ }
+
+ public string HttpMethod()
+ {
+ return _request.Method.Method;
+ }
+ }
+}
View
20 src/FubuMVC.SelfHost/SelfHostHttpContext.cs
@@ -0,0 +1,20 @@
+using System.Net.Http;
+using System.Web;
+
+namespace FubuMVC.SelfHost
+{
+ public class SelfHostHttpContext : HttpContextBase
+ {
+ private readonly SelfHostHttpRequest _request;
+
+ public SelfHostHttpContext(HttpRequestMessage request)
+ {
+ _request = new SelfHostHttpRequest(request);
+ }
+
+ public override HttpRequestBase Request
+ {
+ get { return _request; }
+ }
+ }
+}
View
83 src/FubuMVC.SelfHost/SelfHostHttpMessageHandler.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Net;
+using System.Net.Http;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Web.Http.SelfHost;
+using System.Web.Routing;
+using FubuCore;
+using FubuMVC.Core;
+using FubuMVC.Core.Runtime.Handlers;
+
+namespace FubuMVC.SelfHost
+{
+ public class SelfHostHttpMessageHandler : HttpMessageHandler
+ {
+ private readonly FubuRuntime _runtime;
+ private readonly HttpSelfHostConfiguration _configuration;
+
+ public SelfHostHttpMessageHandler(FubuRuntime runtime, HttpSelfHostConfiguration configuration)
+ {
+ _runtime = runtime;
+ _configuration = configuration;
+ }
+
+ private static RouteData determineRouteData(HttpRequestMessage request)
+ {
+ var context = new SelfHostHttpContext(request);
+ return RouteTable.Routes.GetRouteData(context);
+ }
+
+ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
+ {
+ return Task.Factory.StartNew(() => ExecuteRequest(request), cancellationToken);
+ }
+
+ public bool Verbose { get; set; }
+
+ public HttpResponseMessage ExecuteRequest(HttpRequestMessage request)
+ {
+ if (Verbose) Console.WriteLine("Received {0} - {1}", request.Method, request.RequestUri);
+
+ var routeData = determineRouteData(request);
+
+ if (routeData == null)
+ {
+ return write404();
+ }
+ else
+ {
+ try
+ {
+ var response = new HttpResponseMessage(HttpStatusCode.OK);
+ var arguments = new SelfHostServiceArguments(routeData, request, response, _configuration);
+ var invoker = routeData.RouteHandler.As<FubuRouteHandler>().Invoker;
+ invoker.Invoke(arguments, routeData.Values);
+
+ arguments.Writer.AttachContent();
+
+ return response;
+ }
+ catch (Exception ex)
+ {
+ return write500(ex);
+ }
+ }
+ }
+
+ private static HttpResponseMessage write500(Exception ex)
+ {
+ return new HttpResponseMessage(HttpStatusCode.InternalServerError){
+ Content = new StringContent("FubuMVC has detected an exception\r\n" + ex.ToString())
+ };
+ }
+
+ private static HttpResponseMessage write404()
+ {
+ return new HttpResponseMessage{
+ StatusCode = HttpStatusCode.NotFound,
+ Content = new StringContent("Sorry, I can't find this resource")