Skip to content

Commit

Permalink
Test projects to reproduce
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodejunkie committed Aug 14, 2012
1 parent d122c07 commit 556230a
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 28 deletions.
29 changes: 29 additions & 0 deletions src/Nancy.Testing.Experiments.Model/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Models
{
public class DefaultModelFactory : IModelFactory
{
public DefaultModelFactory()
{
}

public Model GetModel(string message)
{
return new Model(message);
}
}

public interface IModelFactory
{
Model GetModel(string message);
}

public class Model
{
public Model(string message)
{
this.Message = message;
}

public string Message { get; private set; }
}
}
54 changes: 54 additions & 0 deletions src/Nancy.Testing.Experiments.Model/Models.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?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>{A72EABE4-EA73-4EB0-A79F-92711D6875A9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Models</RootNamespace>
<AssemblyName>Models</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="System" />
<Reference Include="System.Core" />
<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="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</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>
68 changes: 44 additions & 24 deletions src/Nancy.Testing.Experiments.Tests/HomeFixture.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
namespace Nancy.Testing.Experiments.Tests
{
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using Bootstrapper;
using Xunit;

public class HomeFixture
{
[Fact]
public void Should_be_able_to_test_route_that_renders_view()
{
AppDomainAssemblyTypeScanner.LoadAssemblies("Models.dll");

var x =
typeof(HomeFixture).Assembly.GetReferencedAssemblies();

//AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
//{
// Debug.WriteLine(args.Name);
// Debug.WriteLine(args.RequestingAssembly.FullName);
// return null;
//};

//AppDomain.CurrentDomain.CreateInstance("Models", "DefaultModelFactory");

// Given
var rootPathProvider =
new ConfigurableRootPathProvider(typeof(Home));
//var rootPathProvider =
// new ConfigurableRootPathProvider(typeof(Home));

//var browser = new Browser(new ConfigurableBootstrapper(with => {
// with.RootPathProvider(rootPathProvider);
//}));

var browser = new Browser(new ConfigurableBootstrapper(with => {
with.RootPathProvider(rootPathProvider);
with.EnableAutoRegistration();
}));

// When
Expand All @@ -26,30 +46,30 @@ public void Should_be_able_to_test_route_that_renders_view()
}
}

public class ConfigurableRootPathProvider : IRootPathProvider
{
private readonly string rootPath;
//public class ConfigurableRootPathProvider : IRootPathProvider
//{
// private readonly string rootPath;

public ConfigurableRootPathProvider(Type type)
: this(type.Assembly)
{
}
// public ConfigurableRootPathProvider(Type type)
// : this(type.Assembly)
// {
// }

public ConfigurableRootPathProvider(Assembly assembly)
{
var assemblyFilePath =
new Uri(assembly.CodeBase).LocalPath;
// public ConfigurableRootPathProvider(Assembly assembly)
// {
// var assemblyFilePath =
// new Uri(assembly.CodeBase).LocalPath;

var assemblyPath =
Path.GetDirectoryName(assemblyFilePath);
// var assemblyPath =
// Path.GetDirectoryName(assemblyFilePath);

this.rootPath =
PathHelper.GetParent(assemblyPath, 2);
}
// this.rootPath =
// PathHelper.GetParent(assemblyPath, 2);
// }

public string GetRootPath()
{
return this.rootPath;
}
}
// public string GetRootPath()
// {
// return this.rootPath;
// }
//}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Nancy.Testing.Experiments.Model\Models.csproj">
<Project>{A72EABE4-EA73-4EB0-A79F-92711D6875A9}</Project>
<Name>Models</Name>
</ProjectReference>
<ProjectReference Include="..\Nancy.Testing.Experiments\Nancy.Testing.Experiments.csproj">
<Project>{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}</Project>
<Name>Nancy.Testing.Experiments</Name>
Expand Down
7 changes: 6 additions & 1 deletion src/Nancy.Testing.Experiments/Home.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
namespace Nancy.Testing.Experiments
{
using Models;
using Nancy;

public class Home : NancyModule
{
public Home()
public Home(IModelFactory modelFactory)
{
Get["/"] = parameters => {

var model =
modelFactory.GetModel("This is a message from the model");

return View["index"];
};
}
Expand Down
12 changes: 9 additions & 3 deletions src/Nancy.Testing.Experiments/Nancy.Testing.Experiments.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,19 @@
<Content Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="views\index.cshtml" />
<Content Include="views\index.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Nancy.Hosting.Aspnet\Nancy.Hosting.Aspnet.csproj">
<Project>{15B7F794-0BB2-4B66-AD78-4A951F1209B2}</Project>
<Name>Nancy.Hosting.Aspnet</Name>
</ProjectReference>
<ProjectReference Include="..\Nancy.Testing.Experiments.Model\Models.csproj">
<Project>{A72EABE4-EA73-4EB0-A79F-92711D6875A9}</Project>
<Name>Models</Name>
</ProjectReference>
<ProjectReference Include="..\Nancy.ViewEngines.Razor\Nancy.ViewEngines.Razor.csproj">
<Project>{2C6F51DF-015C-4DB6-B44C-0E5E4F25E2A9}</Project>
<Name>Nancy.ViewEngines.Razor</Name>
Expand All @@ -93,9 +99,9 @@
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>0</DevelopmentServerPort>
<DevelopmentServerPort>38805</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:62997/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
Expand Down
69 changes: 69 additions & 0 deletions src/Nancy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nancy.Demo.Authentication.S
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nancy.Demo.Authentication.Stateless", "Nancy.Demo.Authentication.Stateless\Nancy.Demo.Authentication.Stateless.csproj", "{BAE74CD5-57C2-40E3-8F7A-EDE5721C2ACC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nancy.Testing.Experiments.Tests", "Nancy.Testing.Experiments.Tests\Nancy.Testing.Experiments.Tests.csproj", "{462BEDEB-21D4-4A79-AE3E-4452104C8642}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nancy.Testing.Experiments", "Nancy.Testing.Experiments\Nancy.Testing.Experiments.csproj", "{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Models", "Nancy.Testing.Experiments.Model\Models.csproj", "{A72EABE4-EA73-4EB0-A79F-92711D6875A9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1119,6 +1125,66 @@ Global
{BAE74CD5-57C2-40E3-8F7A-EDE5721C2ACC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{BAE74CD5-57C2-40E3-8F7A-EDE5721C2ACC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{BAE74CD5-57C2-40E3-8F7A-EDE5721C2ACC}.Release|x86.ActiveCfg = Release|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.Debug|Any CPU.Build.0 = Debug|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.Debug|x86.ActiveCfg = Debug|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.MonoDebug|Any CPU.ActiveCfg = Debug|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.MonoDebug|Any CPU.Build.0 = Debug|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.MonoDebug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.MonoDebug|Mixed Platforms.Build.0 = Debug|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.MonoDebug|x86.ActiveCfg = Debug|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.MonoRelease|Any CPU.ActiveCfg = Release|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.MonoRelease|Any CPU.Build.0 = Release|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.MonoRelease|Mixed Platforms.ActiveCfg = Release|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.MonoRelease|Mixed Platforms.Build.0 = Release|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.MonoRelease|x86.ActiveCfg = Release|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.Release|Any CPU.ActiveCfg = Release|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.Release|Any CPU.Build.0 = Release|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{462BEDEB-21D4-4A79-AE3E-4452104C8642}.Release|x86.ActiveCfg = Release|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.Debug|x86.ActiveCfg = Debug|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.MonoDebug|Any CPU.ActiveCfg = Debug|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.MonoDebug|Any CPU.Build.0 = Debug|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.MonoDebug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.MonoDebug|Mixed Platforms.Build.0 = Debug|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.MonoDebug|x86.ActiveCfg = Debug|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.MonoRelease|Any CPU.ActiveCfg = Release|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.MonoRelease|Any CPU.Build.0 = Release|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.MonoRelease|Mixed Platforms.ActiveCfg = Release|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.MonoRelease|Mixed Platforms.Build.0 = Release|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.MonoRelease|x86.ActiveCfg = Release|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.Release|Any CPU.Build.0 = Release|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3}.Release|x86.ActiveCfg = Release|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.Debug|x86.ActiveCfg = Debug|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.MonoDebug|Any CPU.ActiveCfg = Debug|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.MonoDebug|Any CPU.Build.0 = Debug|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.MonoDebug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.MonoDebug|Mixed Platforms.Build.0 = Debug|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.MonoDebug|x86.ActiveCfg = Debug|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.MonoRelease|Any CPU.ActiveCfg = Release|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.MonoRelease|Any CPU.Build.0 = Release|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.MonoRelease|Mixed Platforms.ActiveCfg = Release|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.MonoRelease|Mixed Platforms.Build.0 = Release|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.MonoRelease|x86.ActiveCfg = Release|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.Release|Any CPU.Build.0 = Release|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A72EABE4-EA73-4EB0-A79F-92711D6875A9}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -1141,6 +1207,8 @@ Global
{01230F2A-D108-480C-B834-8CE0569FD3B3} = {E944109B-0B7A-4ADE-8602-004CEFA5897D}
{EDF3E264-2D0F-4440-99FF-45D279A598A9} = {E944109B-0B7A-4ADE-8602-004CEFA5897D}
{211560C3-FDDF-46D6-AB0C-F3BC04B173B5} = {E944109B-0B7A-4ADE-8602-004CEFA5897D}
{EF098CBF-1DCE-4528-8CE7-16A56C8558A3} = {E944109B-0B7A-4ADE-8602-004CEFA5897D}
{A72EABE4-EA73-4EB0-A79F-92711D6875A9} = {E944109B-0B7A-4ADE-8602-004CEFA5897D}
{776D244D-BC4D-4BBB-A478-CAF2D04520E1} = {A427F9F8-0A6F-4EEA-837F-FCDAB6E7D4B3}
{3D44A461-3133-4B49-A74B-D25632A12FE5} = {A427F9F8-0A6F-4EEA-837F-FCDAB6E7D4B3}
{FE32460D-547C-4EB9-A768-541255CCAA83} = {A427F9F8-0A6F-4EEA-837F-FCDAB6E7D4B3}
Expand All @@ -1157,6 +1225,7 @@ Global
{FBC35268-377B-4DBE-87E3-B22D1314BEC6} = {A427F9F8-0A6F-4EEA-837F-FCDAB6E7D4B3}
{3F18F5DA-93E0-4513-8BF4-BC8EE5C4117C} = {A427F9F8-0A6F-4EEA-837F-FCDAB6E7D4B3}
{CA24ED85-DD68-4C10-B80A-D81C6745FCB8} = {A427F9F8-0A6F-4EEA-837F-FCDAB6E7D4B3}
{462BEDEB-21D4-4A79-AE3E-4452104C8642} = {A427F9F8-0A6F-4EEA-837F-FCDAB6E7D4B3}
{5F2DD52D-471B-4946-8F7B-F050C88EFC52} = {4A24657F-9695-437B-9702-2541ED280628}
{98940A30-1B48-4F71-A6BA-85F0AAF31A2F} = {4A24657F-9695-437B-9702-2541ED280628}
{EF660223-4DFD-4E36-BF36-9DD6AFB3F837} = {4A24657F-9695-437B-9702-2541ED280628}
Expand Down

0 comments on commit 556230a

Please sign in to comment.