Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FsCheck" Version="2.14.0" />
<PackageReference Include="FsCheck.NUnit" Version="2.14.0" />
<PackageReference Include="nunit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="FsCheck" Version="3.3.0" />
<PackageReference Include="FsCheck.NUnit" Version="3.3.0" />
<PackageReference Include="nunit" Version="4.3.2" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
</ItemGroup>

Expand Down
12 changes: 6 additions & 6 deletions tests/Elasticsearch.FSharp.Tests/Mapping.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ open NUnit.Framework

open Elasticsearch.FSharp.Mapping.Attributes
open Elasticsearch.FSharp.Mapping.Json
open NUnit.Framework.Legacy

[<ElasticType("custom_entity_name")>]
type TestEntity = {
Expand Down Expand Up @@ -63,7 +64,7 @@ let ``Type serializes correctly``() =
}
}"""
let actual = mappingJson
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``Type serializes correctly with excluded type name``() =
Expand All @@ -90,7 +91,7 @@ let ``Type serializes correctly with excluded type name``() =
}
}"""
let actual = mappingJson
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``Type serializes correctly with settings``() =
Expand Down Expand Up @@ -132,7 +133,7 @@ let ``Type serializes correctly with settings``() =
}
}"""
let actual = mappingJson
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``Type serializes correctly to put mappings json``() =
Expand Down Expand Up @@ -221,8 +222,7 @@ let ``Recursive type serializes correctly``() =
}
}"""
let actual = mappingJson
printf "%s" mappingJson
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``Custom field name serializes correctly``() =
Expand Down Expand Up @@ -254,4 +254,4 @@ let ``Custom field name serializes correctly``() =
}
}"""
let actual = mappingJson
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))
14 changes: 7 additions & 7 deletions tests/Elasticsearch.FSharp.Tests/Queries/BoolQueryTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let ``"bool" with "must" serializes correctly``() =
]
let expected = """{"query":{"bool":{"must":[{"match_all":{}}]}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``"bool" with "filter" serializes correctly``() =
Expand All @@ -36,7 +36,7 @@ let ``"bool" with "filter" serializes correctly``() =
]
let expected = """{"query":{"bool":{"filter":[{"term":{"field":{"value":"value"}}}]}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``"bool" with "should" serializes correctly``() =
Expand All @@ -52,7 +52,7 @@ let ``"bool" with "should" serializes correctly``() =
]
let expected = """{"query":{"bool":{"should":[{"match":{"field":{"query":"value"}}}]}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``"bool" with "must_not" serializes correctly``() =
Expand All @@ -68,10 +68,10 @@ let ``"bool" with "must_not" serializes correctly``() =
]
let expected = """{"query":{"bool":{"must_not":[{"range":{"field":{"gte":"10"}}}]}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``"bool" with "minimum_should_match" serializes correctly`` =
let ``"bool" with "minimum_should_match" serializes correctly``() =
let msm = "1.0"

let query =
Expand All @@ -85,7 +85,7 @@ let ``"bool" with "minimum_should_match" serializes correctly`` =
]
let expected = sprintf """{"query":{"bool":{"should":[{"match_all":{}}],"minimum_should_match":"%s"}}}""" (Json.escapeString msm)
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``"bool" with multiple clauses serializes correctly``() =
Expand All @@ -103,4 +103,4 @@ let ``"bool" with multiple clauses serializes correctly``() =
]
let expected = """{"query":{"bool":{"must":[{"match":{"title":{"query":"elasticsearch"}}}],"filter":[{"term":{"status":{"value":"published"}}}],"must_not":[{"term":{"tags":{"value":"archived"}}}],"should":[{"match":{"content":{"query":"relevant"}}}],"minimum_should_match":"1"}}}"""
let actual = toJson query
Assert.AreEqual(removeWhitespace expected, removeWhitespace actual)
Assert.That(removeWhitespace actual, Is.EqualTo(removeWhitespace expected))
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ let ``"exists" serialization works correctly``(fieldName) =
]
let expected = sprintf """{"query":{"exists":{"field":"%s"}}}""" (Json.escapeString fieldName)
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))
3 changes: 1 addition & 2 deletions tests/Elasticsearch.FSharp.Tests/Queries/IdsQueryTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Elasticsearch.FSharp.Tests.Queries.IdsQueryTests
open NUnit.Framework
open Elasticsearch.FSharp.DSL
open Elasticsearch.FSharp.DSL.Serialization
open Elasticsearch.FSharp.Utility

[<Test>]
let ``"ids" serializes correctly``() =
Expand All @@ -13,4 +12,4 @@ let ``"ids" serializes correctly``() =
]
let expected = """{"query":{"ids":{"values":["foo","bar"]}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ let ``"match_all" serializes correctly``() =
]
let expected = """{"query":{"match_all":{}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ let ``"match_none" serializes correctly``() =
]
let expected = """{"query":{"match_none":{}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let ``"match_phrase_prefix" base serializes correctly`` (fieldName, fieldValue,
let expected = sprintf """{"query":{"match_phrase_prefix":{"%s":{"query":"%s","max_expansions":%d}}}}"""
(Json.escapeString fieldName) (Json.escapeString fieldValue) expansions
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Property>]
let ``"match_phrase_prefix" with boost serializes correctly`` (fieldName, fieldValue, expansions : int, boostValue: float) =
Expand All @@ -44,7 +44,7 @@ let ``"match_phrase_prefix" with boost serializes correctly`` (fieldName, fieldV
let expected = sprintf """{"query":{"match_phrase_prefix":{"%s":{"query":"%s","max_expansions":%d,"boost":%s}}}}"""
(Json.escapeString fieldName) (Json.escapeString fieldValue) expansions (boost.ToString())
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Property>]
let ``"match_phrase_prefix" with slop serializes correctly`` (fieldName, fieldValue, slopVal: int) =
Expand All @@ -62,7 +62,7 @@ let ``"match_phrase_prefix" with slop serializes correctly`` (fieldName, fieldVa
]
let expected = sprintf """{"query":{"match_phrase_prefix":{"%s":{"query":"%s","slop":%d}}}}"""
(Json.escapeString fieldName) (Json.escapeString fieldValue) slopVal
Assert.AreEqual(expected, toJson query)
Assert.That(toJson query, Is.EqualTo(expected))

[<Property>]
let ``"match_phrase_prefix" with analyzer serializes correctly`` (fieldName, fieldValue, analyzerName) =
Expand All @@ -80,7 +80,7 @@ let ``"match_phrase_prefix" with analyzer serializes correctly`` (fieldName, fie
]
let expected = sprintf """{"query":{"match_phrase_prefix":{"%s":{"query":"%s","analyzer":"%s"}}}}"""
(Json.escapeString fieldName) (Json.escapeString fieldValue) (Json.escapeString analyzerName)
Assert.AreEqual(expected, toJson query)
Assert.That(toJson query, Is.EqualTo(expected))

[<Test>]
let ``"match_phrase_prefix" with all fields serializes correctly`` () =
Expand All @@ -107,4 +107,4 @@ let ``"match_phrase_prefix" with all fields serializes correctly`` () =
]
let expected = sprintf """{"query":{"match_phrase_prefix":{"%s":{"query":"%s","max_expansions":%d,"slop":%d,"analyzer":"%s","boost":%s}}}}"""
(Json.escapeString fieldName) (Json.escapeString fieldValue) maxExp slopVal (Json.escapeString analyzerName) (boostVal.ToString())
Assert.AreEqual(expected, toJson query)
Assert.That(toJson query, Is.EqualTo(expected))
11 changes: 5 additions & 6 deletions tests/Elasticsearch.FSharp.Tests/Queries/MatchQueryTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ open FsCheck.NUnit
open Elasticsearch.FSharp.DSL
open Elasticsearch.FSharp.DSL.Serialization
open Elasticsearch.FSharp.Utility
open Elasticsearch.FSharp.Tests.Helpers

[<Property>]
let ``"match" base serializes correctly``(fieldName, fieldValue) =
Expand All @@ -18,7 +17,7 @@ let ``"match" base serializes correctly``(fieldName, fieldValue) =
let expected = sprintf """{"query":{"match":{"%s":{"query":"%s"}}}}"""
(Json.escapeString fieldName) (Json.escapeString fieldValue)
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Property>]
let ``"match" with operator serializes correctly``(fieldName, fieldValue, op) =
Expand All @@ -31,7 +30,7 @@ let ``"match" with operator serializes correctly``(fieldName, fieldValue, op) =
let expected = sprintf """{"query":{"match":{"%s":{"query":"%s","operator":"%s"}}}}"""
(Json.escapeString fieldName) (Json.escapeString fieldValue) (Json.escapeString op)
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Property>]
let ``"match" with zero_terms_query serializes correctly (current behavior)``(fieldName, fieldValue) =
Expand All @@ -49,7 +48,7 @@ let ``"match" with zero_terms_query serializes correctly (current behavior)``(fi
let expected = sprintf """{"query":{"match":{"%s":{"query":"%s","zero_terms_query":%s}}}}"""
(Json.escapeString fieldName) (Json.escapeString fieldValue) zeroTerms // zeroTerms is not quoted here
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Property>]
let ``"match" with cutoff_frequency serializes correctly``(fieldName, fieldValue, cutoff: float) =
Expand All @@ -63,7 +62,7 @@ let ``"match" with cutoff_frequency serializes correctly``(fieldName, fieldValue
let expected = sprintf """{"query":{"match":{"%s":{"query":"%s","cutoff_frequency":%s}}}}"""
(Json.escapeString fieldName) (Json.escapeString fieldValue) cutoffStr
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``"match" with all fields serializes correctly (current behavior)``() =
Expand All @@ -86,4 +85,4 @@ let ``"match" with all fields serializes correctly (current behavior)``() =
let expected = sprintf """{"query":{"match":{"%s":{"query":"%s","operator":"%s","zero_terms_query":%s,"cutoff_frequency":%s}}}}"""
(Json.escapeString fieldName) (Json.escapeString fieldValue) (Json.escapeString op) zeroTerms (cutoff.ToString())
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ open FsCheck.NUnit
open Elasticsearch.FSharp.DSL
open Elasticsearch.FSharp.DSL.Serialization
open Elasticsearch.FSharp.Utility
open Elasticsearch.FSharp.Tests.Helpers

[<Property>]
// TODO don't know how to specify range for tie_breaker value (by default values from -Infinity to Infinity are generated)
Expand All @@ -26,7 +25,7 @@ let ``"multi_match" base serializes correctly``(queryType, field, queryString, e
let expected = sprintf """{"query":{"multi_match":{"type":"%s","fields":["%s"],"query":"%s","max_expansions":%d,"slop":%d,"tie_breaker":0.3}}}"""
(Json.escapeString queryType) (Json.escapeString field) (Json.escapeString queryString) expansions slop
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``"multi_match" with raw string param serializes correctly``() =
Expand All @@ -40,7 +39,7 @@ let ``"multi_match" with raw string param serializes correctly``() =
)
]
let expected = """{"query":{"multi_match":{"query":"search text","custom_param":"custom_value"}}}"""
Assert.AreEqual(expected, (toJson query))
Assert.That(toJson query, Is.EqualTo(expected))

[<Test>]
let ``"multi_match" with raw numeric param serializes correctly``() =
Expand All @@ -54,4 +53,4 @@ let ``"multi_match" with raw numeric param serializes correctly``() =
)
]
let expected = """{"query":{"multi_match":{"query":"search text","custom_param":123.45}}}"""
Assert.AreEqual(expected, (toJson query))
Assert.That(toJson query, Is.EqualTo(expected))
12 changes: 5 additions & 7 deletions tests/Elasticsearch.FSharp.Tests/Queries/NestedQueryTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module Elasticsearch.FSharp.Tests.Queries.NestedQueryTests
open NUnit.Framework
open Elasticsearch.FSharp.DSL
open Elasticsearch.FSharp.DSL.Serialization
open Elasticsearch.FSharp.Utility
open Elasticsearch.FSharp.Tests.Helpers

