<commit_before>module Neo4jClient.FsQuotations.Tests

open System
open NUnit.Framework
open Neo4jClient
open Neo4jClient.FsQuotations

let neo4jClient =
    let client = new GraphClient(Uri("http://localhost:7474/db/data"), "neo4j", "<PASSWORD>")
    client.Connect()
    client

[<SetUp>]
let setupDbWithTestData () = initDbWithTestData neo4jClient

[<Test>]
let ``Get all nodes with specific label`` () =
    let query =
        <@
        let u = declareNode<UserNode>
        matchNode u
        returnResults u
        @>

    let results =
        query
        |> executeReadQuery neo4jClient.Cypher
        |> Seq.map (fun user -> user.FacebookId)
        |> Set.ofSeq

    Assert.AreEqual(
        set [ "Denis"; "TT"; "Opwal"; "Chouchou" ],
        results,
        "Get all user nodes")

[<Test>]
let ``MATCH-WHERE-RETURN with equality`` () =
    let query =
        <@
        let u = declareNode<UserNode>
        matchNode u
        where (u.FacebookId = "Denis")
        returnResults u
        @>

    let results =
        query
        |> executeReadQuery neo4jClient.Cypher
        |> Seq.map (fun user -> user.FacebookId)
        |> Seq.toArray

    Assert.AreEqual(1, results.Length, "Number of results")
    Assert.AreEqual("Denis", results.[0], "Facebook ID")<commit_msg>New test for matchRelation expression<commit_after>module Neo4jClient.FsQuotations.Tests

open System
open NUnit.Framework
open Neo4jClient
open Neo4jClient.FsQuotations

let neo4jClient =
    let client = new GraphClient(Uri("http://localhost:7474/db/data"), "neo4j", "<PASSWORD>")
    client.Connect()
    client

[<SetUp>]
let setupDbWithTestData () = initDbWithTestData neo4jClient

[<Test>]
let ``Get all nodes with specific label`` () =
    let query =
        <@
        let u = declareNode<UserNode>
        matchNode u
        returnResults u
        @>

    let results =
        query
        |> executeReadQuery neo4jClient.Cypher
        |> Seq.map (fun user -> user.FacebookId)
        |> Set.ofSeq

    Assert.AreEqual(
        set [ "Denis"; "TT"; "Opwal"; "Chouchou" ],
        results,
        "Get all user nodes")

[<Test>]
let ``MATCH-WHERE-RETURN with equality`` () =
    let query =
        <@
        let u = declareNode<UserNode>
        matchNode u
        where (u.FacebookId = "Denis")
        returnResults u
        @>

    let results =
        query
        |> executeReadQuery neo4jClient.Cypher
        |> Seq.map (fun user -> user.FacebookId)
        |> Seq.toArray

    Assert.AreEqual(1, results.Length, "Number of results")
    Assert.AreEqual("Denis", results.[0], "Facebook ID")

[<Test>]
let ``match relations`` () =
    let query =
        <@
        let user = declareNode<UserNode>
        let household = declareNode<HouseholdNode>
        matchRelation user declareRelationship<IsResidentOf> household
        returnResults (user, household)
        @>

    let results =
        query
        |> executeReadQuery neo4jClient.Cypher
        |> Seq.toArray

    Assert.AreEqual(1, results.Length, "Number of results")
{'fraction_non_alphanumeric': 0.11518324607329843, 'fraction_numerical': 0.00981675392670157, 'mean_word_length': 2.4194630872483223, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4660705', 'n_tokens_mistral': 1000, 'n_tokens_neox': 941, 'n_words': 231}