Skip to content

Commit

Permalink
[infra] bumping up Fuchu + FsCheck all the way
Browse files Browse the repository at this point in the history
  • Loading branch information
haf committed Nov 22, 2015
1 parent 04024c1 commit c30f574
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 159 deletions.
182 changes: 90 additions & 92 deletions examples/NancyFx.CSharp/NancyFx.CSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,92 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{76746004-36CF-41FC-B67A-CF07D1776CB5}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>NancyFx.CSharp</RootNamespace>
<AssemblyName>NancyFx.CSharp</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<NoWarn>1701</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Content Include="App.config" />
<Compile Include="Program.cs" />
<None Include="paket.references" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\src\Suave\Suave.fsproj">
<Project>{3DC9193E-BD0C-4486-9C58-56B630C36623}</Project>
<Name>Suave</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\examples\FSharp.Core\lib\net40\FSharp.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
<ItemGroup>
<Reference Include="Nancy">
<HintPath>..\..\packages\examples\Nancy\lib\net40\Nancy.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
<ItemGroup>
<Reference Include="Nancy.Owin">
<HintPath>..\..\packages\examples\Nancy.Owin\lib\net40\Nancy.Owin.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
<ItemGroup>
<Reference Include="Owin">
<HintPath>..\..\packages\examples\Owin\lib\net40\Owin.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<ItemGroup>
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{76746004-36CF-41FC-B67A-CF07D1776CB5}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>NancyFx.CSharp</RootNamespace>
<AssemblyName>NancyFx.CSharp</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<NoWarn>1701</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Content Include="App.config" />
<Compile Include="Program.cs" />
<None Include="paket.references" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\src\Suave\Suave.fsproj">
<Project>{3DC9193E-BD0C-4486-9C58-56B630C36623}</Project>
<Name>Suave</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\packages\examples\FSharp.Core\lib\net40\FSharp.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
<ItemGroup>
<Reference Include="Nancy">
<HintPath>..\..\packages\examples\Nancy\lib\net40\Nancy.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
<ItemGroup>
<Reference Include="Nancy.Owin">
<HintPath>..\..\packages\examples\Nancy.Owin\lib\net40\Nancy.Owin.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5'">
<ItemGroup>
<Reference Include="Owin">
<HintPath>..\..\packages\examples\Owin\lib\net40\Owin.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
4 changes: 2 additions & 2 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ group Tests
source https://nuget.org/api/v2
nuget FSharp.Core ~> 3.1.2
nuget WebSocketSharp
nuget FsCheck = 2.0.7
nuget FsCheck
nuget Fuchu.FsCheck
nuget Fuchu.PerfUtil ~> 0.6
nuget Fuchu.PerfUtil
nuget Http.fs-prerelease
nuget FSharp.Charting

Expand Down
14 changes: 7 additions & 7 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ FRAMEWORK: NET45
NUGET
remote: https://nuget.org/api/v2
specs:
FsCheck (2.0.7)
FsCheck (2.2.2)
FSharp.Core (>= 3.1.2.5)
FSharp.Charting (0.90.13)
FSharp.Core (3.1.2.5)
Fuchu (1.0.1)
FSharp.Core (>= 3.1.2.1)
Fuchu.FsCheck (0.6.0)
FsCheck (>= 1.0.4)
FSharp.Core (>= 3.1.2.1)
Fuchu (>= 0.6.0.0)
Fuchu.PerfUtil (0.6.0)
Fuchu.FsCheck (1.0.1.0)
FsCheck (>= 2.1.0)
FSharp.Core (>= 3.1.2.5)
Fuchu (>= 1.0.1.0)
Fuchu.PerfUtil (1.0.1.0)
FSharp.Core (>= 3.1.2.1)
Fuchu (>= 0.6.0.0)
Fuchu (>= 1.0.1.0)
PerfUtil (>= 0.1.8)
Http.fs-prerelease (2.4.0)
FSharp.Core (>= 3.1.2.1)
Expand Down
2 changes: 1 addition & 1 deletion src/Suave.Tests/Auth.fs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ let sessionState f =
| Some store -> f store )