[<Test>]
let ``"nested" query basic serializes correctly``() =
Expand All @@ -21,7 +19,7 @@ let ``"nested" query basic serializes correctly``() =
]
let expected = """{"query":{"nested":{"path":"obj1","query":{"match":{"obj1.name":{"query":"blue"}}}}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``"nested" query with score_mode serializes correctly``() =
Expand All @@ -37,7 +35,7 @@ let ``"nested" query with score_mode serializes correctly``() =
]
let expected = """{"query":{"nested":{"path":"obj1","query":{"match_all":{}},"score_mode":"max"}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``"nested" query with ignore_unmapped serializes correctly``() =
Expand All @@ -53,7 +51,7 @@ let ``"nested" query with ignore_unmapped serializes correctly``() =
]
let expected = """{"query":{"nested":{"path":"obj1","query":{"match_all":{}},"ignore_unmapped":true}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``"nested" query with all options serializes correctly``() =
Expand All @@ -74,7 +72,7 @@ let ``"nested" query with all options serializes correctly``() =
]
let expected = """{"query":{"nested":{"path":"obj1.child","query":{"bool":{"must":[{"term":{"obj1.child.field":{"value":"value"}}}]}},"score_mode":"sum","ignore_unmapped":false}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
let ``"nested" query multi-level serializes correctly``() =
Expand All @@ -101,4 +99,4 @@ let ``"nested" query multi-level serializes correctly``() =
]
let expected = """{"query":{"nested":{"path":"driver","query":{"nested":{"path":"driver.vehicle","query":{"bool":{"must":[{"match":{"driver.vehicle.make":{"query":"Powell Motors"}}},{"match":{"driver.vehicle.model":{"query":"Canyonero"}}}]}}}}}}}"""
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ open FsCheck.NUnit
open Elasticsearch.FSharp.DSL
open Elasticsearch.FSharp.DSL.Serialization
open Elasticsearch.FSharp.Utility
open Elasticsearch.FSharp.Tests.Helpers

[<Property>]
let ``"script" query serializes correctly``(scriptSource, lang) =
Expand All @@ -21,7 +20,7 @@ let ``"script" query serializes correctly``(scriptSource, lang) =
let expected = sprintf """{"query":{"script":{"script":{"source":"%s","lang":"%s"}}}}"""
(Json.escapeString scriptSource) (Json.escapeString lang)
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))

[<Property>]
let ``"script" query with params serializes correctly``(scriptSource, lang, pName, pValue) =
Expand All @@ -38,4 +37,4 @@ let ``"script" query with params serializes correctly``(scriptSource, lang, pNam
let expected = sprintf """{"query":{"script":{"script":{"source":"%s","lang":"%s","params":{"%s":"%s"}}}}}"""
(Json.escapeString scriptSource) (Json.escapeString lang) (Json.escapeString pName) (Json.escapeString pValue)
let actual = toJson query
Assert.AreEqual(expected, actual)
Assert.That(actual, Is.EqualTo(expected))
Loading
Loading