<commit_before>﻿module FSharp.Data.Tests.HttpIntegrationTests

open System
open System.IO
open System.Net
open System.Net.Cache
open System.Text
open NUnit.Framework
open FsUnit
open Nancy
open Nancy.Hosting.Self
open FSharp.Data

// ? operator to get values from a Nancy DynamicDictionary
let (?) (parameters:obj) param =
    (parameters :?> Nancy.DynamicDictionary).[param]
 
let config = HostConfiguration()
config.UrlReservations.CreateAutomatically <- true
let nancyHost = NancyHost(config, Uri("http://localhost:1235/TestServer/"))

let runningOnMono = Type.GetType("Mono.Runtime") <> null

[<TestFixtureSetUp>]
let fixtureSetup() =
    nancyHost.Start()

[<TestFixtureTearDown>]
let fixtureTearDown() =
    nancyHost.Stop()

[<SetUp>]
let setUp() =
    MockServer.recordedRequest := null

[<Test>]
// This needs to be run first, as the keep-alive is only set on the first call.  They seem to be run alphabetically.
let ``_connection keep-alive header is set automatically on the first request, but not subsequent ones`` () =

    Http.Request "http://localhost:1235/TestServer/RecordRequest" |> ignore
    MockServer.recordedRequest.Value |> should notEqual null
    if runningOnMono then<commit_msg>Fix warning<commit_after>﻿module FSharp.Data.Tests.HttpIntegrationTests

open System
open System.IO
open System.Net
open System.Net.Cache
open System.Text
open NUnit.Framework
open FsUnit
open Nancy
open Nancy.Hosting.Self
open FSharp.Data

// ? operator to get values from a Nancy DynamicDictionary
let (?) (parameters:obj) param =
    (parameters :?> Nancy.DynamicDictionary).[param]
 
let config = HostConfiguration()
config.UrlReservations.CreateAutomatically <- true
use nancyHost = new NancyHost(config, Uri("http://localhost:1235/TestServer/"))

let runningOnMono = Type.GetType("Mono.Runtime") <> null

[<TestFixtureSetUp>]
let fixtureSetup() =
    nancyHost.Start()

[<TestFixtureTearDown>]
let fixtureTearDown() =
    nancyHost.Stop()

[<SetUp>]
let setUp() =
    MockServer.recordedRequest := null

[<Test>]
// This needs to be run first, as the keep-alive is only set on the first call.  They seem to be run alphabetically.
let ``_connection keep-alive header is set automatically on the first request, but not subsequent ones`` () =

    Http.Request "http://localhost:1235/TestServer/RecordRequest" |> ignore
    MockServer.recordedRequest.Value |> should notEqual null
    if runningOnMono then
{'fraction_non_alphanumeric': 0.10678807947019868, 'fraction_numerical': 0.006622516556291391, 'mean_word_length': 4.796163069544365, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7550615', 'n_tokens_mistral': 751, 'n_tokens_neox': 720, 'n_words': 219}