anchor.diff:  
   [<Fact>]
   let ``POST "/json" with supported Accept header returns "json"`` () =
  +    let app = 
  +        choose [
  +            GET >>= choose [ 
  +                route "/"     >>= text "Hello World"
  +                route "/foo"  >>= text "bar" ]
  +            POST >>= choose [
  +                route "/text"   >>= mustAccept [ "text/plain" ] >>= text "text"
  +                route "/json"   >>= mustAccept [ "application/json" ] >>= json "json"
  +                route "/either" >>= mustAccept [ "text/plain"; "application/json" ] >>= text "either" ]
  +            setStatusCode 404 >>= text "Not found" ]
  +
       let headers = new HeaderDictionary()
       headers.Add("Accept", new StringValues("application/json"))
       ctx.Request.Method.ReturnsForAnyArgs "POST" |> ignore
  
positive.code: let services = Substitute.For<IServiceProvider>()
  
  // ---------------------------------
  // HttpHandler application
  // ---------------------------------
  
  type Dummy =
  
negative.code:         Age : int
      }
  
  // ---------------------------------
  // Tests
  // ---------------------------------
  
  [<Fact>]
  let ``GET "/" returns "Hello World"`` () =
      let app = 
          GET >>= choose [ 
              route "/"    >>= text "Hello World"
              route "/foo" >>= text "bar"
              setStatusCode 404 >>= text "Not found" ]
  
      ctx.Request.Method.ReturnsForAnyArgs "GET" |> ignore
      ctx.Request.Path.ReturnsForAnyArgs (PathString("/")) |> ignore
      ctx.Response.Body <- new MemoryStream()
      let expected = "Hello World"
  
      let result = 
          { HttpContext = ctx; Services = services }
          |> app
          |> Async.RunSynchronously
  
      match result with
      | None     -> assertFailf "Result was expected to be %s" expected
      | Some ctx ->
          let body = getBody ctx
          Assert.Equal(expected, body)
  
  [<Fact>]
  let ``GET "/foo" returns "bar"`` () =
      let app = 
          GET >>= choose [ 
              route "/"    >>= text "Hello World"
              route "/foo" >>= text "bar"
              setStatusCode 404 >>= text "Not found" ]
  
      ctx.Request.Method.ReturnsForAnyArgs "GET" |> ignore
      ctx.Request.Path.ReturnsForAnyArgs (PathString("/foo")) |> ignore
      ctx.Response.Body <- new MemoryStream()
      let expected = "bar"
  
      let result = 
          { HttpContext = ctx; Services = services }
          |> app
          |> Async.RunSynchronously
  
      match result with
      | None     -> assertFailf "Result was expected to be %s" expected
      | Some ctx ->
          let body = getBody ctx
          Assert.Equal(expected, body)
  
  [<Fact>]
  let ``GET "/FOO" returns 404 "Not found"`` () =
      let app = 
          GET >>= choose [ 
              route "/"    >>= text "Hello World"
              route "/foo" >>= text "bar"
              setStatusCode 404 >>= text "Not found" ]
  
      ctx.Request.Method.ReturnsForAnyArgs "GET" |> ignore
      ctx.Request.Path.ReturnsForAnyArgs (PathString("/FOO")) |> ignore
      ctx.Response.Body <- new MemoryStream()
      let expected = "Not found"
  
      let result = 
          { HttpContext = ctx; Services = services }
          |> app
          |> Async.RunSynchronously
  
      match result with
      | None     -> assertFailf "Result was expected to be %s" expected
      | Some ctx ->
          let body = getBody ctx
          Assert.Equal(expected, body)
          Assert.Equal(404, ctx.HttpContext.Response.StatusCode)
  
  [<Fact>]
  let ``GET "/json" returns json object`` () =
      let app = 
          GET >>= choose [ 
              route "/"     >>= text "Hello World"
              route "/foo"  >>= text "bar"
              route "/json" >>= json { Foo = "john"; Bar = "doe"; Age = 30 }
              setStatusCode 404 >>= text "Not found" ]
  
      ctx.Request.Method.ReturnsForAnyArgs "GET" |> ignore
      ctx.Request.Path.ReturnsForAnyArgs (PathString("/json")) |> ignore
      ctx.Response.Body <- new MemoryStream()
      let expected = "{\"Foo\":\"john\",\"Bar\":\"doe\",\"Age\":30}"
  
      let result = 
          { HttpContext = ctx; Services = services }
          |> app
          |> Async.RunSynchronously
  
      match result with
      | None     -> assertFailf "Result was expected to be %s" expected
      | Some ctx ->
          let body = getBody ctx
          Assert.Equal(expected, body)
  
  [<Fact>]
  let ``POST "/post/1" returns "1"`` () =
      let app = 
          choose [
              GET >>= choose [ 
                  route "/"     >>= text "Hello World"
                  route "/foo"  >>= text "bar" ]
              POST >>= choose [
                  route "/post/1" >>= text "1"
                  route "/post/2" >>= text "2" ]
              setStatusCode 404 >>= text "Not found" ]
  
      ctx.Request.Method.ReturnsForAnyArgs "POST" |> ignore
      ctx.Request.Path.ReturnsForAnyArgs (PathString("/post/1")) |> ignore
      ctx.Response.Body <- new MemoryStream()
      let expected = "1"
  
      let result = 
          { HttpContext = ctx; Services = services }
          |> app
          |> Async.RunSynchronously
  
      match result with
      | None     -> assertFailf "Result was expected to be %s" expected
      | Some ctx ->
          let body = getBody ctx
          Assert.Equal(expected, body)
  
  [<Fact>]
  let ``POST "/post/2" returns "2"`` () =
      let app = 
          choose [
              GET >>= choose [ 
                  route "/"     >>= text "Hello World"
                  route "/foo"  >>= text "bar" ]
              POST >>= choose [
                  route "/post/1" >>= text "1"
                  route "/post/2" >>= text "2" ]
              setStatusCode 404 >>= text "Not found" ]
  
      ctx.Request.Method.ReturnsForAnyArgs "POST" |> ignore
      ctx.Request.Path.ReturnsForAnyArgs (PathString("/post/2")) |> ignore
      ctx.Response.Body <- new MemoryStream()
      let expected = "2"
  
      let result = 
          { HttpContext = ctx; Services = services }
          |> app
          |> Async.RunSynchronously
  
      match result with
      | None     -> assertFailf "Result was expected to be %s" expected
      | Some ctx ->
          let body = getBody ctx
          Assert.Equal(expected, body)
  
  [<Fact>]
  let ``PUT "/post/2" returns 404 "Not found"`` () =
      let app = 
          choose [
              GET >>= choose [ 
                  route "/"     >>= text "Hello World"
                  route "/foo"  >>= text "bar" ]
              POST >>= choose [
                  route "/post/1" >>= text "1"
                  route "/post/2" >>= text "2" ]
              setStatusCode 404 >>= text "Not found" ]
      
      ctx.Request.Method.ReturnsForAnyArgs "PUT" |> ignore
      ctx.Request.Path.ReturnsForAnyArgs (PathString("/post/2")) |> ignore
      ctx.Response.Body <- new MemoryStream()
      let expected = "Not found"
  
      let result = 
          { HttpContext = ctx; Services = services }
          |> app
          |> Async.RunSynchronously
  
      match result with
      | None     -> assertFailf "Result was expected to be %s" expected
      | Some ctx ->
          let body = getBody ctx
          Assert.Equal(expected, body)
          Assert.Equal(404, ctx.HttpContext.Response.StatusCode)
  
  [<Fact>]
  let ``GET "/dotLiquid" returns rendered html view`` () =
      let dotLiquidTemplate =
          "<html><head><title>DotLiquid</title></head>" + 
          "<body><p>{{ foo }} {{ bar }} is {{ age }} years old.</p>" +
          "</body></html>"
  
      let obj = { Foo = "John"; Bar = "Doe"; Age = 30 }
  
      let app = 
          choose [
              GET >>= choose [ 
                  route "/"          >>= text "Hello World"
                  route "/dotLiquid" >>= dotLiquid "text/html" dotLiquidTemplate obj ]
              POST >>= choose [
                  route "/post/1" >>= text "1" ]
              setStatusCode 404 >>= text "Not found" ]
      
      ctx.Request.Method.ReturnsForAnyArgs "GET" |> ignore
      ctx.Request.Path.ReturnsForAnyArgs (PathString("/dotLiquid")) |> ignore
      ctx.Response.Body <- new MemoryStream()
      let expected = "<html><head><title>DotLiquid</title></head><body><p>John Doe is 30 years old.</p></body></html>"
  
      let result = 
          { HttpContext = ctx; Services = services }
          |> app
          |> Async.RunSynchronously
  
      match result with
      | None     -> assertFailf "Result was expected to be %s" expected
      | Some ctx ->
          let body = getBody ctx
          Assert.Equal(expected, body)
          Assert.Equal("text/html", ctx.HttpContext.Response |> getContentType)
  
  [<Fact>]
  let ``POST "/text" with supported Accept header returns "good"`` () =
      let app = 
          choose [
              GET >>= choose [ 
                  route "/"     >>= text "Hello World"
                  route "/foo"  >>= text "bar" ]
              POST >>= choose [
                  route "/text"   >>= mustAccept [ "text/plain" ] >>= text "text"
                  route "/json"   >>= mustAccept [ "application/json" ] >>= json "json"
                  route "/either" >>= mustAccept [ "text/plain"; "application/json" ] >>= text "either" ]
              setStatusCode 404 >>= text "Not found" ]
      
      let headers = new HeaderDictionary()
      headers.Add("Accept", new StringValues("text/plain"))
      ctx.Request.Method.ReturnsForAnyArgs "POST" |> ignore
  