Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
"version": "6.0.5",
"commands": [
"fantomas"
]
],
"rollForward": false
},
"husky": {
"version": "0.7.2",
"commands": [
"husky"
],
"rollForward": false
}
}
}
22 changes: 22 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

## husky task runner examples -------------------
## Note : for local installation use 'dotnet' prefix. e.g. 'dotnet husky'

## run all tasks
#husky run

### run all tasks with group: 'group-name'
#husky run --group group-name

## run task with name: 'task-name'
#husky run --name task-name

## pass hook arguments to task
#husky run --args "$1" "$2"

## or put your custom commands -------------------
#echo 'Husky.Net is awesome!'

dotnet husky run --group pre-commit
19 changes: 19 additions & 0 deletions .husky/task-runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://alirezanet.github.io/Husky.Net/schema.json",
"tasks": [
{
"name": "fantomas-format-staged-files",
"group": "pre-commit",
"command": "dotnet",
"args": [
"fantomas",
"${staged}"
],
"include": [
"**/*.fs",
"**/*.fsx",
"**/*.fsi"
]
}
]
}
36 changes: 16 additions & 20 deletions ApiStub.FSharp.Stubbery/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,55 +36,51 @@ module StubberyCE =
stubbery
.Request(methods)
.IfRoute(route)
.Response(fun r args -> stub r args |> box) |> ignore
.Response(fun r args -> stub r args |> box)
|> ignore

this

[<CustomOperation("stub_obj")>]
member this.StubObj(x, methods, route, stub : unit -> obj) =
this.Stub(x, methods, route, fun _ _ -> stub())
member this.StubObj(x, methods, route, stub: unit -> obj) =
this.Stub(x, methods, route, (fun _ _ -> stub ()))

[<CustomOperation("GET")>]
member this.Get(x, route, stub) =
this.Stub(x, [|HttpMethod.Get|], route, stub)
this.Stub(x, [| HttpMethod.Get |], route, stub)

[<CustomOperation("GET_OBJ")>]
member this.GetObj(x, route, stub) =
this.StubObj(x, [|HttpMethod.Get|], route, fun _ -> stub)
this.StubObj(x, [| HttpMethod.Get |], route, (fun _ -> stub))

[<CustomOperation("POST")>]
member this.Post(x, route, stub) =
this.Stub(x, [|HttpMethod.Post|], route, stub)
this.Stub(x, [| HttpMethod.Post |], route, stub)

[<CustomOperation("POST_OBJ")>]
member this.PostObj(x, route, stub) =
this.StubObj(x, [|HttpMethod.Post|], route, fun _ -> stub)
this.StubObj(x, [| HttpMethod.Post |], route, (fun _ -> stub))

[<CustomOperation("PUT")>]
member this.Put(x, route, stub) =
this.Stub(x, [|HttpMethod.Put|], route, stub)
this.Stub(x, [| HttpMethod.Put |], route, stub)

[<CustomOperation("DELETE")>]
member this.Delete(x, route, stub) =
this.Stub(x, [|HttpMethod.Delete|], route, stub)
this.Stub(x, [| HttpMethod.Delete |], route, stub)

member this.GetFactory() =
let clientBuilder =
factory
|> web_configure_services (fun s ->
s.ConfigureAll<HttpClientFactoryOptions>(fun options ->
options.HttpClientActions.Add(fun c ->
c.BaseAddress <- uri.MockUri
)
)
)
options.HttpClientActions.Add(fun c -> c.BaseAddress <- uri.MockUri)))

stubbery.Start()
uri.MockUri <- new Uri(stubbery.Address)
clientBuilder

interface IDisposable
with member this.Dispose() =
factory.Dispose()
stubbery.Dispose()


interface IDisposable with
member this.Dispose() =
factory.Dispose()
stubbery.Dispose()
88 changes: 44 additions & 44 deletions ApiStub.FSharp/ApiStub.FSharp.fsproj
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>ApiStub.FSharp</PackageId>
<Version>1.0.2</Version>
<Authors>jkone27</Authors>
<RequireLicenseAcceptance>false</RequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>Aspnet;Testing;Integration Testing;dotnet;Stub</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RepositoryUrl>https://github.com/jkone27/fsharp-integration-tests.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<EnablePackageValidation>true</EnablePackageValidation>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<Compile Include="BuilderExtensions.fs" />
<Compile Include="HttpResponseHelpers.fs" />
<Compile Include="DelegatingHandlers.fs" />
<Compile Include="CE.fs" />
<Compile Include="BDD.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.3">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="6.0.3" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>ApiStub.FSharp</PackageId>
<Version>1.0.2</Version>
<Authors>jkone27</Authors>
<RequireLicenseAcceptance>false</RequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>Aspnet;Testing;Integration Testing;dotnet;Stub</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RepositoryUrl>https://github.com/jkone27/fsharp-integration-tests.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<EnablePackageValidation>true</EnablePackageValidation>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<Compile Include="BuilderExtensions.fs" />
<Compile Include="HttpResponseHelpers.fs" />
<Compile Include="DelegatingHandlers.fs" />
<Compile Include="CE.fs" />
<Compile Include="BDD.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.3">
<GeneratePathProperty></GeneratePathProperty>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="6.0.3" />
</ItemGroup>
<Target Name="Husky" BeforeTargets="Restore;CollectPackageReferences" Condition="'$(HUSKY)' != 0">
<Exec Command="dotnet tool restore" StandardOutputImportance="Low" StandardErrorImportance="High" />
<Exec Command="dotnet husky install" StandardOutputImportance="Low" StandardErrorImportance="High" WorkingDirectory=".." />
</Target>
</Project>
Loading
Loading