mirror of
https://github.com/Smaug123/WoofWare.Myriad
synced 2025-10-10 06:28:40 +00:00
Bump deps (#54)
This commit is contained in:
36
WoofWare.Myriad.Plugins.Test/TestHttpClient/TestPathParam.fs
Normal file
36
WoofWare.Myriad.Plugins.Test/TestHttpClient/TestPathParam.fs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace WoofWare.Myriad.Plugins.Test
|
||||
|
||||
open System
|
||||
open System.Net
|
||||
open System.Net.Http
|
||||
open NUnit.Framework
|
||||
open FsUnitTyped
|
||||
open PureGym
|
||||
|
||||
[<TestFixture>]
|
||||
module TestPathParam =
|
||||
|
||||
[<Test>]
|
||||
let ``Path params are escaped`` () =
|
||||
let proc (message : HttpRequestMessage) : HttpResponseMessage Async =
|
||||
async {
|
||||
message.Method |> shouldEqual HttpMethod.Get
|
||||
|
||||
let expectedUriPrefix = "https://example.com/endpoint/"
|
||||
|
||||
let actualUri = message.RequestUri.ToString ()
|
||||
|
||||
if not (actualUri.StartsWith (expectedUriPrefix, StringComparison.Ordinal)) then
|
||||
failwith $"wrong prefix on %s{actualUri}"
|
||||
|
||||
let content = new StringContent (actualUri.Substring expectedUriPrefix.Length)
|
||||
let resp = new HttpResponseMessage (HttpStatusCode.OK)
|
||||
resp.Content <- content
|
||||
return resp
|
||||
}
|
||||
|
||||
use client = HttpClientMock.make (Uri "https://example.com") proc
|
||||
let api = PureGymApi.make client
|
||||
|
||||
api.GetPathParam("hello/world?(hi)").Result
|
||||
|> shouldEqual "hello%2fworld%3f(hi)"
|
Reference in New Issue
Block a user