[<Tests>]
let tests cfg =
let authTests cfg =
let runWithConfig = runWith { cfg with logger = Loggers.saneDefaultsFor LogLevel.Warn }
testList "auth tests" [
testCase "baseline, no auth cookie" <| fun _ ->
Expand Down
2 changes: 1 addition & 1 deletion src/Suave.Tests/Connection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let setConnectionKeepAlive (r : HttpRequestMessage) =
r

[<Tests>]
let tests cfg =
let connectionTests cfg =
testList "connecting" [
testCase "connect with keep-alive default" <| fun _ ->
let context = runWith cfg (OK "ACK")
Expand Down
32 changes: 16 additions & 16 deletions src/Suave.Tests/FuchuExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@ let testFromMemberWithParam (param : 't) (m: MemberInfo): Test option =
[m]
|> List.filter (fun m -> m.HasAttributeType typeof<TestsAttribute>)
|> List.choose (fun m ->
match box m with
| :? FieldInfo as m ->
if m.FieldType = typeof<Test>
then Some(unbox (m.GetValue(null)))
else None
| :? MethodInfo as m ->
if m.ReturnType = typeof<Test>
then
Some(unbox (m.Invoke(null, [|param :> obj |])))
else None
| :? PropertyInfo as m ->
if m.PropertyType = typeof<Test>
then Some(unbox (m.GetValue(null, null)))
else None
| _ -> None)
match box m with
| :? FieldInfo as m ->
if m.FieldType = typeof<Test>
then Some(unbox (m.GetValue(null)))
else None
| :? MethodInfo as m ->
if m.ReturnType = typeof<Test>
then Some(unbox (m.Invoke(null, [| param :> obj |])))
else None
| :? PropertyInfo as m ->
if m.PropertyType = typeof<Test>
then Some(unbox (m.GetValue(null, null)))
else None
| _ -> None)
|> List.tryFind (fun _ -> true)

let listToTestListOption =
Expand Down Expand Up @@ -56,7 +55,8 @@ let testFromAssemblyWithFilterAndParam typeFilter (a: Assembly) param =
|> listToTestListOption

/// Scan tests marked with TestsAttribute from an assembly
let testFromAssemblyWithParam asm param = testFromAssemblyWithFilterAndParam (fun _ -> true) asm param
let testFromAssemblyWithParam asm param =
testFromAssemblyWithFilterAndParam (fun _ -> true) asm param

let defaultMainThisAssemblyWithParam param args =

Expand Down
2 changes: 1 addition & 1 deletion src/Suave.Tests/HttpApplicatives.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ open Suave.Testing
open Fuchu

[<Tests>]
let tests cfg =
let applicativeTests cfg =
let runWithConfig = runWith cfg
let ip, port =
let binding = SuaveConfig.firstBinding cfg
Expand Down
2 changes: 1 addition & 1 deletion src/Suave.Tests/HttpAuthentication.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ open Suave.Testing
open Fuchu

[<Tests>]
let tests cfg =
let authTests cfg =
let runWithConfig = runWith cfg

let user = "foo"
Expand Down
44 changes: 22 additions & 22 deletions src/Suave.Tests/HttpVerbs.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Suave.Tests.Common
module Suave.Tests.HttpVerbs

open System
open System.Text
Expand All @@ -20,27 +20,27 @@ open Fuchu
let gets cfg =
let runWithConfig = runWith cfg
testList "getting basic responses" [
testCase "200 OK returns 'a'" <| fun _ ->
Assert.Equal("expecting non-empty response", "a", runWithConfig (OK "a") |> req HttpMethod.GET "/" None)

testCase "200 OK returning url" <| fun _ ->
Assert.Equal("expecting correct url from binding",
SuaveConfig.firstBindingUri cfg "/" "" |> string,
runWithConfig (request (fun r -> OK (r.url.ToString())))
|> req HttpMethod.GET "/" None)

testPropertyWithConfig fsCheckConfig "200 OK returns equivalent" <| fun respStr ->
(runWithConfig (OK respStr) |> req HttpMethod.GET "/hello" None) = respStr

testCase "204 No Content empty body" <| fun _ ->
Assert.Equal("empty string should always be returned by 204 No Content",
"", (runWithConfig NO_CONTENT |> req HttpMethod.GET "/" None))

testCase "302 FOUND sends content-length header" <| fun _ ->
let headers = reqContentHeaders HttpMethod.GET "/" None (runWithConfig (Redirection.FOUND "/url"))
Assert.Equal("302 FOUND sends content-length header",
true,
headers.Contains("Content-Length"))
testCase "200 OK returns 'a'" <| fun _ ->
Assert.Equal("expecting non-empty response", "a", runWithConfig (OK "a") |> req HttpMethod.GET "/" None)

testCase "200 OK returning url" <| fun _ ->
Assert.Equal("expecting correct url from binding",
SuaveConfig.firstBindingUri cfg "/" "" |> string,
runWithConfig (request (fun r -> OK (r.url.ToString())))
|> req HttpMethod.GET "/" None)

testPropertyWithConfig fsCheckConfig "200 OK returns equivalent" <| fun respStr ->
(runWithConfig (OK respStr) |> req HttpMethod.GET "/hello" None) = respStr

testCase "204 No Content empty body" <| fun _ ->
Assert.Equal("empty string should always be returned by 204 No Content",
"", (runWithConfig NO_CONTENT |> req HttpMethod.GET "/" None))

testCase "302 FOUND sends content-length header" <| fun _ ->
let headers = reqContentHeaders HttpMethod.GET "/" None (runWithConfig (Redirection.FOUND "/url"))
Assert.Equal("302 FOUND sends content-length header",
true,
headers.Contains("Content-Length"))
]

[<Tests>]
Expand Down
2 changes: 1 addition & 1 deletion src/Suave.Tests/Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ open Suave.Tests.TestUtilities
open Suave.Testing

[<Tests>]
let tests cfg =
let modelTests cfg =
let runWithConfig = runWith cfg

let postData3 = readText "request-2.txt"
Expand Down
4 changes: 2 additions & 2 deletions src/Suave.Tests/Owin.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let throws msg matcher fn =
try fn () with e when matcher e -> ()

[<Tests>]
let unit =
let owinUnit =
let create (m : (string * string) list) =
OwinApp.DeltaDictionary(m) :> IDictionary<string, string[]>

Expand Down Expand Up @@ -115,7 +115,7 @@ let unit =
]

[<Tests>]
let endToEnd cfg =
let owinEndToEnd cfg =
let runWithConfig = runWith cfg

let owinHelloWorld (env : OwinEnvironment) =
Expand Down
Loading

0 comments on commit c30f574

Please sign in to comment.