Skip to content
Closed
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
7 changes: 7 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tasks": {
"test": "dotnet test",
"build": "dotnet build",
"launch": "echo \"cannot run is a library\" && exit 1"
}
}
3 changes: 2 additions & 1 deletion test/ApiStub.FSharp.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<Compile Include="BDDTests.fs" />
<Compile Include="BuilderExtensionsTests.fs" />
<Compile Include="StubberyTests.fs" />
<Compile Include="IssuesTests.fs" />
<Content Include="swagger.json" />
</ItemGroup>
<ItemGroup>
Expand All @@ -34,4 +35,4 @@
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="6.0.3" />
</ItemGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions test/BDDTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ module BDDTests =
)
|> END


75 changes: 75 additions & 0 deletions test/IssuesTests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
namespace ApiStub.FSharp.Tests

open Xunit
open fsharpintegrationtests
open Microsoft.AspNetCore.Mvc.Testing
open Microsoft.Extensions.DependencyInjection
open Microsoft.AspNetCore.Hosting
open SwaggerProvider
open System.Threading.Tasks
open System.Net.Http
open System
open Microsoft.AspNetCore.TestHost
open Microsoft.Extensions.Http
open Microsoft.AspNetCore.Routing.Template
open Microsoft.AspNetCore.Routing.Patterns
open Microsoft.AspNetCore.Routing
open System.Net
open System.Text.Json
open Microsoft.AspNetCore.Http
open System.Net.Http.Json
open Swensen.Unquote
open ApiStub.FSharp.CE
open ApiStub.FSharp.BuilderExtensions
open ApiStub.FSharp.HttpResponseHelpers
open ApiStub.FSharp
open ApiStub.FSharp.BDD
open HttpResponseMessageExtensions
open Xunit.Abstractions

module IssuesTests =

let testce = new TestClient<Startup>()

[<Fact>]
let ``when base URL without trailing slash is combined correctly`` () =

let mutable expected = "_"
let stubData = { Ok = "undefined" }

testce {
POSTJ "/another/anotherApi" {| Test = "NOT_USED_VAL" |}
GET_ASYNC "/externalApi" (fun r _ -> task {
return { stubData with Ok = expected } |> R_JSON
})
}
|> SCENARIO "when base URL without trailing slash is combined correctly"
|> SETUP (fun s -> task {

let test = s.TestClient

let f = test.GetFactory()

return {
Client = f.CreateClient()
Factory = f
Scenario = s
FeatureStubData = stubData
}
}) (fun c ->
c.BaseAddress <- new Uri("http://whatever/without-trailing-slash")
c
)
|> GIVEN (fun g ->
expected <- "world"
expected |> Task.FromResult
)
|> WHEN (fun g -> task {
let! (r : HttpResponseMessage) = g.Environment.Client.GetAsync("/Hello")
return! r.Content.ReadFromJsonAsync<Hello>()

})
|> THEN (fun w ->
Assert.Equal(w.Given.ArrangeData, w.AssertData.Ok)
)
|> END
Loading