Skip to content

Commit

Permalink
Merge pull request #68 from andrewchaa/PublicContexts
Browse files Browse the repository at this point in the history
Moving contexts to OpenRasta.Testing
  • Loading branch information
holytshirt committed Sep 3, 2014
2 parents 50f398c + 10c71d1 commit 684b7df
Show file tree
Hide file tree
Showing 39 changed files with 11,092 additions and 11,027 deletions.
21,920 changes: 10,960 additions & 10,960 deletions packages/NUnit.2.6.3/lib/nunit.framework.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using OpenRasta.Codecs;
using OpenRasta.DI;
using OpenRasta.Hosting;
using OpenRasta.Hosting.InMemory;
using OpenRasta.Testing;
using OpenRasta.Web;

namespace OpenRasta.Codecs
namespace OpenRasta.Testing.Contexts
{
public abstract class codec_context<TCodec> : context where TCodec:ICodec
{
Expand Down
18 changes: 18 additions & 0 deletions src/OpenRasta.Testing/Contexts/contributor_context.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using OpenRasta.Pipeline;

namespace OpenRasta.Testing.Contexts
{
public abstract class contributor_context<T> : openrasta_context
where T : class, IPipelineContributor
{
public void given_contributor()
{
given_pipeline_contributor<T>();
}

protected void then_contributor_returns(PipelineContinuation continuation)
{
Result.ShouldBe(continuation);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
using System.IO;
using System.Reflection;
using System.Text;
using OpenRasta.DI;
using OpenRasta.Codecs;
using OpenRasta.IO;
using OpenRasta.Testing;
using OpenRasta.TypeSystem;
using OpenRasta.Web;

namespace OpenRasta.Codecs
namespace OpenRasta.Testing.Contexts
{
public abstract class media_type_reader_context<TCodec> : codec_context<TCodec>
where TCodec : ICodec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using OpenRasta.Codecs;
using OpenRasta.Web;

namespace OpenRasta.Codecs
namespace OpenRasta.Testing.Contexts
{
public abstract class media_type_writer_context<TCodec> : codec_context<TCodec> where TCodec : ICodec
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
using OpenRasta.Hosting.InMemory;
using OpenRasta.Pipeline;
using OpenRasta.Security;
using OpenRasta.Testing;
using OpenRasta.TypeSystem;
using OpenRasta.Web;

namespace OpenRasta.Tests
namespace OpenRasta.Testing.Contexts
{
public class openrasta_context : context
{
Expand Down
38 changes: 38 additions & 0 deletions src/OpenRasta.Testing/Contexts/operation_context.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Linq;
using OpenRasta.Binding;
using OpenRasta.OperationModel;
using OpenRasta.OperationModel.MethodBased;
using OpenRasta.TypeSystem;

namespace OpenRasta.Testing.Contexts
{
public abstract class operation_context<THandler> : openrasta_context
{
protected operation_context()
{
Handler = TypeSystem.FromClr<THandler>();
}

protected IType Handler { get; set; }
protected IOperation Operation { get; set; }

protected void given_operation(string name, params Type[] parameters)
{
IMethod method = (from m in Handler.GetMethods()
where m.InputMembers.Count() == parameters.Length && m.Name.EqualsOrdinalIgnoreCase(name)
let matchingParams =
(from parameter in m.InputMembers
from typeParameter in parameters
where parameter.Type.CompareTo(parameter.TypeSystem.FromClr(typeParameter)) == 0
select parameter).Count()
where parameters.Length == 0 || matchingParams == parameters.Length
select m).First();
Operation = new MethodBasedOperation(new DefaultObjectBinderLocator(), Handler, method)
{
Resolver = Resolver
};
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
using OpenRasta.Binding;
using OpenRasta.OperationModel;
using OpenRasta.OperationModel.MethodBased;
using OpenRasta.Testing;
using OpenRasta.Tests.Unit.OperationModel.MethodBased;
using OpenRasta.TypeSystem;
using OpenRasta.Web;

namespace OpenRasta.Tests.Unit.OperationModel.Filters
namespace OpenRasta.Testing.Contexts
{
public abstract class operation_filter_context<THandler, TFilter> : operation_context<THandler>
where TFilter : IOperationProcessor
Expand Down
14 changes: 14 additions & 0 deletions src/OpenRasta.Testing/OpenRasta.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,27 @@
</ItemGroup>
<ItemGroup>
<Compile Include="context.cs" />
<Compile Include="Contexts\codec_context.cs" />
<Compile Include="Contexts\contributor_context.cs" />
<Compile Include="Contexts\media_type_reader_context.cs" />
<Compile Include="Contexts\media_type_writer_context.cs" />
<Compile Include="Contexts\openrasta_context.cs" />
<Compile Include="Contexts\operation_context.cs" />
<Compile Include="Contexts\operation_filter_context.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SpecExtensions.cs" />
<Compile Include="SpecExtensionsFixture.cs" />
<Compile Include="TestErrorCollector.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRasta\OpenRasta.csproj">
<Project>{3D251617-2581-4D9C-A639-5CFB0BB09420}</Project>
<Name>OpenRasta</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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using System.Collections.Generic;
using OpenRasta.Diagnostics;

namespace OpenRasta.Tests
namespace OpenRasta.Testing
{
public class TestErrorCollector : IErrorCollector
{
Expand Down
24 changes: 24 additions & 0 deletions src/OpenRasta.Testing/openrasta-testing.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata>
<id>openrasta-testing</id>
<version>$version$</version>
<title>OpenRasta.Testing</title>
<authors>Sebastien Lambla</authors>
<owners>Sebastien Lambla</owners>
<licenseUrl>http://openrasta.org/</licenseUrl>
<projectUrl>https://github.com/openrasta/openrasta-core</projectUrl>
<iconUrl>http://openrasta.org/openRastaLogo-32x32.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>BDD-style contexts for developing OpenRasta extensions.</description>
<releaseNotes />
<copyright>Copyright 2007</copyright>
<tags>OpenRasta Testing Contexts</tags>
<dependencies>
<dependency id="openrasta-core" version="$version$" />
</dependencies>
</metadata>
<files>
<file src="bin\release\OpenRasta.Testing.dll" target="lib\net40\OpenRasta.Testing.dll" />
</files>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using OpenRasta.Pipeline.Contributors;
using OpenRasta.Security;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.Tests;
using OpenRasta.Web;
using OpenRasta.Pipeline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Text;
using OpenRasta.Codecs;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.TypeSystem.ReflectionBased;
using OpenRasta.Web;
using NUnit.Framework;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using OpenRasta.Data;
using OpenRasta.Testing;
using NUnit.Framework;
using OpenRasta.Testing.Contexts;
using OpenRasta.Web;
using Moq;
using System.IO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using OpenRasta.Testing;
using NUnit.Framework;
using OpenRasta.Codecs;
using OpenRasta.Testing.Contexts;
using OpenRasta.TypeSystem;
using OpenRasta.Web;
using OpenRasta.IO;
Expand Down
6 changes: 0 additions & 6 deletions src/OpenRasta.Tests.Unit/OpenRasta.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@
<Compile Include="Codecs\ApplicationXWwwUrlformEncodedCodec_Specification.cs" />
<Compile Include="Codecs\CodecMatch_Specification.cs" />
<Compile Include="Codecs\CodecRepository_Specification.cs" />
<Compile Include="Codecs\codec_context.cs" />
<Compile Include="Codecs\JsonDataContractCodec_Specification.cs" />
<Compile Include="Codecs\MediaTypeDictionary_Specification.cs" />
<Compile Include="Codecs\media_type_reader_context.cs" />
<Compile Include="Codecs\media_type_writer_context.cs" />
<Compile Include="Codecs\MultipartFormDataCodec_Specification.cs" />
<Compile Include="Codecs\WebForms_Specification.cs" />
<Compile Include="Codecs\xml.cs" />
Expand Down Expand Up @@ -97,10 +94,8 @@
<Compile Include="IO\MultipartReader_Specification.cs" />
<Compile Include="IO\MultipartWriter_Specification.cs" />
<Compile Include="IO\stream_context.cs" />
<Compile Include="openrasta_context.cs" />
<Compile Include="OperationModel\CodecSelectors\RequestCodecSelector_Specification.cs" />
<Compile Include="OperationModel\Filters\HttpMethodOperationFilter_Specification.cs" />
<Compile Include="OperationModel\Filters\operation_filter_context.cs" />
<Compile Include="OperationModel\Filters\UriNameOperationFilter_Specification.cs" />
<Compile Include="OperationModel\Filters\UriParametersFilter_Specification.cs" />
<Compile Include="OperationModel\Hydrators\RequestEntityReaderHydrator_Specification.cs" />
Expand Down Expand Up @@ -129,7 +124,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Security\RequiresAuthenticationInterceptor_Specification.cs" />
<Compile Include="Security\RequiresRoleInterceptor_Specification.cs" />
<Compile Include="TestErrorCollector.cs" />
<Compile Include="Text\Rfc2047Encoding_Specification.cs" />
<Compile Include="TypeSystem\Extensions_Specification.cs" />
<Compile Include="TypeSystem\Instances_Specification.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using OpenRasta.OperationModel.CodecSelectors;
using OpenRasta.OperationModel.Hydrators;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.Tests.Unit.Fakes;
using OpenRasta.Tests.Unit.OperationModel.Filters;
using OpenRasta.Web;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NUnit.Framework;
using OpenRasta.OperationModel.Filters;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.Web;

namespace OpenRasta.Tests.Unit.OperationModel.Filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NUnit.Framework;
using OpenRasta.OperationModel.Filters;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;

namespace OpenRasta.Tests.Unit.OperationModel.Filters
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NUnit.Framework;
using OpenRasta.OperationModel.Filters;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.Web;

namespace OpenRasta.Tests.Unit.OperationModel.Filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using OpenRasta.OperationModel.Hydrators;
using OpenRasta.OperationModel.Hydrators.Diagnostics;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.Tests.Unit.Fakes;
using OpenRasta.Tests.Unit.OperationModel.Filters;
using OpenRasta.TypeSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using OpenRasta.OperationModel;
using OpenRasta.OperationModel.Interceptors;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.Tests.Unit.OperationModel.MethodBased;

namespace OpenRasta.Tests.Unit.OperationModel.Interceptors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using OpenRasta.OperationModel;
using OpenRasta.OperationModel.MethodBased;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.TypeSystem;

namespace OpenRasta.Tests.Unit.OperationModel.MethodBased
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
using System.Linq;
using System.Runtime.InteropServices;
using NUnit.Framework;
using OpenRasta.Binding;
using OpenRasta.DI;
using OpenRasta.OperationModel;
using OpenRasta.OperationModel.MethodBased;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.TypeSystem;

namespace OpenRasta.Tests.Unit.OperationModel.MethodBased
Expand Down Expand Up @@ -192,33 +191,4 @@ public object Search([Optional, DefaultParameterValue("*")]string searchString)
return 0;
}
}

public abstract class operation_context<THandler> : openrasta_context
{
protected operation_context()
{
Handler = TypeSystem.FromClr<THandler>();
}

protected IType Handler { get; set; }
protected IOperation Operation { get; set; }

protected void given_operation(string name, params Type[] parameters)
{
IMethod method = (from m in Handler.GetMethods()
where m.InputMembers.Count() == parameters.Length && m.Name.EqualsOrdinalIgnoreCase(name)
let matchingParams =
(from parameter in m.InputMembers
from typeParameter in parameters
where parameter.Type.CompareTo(parameter.TypeSystem.FromClr(typeParameter)) == 0
select parameter).Count()
where parameters.Length == 0 || matchingParams == parameters.Length
select m).First();
Operation = new MethodBasedOperation(new DefaultObjectBinderLocator(), Handler, method)
{
Resolver = Resolver
};
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using NUnit.Framework;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.TypeSystem;
using OpenRasta.OperationModel.MethodBased;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma warning disable 618
using OpenRasta.Testing.Contexts;
#pragma warning disable 618
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma warning disable 618
using OpenRasta.Testing.Contexts;
#pragma warning disable 618
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using NUnit.Framework;
using OpenRasta.Reflection;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.Tests;
using OpenRasta.Web;
using OpenRasta.Pipeline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using OpenRasta.Pipeline;
using NUnit.Framework;
using OpenRasta.Codecs;
using OpenRasta.Testing.Contexts;
using OpenRasta.Tests;
using OpenRasta.Tests.Unit.Fakes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using NUnit.Framework;
using OpenRasta.Pipeline.Contributors;
using OpenRasta.Testing;
using OpenRasta.Testing.Contexts;
using OpenRasta.Tests;
using OpenRasta.Web;
using OpenRasta.TypeSystem;
Expand Down
Loading

0 comments on commit 684b7df

Please sign in to comment.