From facf8a1c4008dd78b2a6f1fc2bc32543aae34d28 Mon Sep 17 00:00:00 2001 From: BorisDog Date: Fri, 18 Nov 2022 10:45:19 -0800 Subject: [PATCH 01/21] - Search text operator --- src/MongoDB.Driver.Core/Core/Misc/Ensure.cs | 101 +++++------ src/MongoDB.Driver/AggregateFluent.cs | 17 +- src/MongoDB.Driver/AggregateFluentBase.cs | 12 ++ src/MongoDB.Driver/Builders.cs | 61 +++---- src/MongoDB.Driver/IAggregateFluent.cs | 20 +++ src/MongoDB.Driver/Linq/MongoQueryable.cs | 28 +++ src/MongoDB.Driver/MongoUtils.cs | 5 +- .../PipelineDefinitionBuilder.cs | 30 ++++ .../PipelineStageDefinitionBuilder.cs | 42 ++++- src/MongoDB.Driver/Search/FuzzyOptions.cs | 66 +++++++ src/MongoDB.Driver/Search/HighlightOptions.cs | 74 ++++++++ .../Search/HighlightOptionsBuilder.cs | 70 ++++++++ src/MongoDB.Driver/Search/PathDefinition.cs | 90 ++++++++++ .../Search/PathDefinitionBuilder.cs | 165 ++++++++++++++++++ src/MongoDB.Driver/Search/QueryDefinition.cs | 102 +++++++++++ src/MongoDB.Driver/Search/ScoreDefinition.cs | 34 ++++ .../Search/ScoreDefinitionBuilder.cs | 134 ++++++++++++++ .../Search/SearchCountOptions.cs | 54 ++++++ src/MongoDB.Driver/Search/SearchCountType.cs | 32 ++++ src/MongoDB.Driver/Search/SearchDefinition.cs | 105 +++++++++++ .../Search/SearchDefinitionBuilder.cs | 97 ++++++++++ .../Search/SearchDefinitionBuilderTests.cs | 155 ++++++++++++++++ 22 files changed, 1399 insertions(+), 95 deletions(-) create mode 100644 src/MongoDB.Driver/Search/FuzzyOptions.cs create mode 100644 src/MongoDB.Driver/Search/HighlightOptions.cs create mode 100644 src/MongoDB.Driver/Search/HighlightOptionsBuilder.cs create mode 100644 src/MongoDB.Driver/Search/PathDefinition.cs create mode 100644 src/MongoDB.Driver/Search/PathDefinitionBuilder.cs create mode 100644 src/MongoDB.Driver/Search/QueryDefinition.cs create mode 100644 src/MongoDB.Driver/Search/ScoreDefinition.cs create mode 100644 src/MongoDB.Driver/Search/ScoreDefinitionBuilder.cs create mode 100644 src/MongoDB.Driver/Search/SearchCountOptions.cs create mode 100644 src/MongoDB.Driver/Search/SearchCountType.cs create mode 100644 src/MongoDB.Driver/Search/SearchDefinition.cs create mode 100644 src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs create mode 100644 tests/MongoDB.Driver.Tests/Search/SearchDefinitionBuilderTests.cs diff --git a/src/MongoDB.Driver.Core/Core/Misc/Ensure.cs b/src/MongoDB.Driver.Core/Core/Misc/Ensure.cs index 9d9def7ebe4..3e91cb84a28 100644 --- a/src/MongoDB.Driver.Core/Core/Misc/Ensure.cs +++ b/src/MongoDB.Driver.Core/Core/Misc/Ensure.cs @@ -83,16 +83,18 @@ public static T IsEqualTo(T value, T comparand, string paramName) } /// - /// Ensures that the value of a parameter is greater than or equal to zero. + /// Ensures that the value of a parameter is greater than a comparand. /// + /// Type type of the value. /// The value of the parameter. + /// The comparand. /// The name of the parameter. /// The value of the parameter. - public static int IsGreaterThanOrEqualToZero(int value, string paramName) + public static T IsGreaterThan(T value, T comparand, string paramName) where T : IComparable { - if (value < 0) + if (value.CompareTo(comparand) <= 0) { - var message = string.Format("Value is not greater than or equal to 0: {0}.", value); + var message = $"Value is not greater than {comparand}: {value}."; throw new ArgumentOutOfRangeException(paramName, message); } return value; @@ -104,15 +106,8 @@ public static int IsGreaterThanOrEqualToZero(int value, string paramName) /// The value of the parameter. /// The name of the parameter. /// The value of the parameter. - public static long IsGreaterThanOrEqualToZero(long value, string paramName) - { - if (value < 0) - { - var message = string.Format("Value is not greater than or equal to 0: {0}.", value); - throw new ArgumentOutOfRangeException(paramName, message); - } - return value; - } + public static int IsGreaterThanOrEqualToZero(int value, string paramName) => + IsGreaterThanOrEqualTo(value, 0, paramName); /// /// Ensures that the value of a parameter is greater than or equal to zero. @@ -120,15 +115,17 @@ public static long IsGreaterThanOrEqualToZero(long value, string paramName) /// The value of the parameter. /// The name of the parameter. /// The value of the parameter. - public static TimeSpan IsGreaterThanOrEqualToZero(TimeSpan value, string paramName) - { - if (value < TimeSpan.Zero) - { - var message = string.Format("Value is not greater than or equal to zero: {0}.", TimeSpanParser.ToString(value)); - throw new ArgumentOutOfRangeException(paramName, message); - } - return value; - } + public static long IsGreaterThanOrEqualToZero(long value, string paramName) => + IsGreaterThanOrEqualTo(value, 0, paramName); + + /// + /// Ensures that the value of a parameter is greater than or equal to zero. + /// + /// The value of the parameter. + /// The name of the parameter. + /// The value of the parameter. + public static TimeSpan IsGreaterThanOrEqualToZero(TimeSpan value, string paramName) => + IsGreaterThanOrEqualTo(value, TimeSpan.Zero, paramName); /// /// Ensures that the value of a parameter is greater than zero. @@ -136,15 +133,8 @@ public static TimeSpan IsGreaterThanOrEqualToZero(TimeSpan value, string paramNa /// The value of the parameter. /// The name of the parameter. /// The value of the parameter. - public static int IsGreaterThanZero(int value, string paramName) - { - if (value <= 0) - { - var message = string.Format("Value is not greater than zero: {0}.", value); - throw new ArgumentOutOfRangeException(paramName, message); - } - return value; - } + public static int IsGreaterThanZero(int value, string paramName) => + IsGreaterThan(value, 0, paramName); /// /// Ensures that the value of a parameter is greater than zero. @@ -152,15 +142,8 @@ public static int IsGreaterThanZero(int value, string paramName) /// The value of the parameter. /// The name of the parameter. /// The value of the parameter. - public static long IsGreaterThanZero(long value, string paramName) - { - if (value <= 0) - { - var message = string.Format("Value is not greater than zero: {0}.", value); - throw new ArgumentOutOfRangeException(paramName, message); - } - return value; - } + public static long IsGreaterThanZero(long value, string paramName) => + IsGreaterThan(value, 0, paramName); /// /// Ensures that the value of a parameter is greater than zero. @@ -168,15 +151,17 @@ public static long IsGreaterThanZero(long value, string paramName) /// The value of the parameter. /// The name of the parameter. /// The value of the parameter. - public static TimeSpan IsGreaterThanZero(TimeSpan value, string paramName) - { - if (value <= TimeSpan.Zero) - { - var message = string.Format("Value is not greater than zero: {0}.", value); - throw new ArgumentOutOfRangeException(paramName, message); - } - return value; - } + public static double IsGreaterThanZero(double value, string paramName) => + IsGreaterThan(value, 0, paramName); + + /// + /// Ensures that the value of a parameter is greater than zero. + /// + /// The value of the parameter. + /// The name of the parameter. + /// The value of the parameter. + public static TimeSpan IsGreaterThanZero(TimeSpan value, string paramName) => + IsGreaterThan(value, TimeSpan.Zero, paramName); /// /// Ensures that the value of a parameter is infinite or greater than or equal to zero. @@ -298,6 +283,24 @@ public static string IsNotNullOrEmpty(string value, string paramName) return value; } + /// + /// Ensures that the value of a parameter is null or is between a minimum and a maximum value. + /// + /// Type type of the value. + /// The value of the parameter. + /// The minimum value. + /// The maximum value. + /// The name of the parameter. + /// The value of the parameter. + public static T? IsNullOrBetween(T? value, T min, T max, string paramName) where T : struct, IComparable + { + if (value != null) + { + IsBetween(value.Value, min, max, paramName); + } + return value; + } + /// /// Ensures that the value of a parameter is null or greater than or equal to zero. /// diff --git a/src/MongoDB.Driver/AggregateFluent.cs b/src/MongoDB.Driver/AggregateFluent.cs index 6479c61822c..a03a75f7e81 100644 --- a/src/MongoDB.Driver/AggregateFluent.cs +++ b/src/MongoDB.Driver/AggregateFluent.cs @@ -13,13 +13,14 @@ * limitations under the License. */ -using MongoDB.Bson; -using MongoDB.Bson.Serialization; -using MongoDB.Driver.Core.Misc; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; +using MongoDB.Driver.Search; namespace MongoDB.Driver { @@ -238,6 +239,16 @@ public override IAggregateFluent ReplaceWith(AggregateEx return WithPipeline(_pipeline.ReplaceWith(newRoot)); } + public override IAggregateFluent Search( + SearchDefinition query, + HighlightOptions highlight = null, + string indexName = null, + SearchCountOptions count = null, + bool returnStoredSource = false) + { + return WithPipeline(_pipeline.Search(query, highlight, indexName, count, returnStoredSource)); + } + public override IAggregateFluent SetWindowFields( AggregateExpressionDefinition, TWindowFields> output) { diff --git a/src/MongoDB.Driver/AggregateFluentBase.cs b/src/MongoDB.Driver/AggregateFluentBase.cs index 2393da49074..9223eccd87e 100644 --- a/src/MongoDB.Driver/AggregateFluentBase.cs +++ b/src/MongoDB.Driver/AggregateFluentBase.cs @@ -19,6 +19,7 @@ using System.Threading.Tasks; using MongoDB.Bson; using MongoDB.Bson.Serialization; +using MongoDB.Driver.Search; namespace MongoDB.Driver { @@ -215,6 +216,17 @@ public virtual IAggregateFluent ReplaceWith(AggregateExp throw new NotImplementedException(); } + /// + public virtual IAggregateFluent Search( + SearchDefinition query, + HighlightOptions highlight = null, + string indexName = null, + SearchCountOptions count = null, + bool returnStoredSource = false) + { + throw new NotImplementedException(); + } + /// public virtual IAggregateFluent SetWindowFields( AggregateExpressionDefinition, TWindowFields> output) diff --git a/src/MongoDB.Driver/Builders.cs b/src/MongoDB.Driver/Builders.cs index 2748d915ce5..b339da7644f 100644 --- a/src/MongoDB.Driver/Builders.cs +++ b/src/MongoDB.Driver/Builders.cs @@ -13,6 +13,8 @@ * limitations under the License. */ +using MongoDB.Driver.Search; + namespace MongoDB.Driver { /// @@ -21,50 +23,29 @@ namespace MongoDB.Driver /// The type of the document. public static class Builders { - private static FilterDefinitionBuilder __filter = new FilterDefinitionBuilder(); - private static IndexKeysDefinitionBuilder __index = new IndexKeysDefinitionBuilder(); - private static ProjectionDefinitionBuilder __projection = new ProjectionDefinitionBuilder(); - private static SortDefinitionBuilder __sort = new SortDefinitionBuilder(); - private static UpdateDefinitionBuilder __update = new UpdateDefinitionBuilder(); + /// Gets a . + public static FilterDefinitionBuilder Filter { get; } = new FilterDefinitionBuilder(); + + /// Gets an . + public static IndexKeysDefinitionBuilder IndexKeys { get; } = new IndexKeysDefinitionBuilder(); + + /// Gets a . + public static ProjectionDefinitionBuilder Projection { get; } = new ProjectionDefinitionBuilder(); - /// - /// Gets a . - /// - public static FilterDefinitionBuilder Filter - { - get { return __filter; } - } + /// Gets a . + public static SortDefinitionBuilder Sort { get; } = new SortDefinitionBuilder(); - /// - /// Gets an . - /// - public static IndexKeysDefinitionBuilder IndexKeys - { - get { return __index; } - } + /// Gets an . + public static UpdateDefinitionBuilder Update { get; } = new UpdateDefinitionBuilder(); - /// - /// Gets a . - /// - public static ProjectionDefinitionBuilder Projection - { - get { return __projection; } - } + // Search builders + /// Gets a . + public static PathDefinitionBuilder Path { get; } = new PathDefinitionBuilder(); - /// - /// Gets a . - /// - public static SortDefinitionBuilder Sort - { - get { return __sort; } - } + /// Gets a . + public static ScoreDefinitionBuilder Score { get; } = new ScoreDefinitionBuilder(); - /// - /// Gets an . - /// - public static UpdateDefinitionBuilder Update - { - get { return __update; } - } + /// Gets a . + public static SearchDefinitionBuilder Search { get; } = new SearchDefinitionBuilder(); } } diff --git a/src/MongoDB.Driver/IAggregateFluent.cs b/src/MongoDB.Driver/IAggregateFluent.cs index 703dba4956d..7ba11536235 100644 --- a/src/MongoDB.Driver/IAggregateFluent.cs +++ b/src/MongoDB.Driver/IAggregateFluent.cs @@ -19,6 +19,7 @@ using System.Threading.Tasks; using MongoDB.Bson; using MongoDB.Bson.Serialization; +using MongoDB.Driver.Search; namespace MongoDB.Driver { @@ -353,6 +354,25 @@ public interface IAggregateFluent : IAsyncCursorSource IAggregateFluent SetWindowFields( AggregateExpressionDefinition, TWindowFields> output); + /// + /// Appends a $search stage to the pipeline. + /// + /// The search definition. + /// The highlight options. + /// The index name. + /// The count options. + /// + /// Flag that specifies whether to perform a full document lookup on the backend database + /// or return only stored source fields directly from Atlas Search. + /// + /// The fluent aggregate interface. + IAggregateFluent Search( + SearchDefinition query, + HighlightOptions highlight = null, + string indexName = null, + SearchCountOptions count = null, + bool returnStoredSource = false); + /// /// Appends a $setWindowFields to the pipeline. /// diff --git a/src/MongoDB.Driver/Linq/MongoQueryable.cs b/src/MongoDB.Driver/Linq/MongoQueryable.cs index 6a25addf77b..8f3fd2f1503 100644 --- a/src/MongoDB.Driver/Linq/MongoQueryable.cs +++ b/src/MongoDB.Driver/Linq/MongoQueryable.cs @@ -21,6 +21,7 @@ using System.Threading; using System.Threading.Tasks; using MongoDB.Bson.Serialization; +using MongoDB.Driver.Search; namespace MongoDB.Driver.Linq { @@ -923,6 +924,33 @@ public static IMongoQueryable Sample(this IMongoQueryable + /// Appends a $search stage to the LINQ pipeline + /// + /// The type of the elements of . + /// A sequence of values. + /// The search definition. + /// The highlight options. + /// The index name. + /// The count options. + /// + /// Flag that specifies whether to perform a full document lookup on the backend database + /// or return only stored source fields directly from Atlas Search. + /// + /// The fluent aggregate interface. + public static IMongoQueryable Search( + this IMongoQueryable source, + SearchDefinition searchDefinition, + HighlightOptions highlight = null, + string indexName = null, + SearchCountOptions count = null, + bool returnStoredSource = false) + { + return AppendStage( + source, + PipelineStageDefinitionBuilder.Search(searchDefinition, highlight, indexName, count, returnStoredSource)); + } + /// /// Projects each element of a sequence into a new form by incorporating the /// element's index. diff --git a/src/MongoDB.Driver/MongoUtils.cs b/src/MongoDB.Driver/MongoUtils.cs index 60cff0bcb9a..43717b4dfc9 100644 --- a/src/MongoDB.Driver/MongoUtils.cs +++ b/src/MongoDB.Driver/MongoUtils.cs @@ -14,8 +14,6 @@ */ using System; -using System.Runtime.InteropServices; -using System.Security; using System.Security.Cryptography; using System.Text; using MongoDB.Bson; @@ -61,5 +59,8 @@ public static string ToCamelCase(string value) { return value.Length == 0 ? "" : value.Substring(0, 1).ToLower() + value.Substring(1); } + + internal static string ToCamelCase(this TEnum @enum) where TEnum : Enum => + ToCamelCase(@enum.ToString()); } } diff --git a/src/MongoDB.Driver/PipelineDefinitionBuilder.cs b/src/MongoDB.Driver/PipelineDefinitionBuilder.cs index 7ece8ab2363..c4ecef2b701 100644 --- a/src/MongoDB.Driver/PipelineDefinitionBuilder.cs +++ b/src/MongoDB.Driver/PipelineDefinitionBuilder.cs @@ -21,6 +21,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Linq; +using MongoDB.Driver.Search; namespace MongoDB.Driver { @@ -1162,6 +1163,35 @@ public static class PipelineDefinitionBuilder return pipeline.AppendStage(PipelineStageDefinitionBuilder.ReplaceWith(newRoot, translationOptions)); } + /// + /// Appends a $search stage to the pipeline. + /// + /// The type of the input documents. + /// The type of the output documents. + /// The pipeline. + /// The search definition. + /// The highlight options. + /// The index name. + /// The count options. + /// + /// Flag that specifies whether to perform a full document lookup on the backend database + /// or return only stored source fields directly from Atlas Search. + /// + /// + /// A new pipeline with an additional stage. + /// + public static PipelineDefinition Search( + this PipelineDefinition pipeline, + SearchDefinition searchDefinition, + HighlightOptions highlight = null, + string indexName = null, + SearchCountOptions count = null, + bool returnStoredSource = false) + { + Ensure.IsNotNull(pipeline, nameof(pipeline)); + return pipeline.AppendStage(PipelineStageDefinitionBuilder.Search(searchDefinition, highlight, indexName, count, returnStoredSource)); + } + /// /// Create a $setWindowFields stage. /// diff --git a/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs b/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs index 4ef2c53d80a..78477da9fa6 100644 --- a/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs +++ b/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs @@ -22,9 +22,9 @@ using MongoDB.Bson.Serialization; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Linq; -using MongoDB.Driver.Linq.Linq3Implementation.Misc; using MongoDB.Driver.Linq.Linq3Implementation.Serializers; using MongoDB.Driver.Linq.Linq3Implementation.Translators; +using MongoDB.Driver.Search; namespace MongoDB.Driver { @@ -1309,6 +1309,46 @@ public static class PipelineStageDefinitionBuilder return Project(new ProjectExpressionProjection(projection, translationOptions)); } + /// + /// Creates a $search stage. + /// + /// The type of the input documents. + /// The search definition. + /// The highlight options. + /// The index name. + /// The count options. + /// + /// Flag that specifies whether to perform a full document lookup on the backend database + /// or return only stored source fields directly from Atlas Search. + /// + /// The stage. + public static PipelineStageDefinition Search( + SearchDefinition searchDefinition, + HighlightOptions highlight = null, + string indexName = null, + SearchCountOptions count = null, + bool returnStoredSource = false) + { + Ensure.IsNotNull(searchDefinition, nameof(searchDefinition)); + + const string operatorName = "$search"; + var stage = new DelegatedPipelineStageDefinition( + operatorName, + (s, sr, linqProvider) => + { + var renderedSearchDefinition = searchDefinition.Render(s, sr); + renderedSearchDefinition.Add("highlight", () => highlight.Render(s, sr), highlight != null); + renderedSearchDefinition.Add("count", () => count.Render(), count != null); + renderedSearchDefinition.Add("index", indexName, indexName != null); + renderedSearchDefinition.Add("returnStoredSource", returnStoredSource, returnStoredSource); + + var document = new BsonDocument(operatorName, renderedSearchDefinition); + return new RenderedPipelineStageDefinition(operatorName, document, s); + }); + + return stage; + } + /// /// Creates a $replaceRoot stage. /// diff --git a/src/MongoDB.Driver/Search/FuzzyOptions.cs b/src/MongoDB.Driver/Search/FuzzyOptions.cs new file mode 100644 index 00000000000..1ad9456dade --- /dev/null +++ b/src/MongoDB.Driver/Search/FuzzyOptions.cs @@ -0,0 +1,66 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using MongoDB.Bson; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// Options for fuzzy search. + /// + public sealed class FuzzyOptions + { + private int? _maxEdits; + private int? _prefixLength; + private int? _maxExpansions; + + /// + /// Gets or sets the maximum number of single-character edits required to match the + /// specified search term. + /// + public int? MaxEdits + { + get => _maxEdits; + set => _maxEdits = Ensure.IsNullOrBetween(value, 1, 2, nameof(value)); + } + + /// + /// Gets or sets the number of characters at the beginning of each term in the result that + /// must exactly match. + /// + public int? PrefixLength + { + get => _prefixLength; + set => _prefixLength = Ensure.IsNullOrGreaterThanOrEqualToZero(value, nameof(value)); + } + + /// + /// Gets or sets the number of variations to generate and search for. + /// + public int? MaxExpansions + { + get => _maxExpansions; + set => _maxExpansions = Ensure.IsNullOrGreaterThanZero(value, nameof(value)); + } + + internal BsonDocument Render() + => new() + { + { "maxEdits", _maxEdits, _maxEdits != null }, + { "prefixLength", _prefixLength, _prefixLength != null }, + { "maxExpansions", _maxExpansions, _maxExpansions != null } + }; + } +} diff --git a/src/MongoDB.Driver/Search/HighlightOptions.cs b/src/MongoDB.Driver/Search/HighlightOptions.cs new file mode 100644 index 00000000000..1eb3b2e81b2 --- /dev/null +++ b/src/MongoDB.Driver/Search/HighlightOptions.cs @@ -0,0 +1,74 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// Options for highlighting. + /// + /// The type of the document. + public sealed class HighlightOptions + { + private PathDefinition _path; + private int? _maxCharsToExamine; + private int? _maxNumPassages; + + /// + /// Gets or sets the document field to search. + /// + public PathDefinition Path + { + get => _path; + set => _path = Ensure.IsNotNull(value, nameof(value)); + } + + /// + /// Gets or sets the maximum number of characters to examine on a document when performing + /// highlighting for a field. + /// + public int? MaxCharsToExamine + { + get => _maxCharsToExamine; + set => _maxCharsToExamine = Ensure.IsNullOrGreaterThanZero(value, nameof(value)); + } + + /// + /// Gets or sets the number of high-scoring passages to return per document in the + /// highlighting results for each field. + /// + public int? MaxNumPassages + { + get => _maxNumPassages; + set => _maxNumPassages = Ensure.IsNullOrGreaterThanZero(value, nameof(value)); + } + + /// + /// Renders the options to a . + /// + /// The document serializer. + /// The serializer registry. + /// A . + public BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) + => new() + { + { "path", _path.Render(documentSerializer, serializerRegistry) }, + { "maxCharsToExamine", _maxCharsToExamine, _maxCharsToExamine != null}, + { "maxNumPassages", _maxNumPassages, _maxNumPassages != null } + }; + } +} diff --git a/src/MongoDB.Driver/Search/HighlightOptionsBuilder.cs b/src/MongoDB.Driver/Search/HighlightOptionsBuilder.cs new file mode 100644 index 00000000000..4005a5a2945 --- /dev/null +++ b/src/MongoDB.Driver/Search/HighlightOptionsBuilder.cs @@ -0,0 +1,70 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Linq.Expressions; + +namespace MongoDB.Driver.Search +{ + /// + /// A build for highlighting options. + /// + /// The type of the document. + public sealed class HighlightOptionsBuilder + { + /// + /// Creates highlighting options. + /// + /// The document field to search. + /// + /// The maximum number of characters to examine on a document when performing highlighting + /// for a field. + /// + /// + /// The number of high-scoring passages to return per document in the highlighting results + /// for each field. + /// + /// Highlighting options. + public HighlightOptions Options( + PathDefinition path, + int? maxCharsToExamine = null, + int? maxNumPassages = null) + => new() + { + Path = path, + MaxCharsToExamine = maxCharsToExamine, + MaxNumPassages = maxNumPassages + }; + + /// + /// Creates highlighting options. + /// + /// The type of the field. + /// The document field to search. + /// + /// The maximum number of characters to examine on a document when performing highlighting + /// for a field. + /// + /// + /// The number of high-scoring passages to return per document in the highlighting results + /// for each field. + /// + /// Highlighting options. + public HighlightOptions Options( + Expression> path, + int? maxCharsToExamine = null, + int? maxNumPassages = null) => + Options(new ExpressionFieldDefinition(path), maxCharsToExamine, maxNumPassages); + } +} diff --git a/src/MongoDB.Driver/Search/PathDefinition.cs b/src/MongoDB.Driver/Search/PathDefinition.cs new file mode 100644 index 00000000000..80d138de38c --- /dev/null +++ b/src/MongoDB.Driver/Search/PathDefinition.cs @@ -0,0 +1,90 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using System.Linq; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; + +namespace MongoDB.Driver.Search +{ + /// + /// Base class for search paths. + /// + /// The type of the document. + public abstract class PathDefinition + { + /// + /// Renders the path to a . + /// + /// The document serializer. + /// The serializer registry. + /// A . + public abstract BsonValue Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry); + + /// + /// Performs an implicit conversion from to + /// . + /// + /// The field. + /// + /// The result of the conversion. + /// + public static implicit operator PathDefinition(FieldDefinition field) => + new SinglePathDefinition(field); + + /// + /// Performs an implicit conversion from a field name to . + /// + /// The field name. + /// + /// The result of the conversion. + /// + public static implicit operator PathDefinition(string fieldName) => + new SinglePathDefinition(new StringFieldDefinition(fieldName)); + + /// + /// Performs an implicit conversion from an array of to + /// . + /// + /// The array of fields. + /// + /// The result of the conversion. + /// + public static implicit operator PathDefinition(FieldDefinition[] fields) => + new MultiPathDefinition(fields); + + /// + /// Performs an implicit conversion from a list of to + /// . + /// + /// The list of fields. + /// + /// The result of the conversion. + /// + public static implicit operator PathDefinition(List> fields) => + new MultiPathDefinition(fields); + + /// + /// Performs an implicit conversion from an array of field names to + /// . + /// + /// The array of field names. + /// + /// The result of the conversion. + /// + public static implicit operator PathDefinition(string[] fieldNames) => + new MultiPathDefinition(fieldNames.Select(fieldName => new StringFieldDefinition(fieldName))); + } +} diff --git a/src/MongoDB.Driver/Search/PathDefinitionBuilder.cs b/src/MongoDB.Driver/Search/PathDefinitionBuilder.cs new file mode 100644 index 00000000000..437d0f8c6e9 --- /dev/null +++ b/src/MongoDB.Driver/Search/PathDefinitionBuilder.cs @@ -0,0 +1,165 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// A builder for a search path. + /// + /// The type of the document. + public sealed class PathDefinitionBuilder + { + /// + /// Creates a search path for a single field. + /// + /// The field definition. + /// A single-field search path. + public PathDefinition Single(FieldDefinition field) => + new SinglePathDefinition(field); + + /// + /// Creates a search path for a single field. + /// + /// The type of the field. + /// The field definition. + /// A single-field search path. + public PathDefinition Single(Expression> field) => + Single(new ExpressionFieldDefinition(field)); + + /// + /// Creates a search path for multiple fields. + /// + /// The collection of field definitions. + /// A multi-field search path. + public PathDefinition Multi(IEnumerable> fields) => + new MultiPathDefinition(fields); + + /// + /// Creates a search path for multiple fields. + /// + /// The array of field definitions. + /// A multi-field search path. + public PathDefinition Multi(params FieldDefinition[] fields) => + Multi((IEnumerable>)fields); + + /// + /// Creates a search path for multiple fields. + /// + /// The type of the fields. + /// The array of field definitions. + /// A multi-field search path. + public PathDefinition Multi(params Expression>[] fields) => + Multi(fields.Select(x => new ExpressionFieldDefinition(x))); + + /// + /// Creates a search path that searches using the specified analyzer. + /// + /// The field definition + /// The name of the analyzer. + /// An analyzer search path. + public PathDefinition Analyzer(FieldDefinition field, string analyzerName) => + new AnalyzerPathDefinition(field, analyzerName); + + /// + /// Creates a search path that searches using the specified analyzer. + /// + /// The type of the field. + /// The field definition + /// The name of the analyzer. + /// An analyzer search path. + public PathDefinition Analyzer(Expression> field, string analyzerName) => + Analyzer(new ExpressionFieldDefinition(field), analyzerName); + + /// + /// Creates a search path that uses special characters in the field name + /// that can match any character. + /// + /// + /// The wildcard string that the field name must match. + /// + /// A wildcard search path. + public PathDefinition Wildcard(string query) => + new WildcardPathDefinition(query); + } + + internal sealed class SinglePathDefinition : PathDefinition + { + private readonly FieldDefinition _field; + + public SinglePathDefinition(FieldDefinition field) + { + _field = Ensure.IsNotNull(field, nameof(field)); + } + + public override BsonValue Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) + { + var renderedField = _field.Render(documentSerializer, serializerRegistry); + return new BsonString(renderedField.FieldName); + } + } + + internal sealed class MultiPathDefinition : PathDefinition + { + private readonly IEnumerable> _fields; + + public MultiPathDefinition(IEnumerable> fields) + { + _fields = Ensure.IsNotNull(fields, nameof(fields)); + } + + public override BsonValue Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new BsonArray(_fields.Select(field => field.Render(documentSerializer, serializerRegistry).FieldName)); + } + + internal sealed class AnalyzerPathDefinition : PathDefinition + { + private readonly FieldDefinition _field; + private readonly string _analyzerName; + + public AnalyzerPathDefinition(FieldDefinition field, string analyzerName) + { + _field = Ensure.IsNotNull(field, nameof(field)); + _analyzerName = Ensure.IsNotNull(analyzerName, nameof(analyzerName)); + } + + public override BsonValue Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => new BsonDocument() + { + { "value", _field.Render(documentSerializer, serializerRegistry).FieldName }, + { "multi", _analyzerName } + }; + } + + internal sealed class WildcardPathDefinition : PathDefinition + { + private readonly string _query; + + public WildcardPathDefinition(string query) + { + _query = Ensure.IsNotNull(query, nameof(query)); + } + + public override BsonValue Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => new BsonDocument() + { + { "wildcard", _query } + }; + } +} diff --git a/src/MongoDB.Driver/Search/QueryDefinition.cs b/src/MongoDB.Driver/Search/QueryDefinition.cs new file mode 100644 index 00000000000..d8a92bbd011 --- /dev/null +++ b/src/MongoDB.Driver/Search/QueryDefinition.cs @@ -0,0 +1,102 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using MongoDB.Bson; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// Base class for search queries. + /// + public abstract class QueryDefinition + { + /// + /// Renders the query to a . + /// + /// A . + public abstract BsonValue Render(); + + /// + /// Performs an implicit conversion from a string to . + /// + /// The string. + /// + /// The result of the conversion. + /// + public static implicit operator QueryDefinition(string query) => + new SingleQueryDefinition(query); + + /// + /// Performs an implicit conversion from an array of strings to . + /// + /// The array of strings. + /// + /// The result of the conversion. + /// + public static implicit operator QueryDefinition(string[] queries) => + new MultiQueryDefinition(queries); + + /// + /// Performs an implicit conversion from a list of strings to . + /// + /// The list of strings. + /// + /// The result of the conversion. + /// + public static implicit operator QueryDefinition(List queries) => + new MultiQueryDefinition(queries); + } + + /// + /// A query definition for a single string. + /// + public sealed class SingleQueryDefinition : QueryDefinition + { + private readonly string _query; + + /// + /// Initializes a new instance of the class. + /// + /// The query string. + public SingleQueryDefinition(string query) + { + _query = Ensure.IsNotNull(query, nameof(query)); + } + + /// + public override BsonValue Render() => new BsonString(_query); + } + + /// + /// A query definition for multiple strings. + /// + public sealed class MultiQueryDefinition : QueryDefinition + { + private readonly IEnumerable _queries; + + /// + /// Initializes a new instance of the class. + /// + /// The query strings. + public MultiQueryDefinition(IEnumerable queries) + { + _queries = Ensure.IsNotNull(queries, nameof(queries)); + } + + /// + public override BsonValue Render() => new BsonArray(_queries); + } +} diff --git a/src/MongoDB.Driver/Search/ScoreDefinition.cs b/src/MongoDB.Driver/Search/ScoreDefinition.cs new file mode 100644 index 00000000000..78bc649b0bf --- /dev/null +++ b/src/MongoDB.Driver/Search/ScoreDefinition.cs @@ -0,0 +1,34 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using MongoDB.Bson; +using MongoDB.Bson.Serialization; + +namespace MongoDB.Driver.Search +{ + /// + /// Base class for search score modifiers. + /// + /// The type of the document. + public abstract class ScoreDefinition + { + /// + /// Renders the score modifier to a . + /// + /// The document serializer. + /// The serializer registry. + /// A . + public abstract BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry); + } +} diff --git a/src/MongoDB.Driver/Search/ScoreDefinitionBuilder.cs b/src/MongoDB.Driver/Search/ScoreDefinitionBuilder.cs new file mode 100644 index 00000000000..c4f3190533b --- /dev/null +++ b/src/MongoDB.Driver/Search/ScoreDefinitionBuilder.cs @@ -0,0 +1,134 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Linq.Expressions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// A builder for a score modifier. + /// + /// The type of the document. + public sealed class ScoreDefinitionBuilder + { + /// + /// Creates a score modifier that multiplies a result's base score by a given number. + /// + /// The number to multiply the default base score by. + /// + /// A boost score modifier. + /// + public ScoreDefinition Boost(double value) => new BoostValueScoreDefinition(value); + + /// + /// Creates a score modifier that multiples a result's base score by the value of a numeric + /// field in the documents. + /// + /// + /// The path to the numeric field whose value to multiply the default base score by. + /// + /// + /// The numeric value to substitute if the numeric field is not found in the documents. + /// + /// + /// A boost score modifier. + /// + public ScoreDefinition Boost(PathDefinition path, double undefined = 0) => + new BoostPathScoreDefinition(path, undefined); + + /// + /// Creates a score modifier that multiplies a result's base score by the value of a numeric + /// field in the documents. + /// + /// + /// The path to the numeric field whose value to multiply the default base score by. + /// + /// + /// The numeric value to substitute if the numeric field is not found in the documents. + /// + /// + /// A boost score modifier. + /// + public ScoreDefinition Boost(Expression> path, double undefined = 0) => + Boost(new ExpressionFieldDefinition(path), undefined); + + /// + /// Creates a score modifier that replaces the base score with a given number. + /// + /// The number to replace the base score with. + /// + /// A constant score modifier. + /// + public ScoreDefinition Constant(double value) => + new ConstantScoreDefinition(value); + } + + internal class BoostValueScoreDefinition : ScoreDefinition + { + private readonly double _value; + + public BoostValueScoreDefinition(double value) + { + _value = Ensure.IsGreaterThanZero(value, nameof(value)); + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) + => new() + { + { "boost", new BsonDocument("value", _value) } + }; + } + + internal class BoostPathScoreDefinition : ScoreDefinition + { + private readonly PathDefinition _path; + private readonly double _undefined; + + public BoostPathScoreDefinition(PathDefinition path, double undefined) + { + _path = Ensure.IsNotNull(path, nameof(path)); + _undefined = undefined; + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) + { + var document = new BsonDocument() + { + { "path", _path.Render(documentSerializer, serializerRegistry) }, + { "undefined", _undefined, _undefined != 0 } + }; + + return new("boost", document); + } + } + + internal sealed class ConstantScoreDefinition : ScoreDefinition + { + private readonly double _value; + + public ConstantScoreDefinition(double value) + { + _value = Ensure.IsGreaterThanZero(value, nameof(value)); + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => new() + { + { "constant", new BsonDocument("value", _value) } + }; + } +} diff --git a/src/MongoDB.Driver/Search/SearchCountOptions.cs b/src/MongoDB.Driver/Search/SearchCountOptions.cs new file mode 100644 index 00000000000..7f26fef5c8c --- /dev/null +++ b/src/MongoDB.Driver/Search/SearchCountOptions.cs @@ -0,0 +1,54 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using MongoDB.Bson; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// Options for counting the search results. + /// + public class SearchCountOptions + { + private SearchCountType _type = SearchCountType.LowerBound; + private int? _threshold; + + /// + /// Gets or sets the type of count of the documents in the result set. + /// + public SearchCountType Type + { + get => _type; + set => _type = value; + } + + /// + /// Gets or sets the number of documents to include in the exact count if + /// is . + /// + public int? Threshold + { + get => _threshold; + set => _threshold = Ensure.IsNullOrGreaterThanZero(value, nameof(value)); + } + + internal BsonDocument Render() + => new() + { + { "type", _type.ToCamelCase(), _type != SearchCountType.LowerBound }, + { "threshold", _threshold, _threshold != null } + }; + } +} diff --git a/src/MongoDB.Driver/Search/SearchCountType.cs b/src/MongoDB.Driver/Search/SearchCountType.cs new file mode 100644 index 00000000000..4dfac693a98 --- /dev/null +++ b/src/MongoDB.Driver/Search/SearchCountType.cs @@ -0,0 +1,32 @@ +// Copyright 2021-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace MongoDB.Driver.Search +{ + /// + /// The type of count of the documents in a search result set. + /// + public enum SearchCountType + { + /// + /// A lower bound count of the number of documents that match the query. + /// + LowerBound, + + /// + /// An exact count of the number of documents that match the query. + /// + Total + } +} diff --git a/src/MongoDB.Driver/Search/SearchDefinition.cs b/src/MongoDB.Driver/Search/SearchDefinition.cs new file mode 100644 index 00000000000..8b7ec459bf2 --- /dev/null +++ b/src/MongoDB.Driver/Search/SearchDefinition.cs @@ -0,0 +1,105 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// Base class for search definitions. + /// + /// The type of the document. + public abstract class SearchDefinition + { + /// + /// Renders the search definition to a . + /// + /// The document serializer. + /// The serializer registry. + /// A . + public abstract BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry); + + /// + /// Performs an implicit conversion from a BSON document to a . + /// + /// The BSON document specifying the search definition. + /// + /// The result of the conversion. + /// + public static implicit operator SearchDefinition(BsonDocument document) => + document != null ? new BsonDocumentSearchDefinition(document) : null; + + /// + /// Performs an implicit conversion from a string to a . + /// + /// The string specifying the search definition in JSON. + /// + /// The result of the conversion. + /// + public static implicit operator SearchDefinition(string json) => + json != null ? new JsonSearchDefinition(json) : null; + } + + /// + /// A search definition based on a BSON document. + /// + /// The type of the document. + public sealed class BsonDocumentSearchDefinition : SearchDefinition + { + /// + /// Initializes a new instance of the class. + /// + /// The BSON document specifying the search definition. + public BsonDocumentSearchDefinition(BsonDocument document) + { + Document = Ensure.IsNotNull(document, nameof(document)); + } + + /// + /// Gets the BSON document. + /// + public BsonDocument Document { get; private set; } + + /// + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + Document; + } + + /// + /// A search definition based on a JSON string. + /// + /// The type of the document. + public sealed class JsonSearchDefinition : SearchDefinition + { + /// + /// Initializes a new instance of the class. + /// + /// The JSON string specifying the search definition. + public JsonSearchDefinition(string json) + { + Json = Ensure.IsNotNullOrEmpty(json, nameof(json)); + } + + /// + /// Gets the JSON string. + /// + public string Json { get; private set; } + + /// + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + BsonDocument.Parse(Json); + } +} diff --git a/src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs b/src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs new file mode 100644 index 00000000000..14598e090c4 --- /dev/null +++ b/src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs @@ -0,0 +1,97 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Linq.Expressions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// A builder for a search definition. + /// + /// The type of the document. + public sealed class SearchDefinitionBuilder + { + /// + /// Creates a search definition that performs full-text search using the analyzer specified + /// in the index configuration. + /// + /// The string or strings to search for. + /// The indexed field or fields to search. + /// The options for fuzzy search. + /// The score modifier. + /// A text search definition. + public SearchDefinition Text( + QueryDefinition query, + PathDefinition path, + FuzzyOptions fuzzy = null, + ScoreDefinition score = null) => + new TextSearchDefinition(query, path, fuzzy, score); + + /// + /// Creates a search definition that performs full-text search using the analyzer specified + /// in the index configuration. + /// + /// The type of the field. + /// The string or strings to search for. + /// The indexed field or field to search. + /// The options for fuzzy search. + /// The score modifier. + /// A text search definition. + public SearchDefinition Text( + QueryDefinition query, + Expression> path, + FuzzyOptions fuzzy = null, + ScoreDefinition score = null) => + Text(query, new ExpressionFieldDefinition(path), fuzzy, score); + } + + internal sealed class TextSearchDefinition : SearchDefinition + { + private readonly QueryDefinition _query; + private readonly PathDefinition _path; + private readonly FuzzyOptions _fuzzy; + private readonly ScoreDefinition _score; + + public TextSearchDefinition( + QueryDefinition query, + PathDefinition path, + FuzzyOptions fuzzy, + ScoreDefinition score) + { + _query = Ensure.IsNotNull(query, nameof(query)); + _path = Ensure.IsNotNull(path, nameof(path)); + _fuzzy = fuzzy; + _score = score; + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) + => new() + { + { + "text", + new BsonDocument() + { + { "query", _query.Render() }, + { "path", _path.Render(documentSerializer, serializerRegistry) }, + { "fuzzy", () => _fuzzy.Render(), _fuzzy != null }, + { "score", () => _score.Render(documentSerializer, serializerRegistry), _score != null } + } + } + }; + } +} diff --git a/tests/MongoDB.Driver.Tests/Search/SearchDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/Search/SearchDefinitionBuilderTests.cs new file mode 100644 index 00000000000..a27cd4d125a --- /dev/null +++ b/tests/MongoDB.Driver.Tests/Search/SearchDefinitionBuilderTests.cs @@ -0,0 +1,155 @@ +// Copyright 2021-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using FluentAssertions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver.GeoJsonObjectModel; +using MongoDB.Driver.Search; +using Xunit; + +namespace MongoDB.Driver.Tests.Search +{ + public class SearchDefinitionBuilderTests + { + [Fact] + public void Text() + { + var subject = CreateSubject(); + + AssertRendered(subject.Text("foo", "x"), + "{ text: { query: 'foo', path: 'x' } }"); + + AssertRendered( + subject.Text("foo", new[] { "x", "y" }), + "{ text: { query: 'foo', path: ['x', 'y'] } }"); + AssertRendered( + subject.Text(new[] { "foo", "bar" }, "x"), + "{ text: { query: ['foo', 'bar'], path: 'x' } }"); + AssertRendered( + subject.Text(new[] { "foo", "bar" }, new[] { "x", "y" }), + "{ text: { query: ['foo', 'bar'], path: ['x', 'y'] } }"); + + AssertRendered( + subject.Text("foo", "x", new FuzzyOptions()), + "{ text: { query: 'foo', path: 'x', fuzzy: {} } }"); + AssertRendered( + subject.Text("foo", "x", new FuzzyOptions() + { + MaxEdits = 1, + PrefixLength = 5, + MaxExpansions = 25 + }), + "{ text: { query: 'foo', path: 'x', fuzzy: { maxEdits: 1, prefixLength: 5, maxExpansions: 25 } } }"); + + var scoreBuilder = new ScoreDefinitionBuilder(); + AssertRendered( + subject.Text("foo", "x", score: scoreBuilder.Constant(1)), + "{ text: { query: 'foo', path: 'x', score: { constant: { value: 1 } } } }"); + } + + [Fact] + public void Text_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Text("foo", x => x.FirstName), + "{ text: { query: 'foo', path: 'fn' } }"); + AssertRendered( + subject.Text("foo", "FirstName"), + "{ text: { query: 'foo', path: 'fn' } }"); + + AssertRendered( + subject.Text( + "foo", + new FieldDefinition[] + { + new ExpressionFieldDefinition(x => x.FirstName), + new ExpressionFieldDefinition(x => x.LastName) + }), + "{ text: { query: 'foo', path: ['fn', 'ln'] } }"); + AssertRendered( + subject.Text("foo", new[] { "FirstName", "LastName" }), + "{ text: { query: 'foo', path: ['fn', 'ln'] } }"); + + AssertRendered( + subject.Text(new[] { "foo", "bar" }, x => x.FirstName), + "{ text: { query: ['foo', 'bar'], path: 'fn' } }"); + AssertRendered( + subject.Text(new[] { "foo", "bar" }, "FirstName"), + "{ text: { query: ['foo', 'bar'], path: 'fn' } }"); + + AssertRendered( + subject.Text( + new[] { "foo", "bar" }, + new FieldDefinition[] + { + new ExpressionFieldDefinition(x => x.FirstName), + new ExpressionFieldDefinition(x => x.LastName) + }), + "{ text: { query: ['foo', 'bar'], path: ['fn', 'ln'] } }"); + AssertRendered( + subject.Text(new[] { "foo", "bar" }, new[] { "FirstName", "LastName" }), + "{ text: { query: ['foo', 'bar'], path: ['fn', 'ln'] } }"); + } + + private void AssertRendered(SearchDefinition query, string expected) + { + AssertRendered(query, BsonDocument.Parse(expected)); + } + + private void AssertRendered(SearchDefinition query, BsonDocument expected) + { + var documentSerializer = BsonSerializer.SerializerRegistry.GetSerializer(); + var renderedQuery = query.Render(documentSerializer, BsonSerializer.SerializerRegistry); + + renderedQuery.Should().Be(expected); + } + + private SearchDefinitionBuilder CreateSubject() + { + return new SearchDefinitionBuilder(); + } + + private class SimplePerson + { + [BsonElement("fn")] + public string FirstName { get; set; } + + [BsonElement("ln")] + public string LastName { get; set; } + } + + private class Person : SimplePerson + { + [BsonId] + public ObjectId Id { get; set; } + + [BsonElement("age")] + public int Age { get; set; } + + [BsonElement("ret")] + public bool Retired { get; set; } + + [BsonElement("dob")] + public DateTime Birthday { get; set; } + + [BsonElement("location")] + public GeoJsonPoint Location { get; set; } + } + } +} From 0c9e2a65ea07487b2555540ca6b9f699d0931989 Mon Sep 17 00:00:00 2001 From: BorisDog Date: Mon, 12 Dec 2022 13:10:20 -0800 Subject: [PATCH 02/21] CSHARP-4440: Incorporate MongoDB.Labs.Search library --- src/MongoDB.Driver/AggregateFluent.cs | 12 +- src/MongoDB.Driver/AggregateFluentBase.cs | 9 + src/MongoDB.Driver/Builders.cs | 9 + src/MongoDB.Driver/IAggregateFluent.cs | 16 +- .../PipelineDefinitionBuilder.cs | 22 + .../PipelineStageDefinitionBuilder.cs | 34 + .../ProjectionDefinitionBuilder.cs | 116 +++ .../Search/AutocompleteTokenOrder.cs | 33 + src/MongoDB.Driver/Search/CompoundFluent.cs | 114 +++ .../Search/CompoundFluentImpl.cs | 57 ++ src/MongoDB.Driver/Search/GeoShapeRelation.cs | 43 + src/MongoDB.Driver/Search/GeoWithin.cs | 113 +++ src/MongoDB.Driver/Search/HighlightOptions.cs | 14 + .../Search/HighlightOptionsBuilder.cs | 70 -- .../Search/ScoreDefinitionBuilder.cs | 53 +- src/MongoDB.Driver/Search/ScoreFunction.cs | 34 + .../Search/ScoreFunctionBuilder.cs | 276 +++++++ .../Search/SearchCountOptions.cs | 6 +- src/MongoDB.Driver/Search/SearchCountType.cs | 2 +- src/MongoDB.Driver/Search/SearchDefinition.cs | 58 ++ .../Search/SearchDefinitionBuilder.cs | 636 ++++++++++++++- .../Search/SearchDefinitions.cs | 379 +++++++++ src/MongoDB.Driver/Search/SearchFacet.cs | 48 ++ .../Search/SearchFacetBuilder.cs | 274 +++++++ src/MongoDB.Driver/Search/SearchMetaResult.cs | 86 ++ src/MongoDB.Driver/Search/SearchRange.cs | 118 +++ src/MongoDB.Driver/Search/SpanDefinition.cs | 50 ++ .../Search/SpanDefinitionBuilder.cs | 198 +++++ .../PipelineDefinitionBuilderTests.cs | 135 +++ .../Search/PathDefinitionBuilderTests.cs | 147 ++++ .../ProjectionDefinitionBuilderTests.cs | 62 ++ .../Search/ScoreDefinitionBuilderTests.cs | 96 +++ .../Search/SearchDefinitionBuilderTests.cs | 771 +++++++++++++++++- .../Search/SearchFacetBuilderTests.cs | 143 ++++ .../Search/SpanDefinitionBuilderTests.cs | 172 ++++ 35 files changed, 4266 insertions(+), 140 deletions(-) create mode 100644 src/MongoDB.Driver/Search/AutocompleteTokenOrder.cs create mode 100644 src/MongoDB.Driver/Search/CompoundFluent.cs create mode 100644 src/MongoDB.Driver/Search/CompoundFluentImpl.cs create mode 100644 src/MongoDB.Driver/Search/GeoShapeRelation.cs create mode 100644 src/MongoDB.Driver/Search/GeoWithin.cs delete mode 100644 src/MongoDB.Driver/Search/HighlightOptionsBuilder.cs create mode 100644 src/MongoDB.Driver/Search/ScoreFunction.cs create mode 100644 src/MongoDB.Driver/Search/ScoreFunctionBuilder.cs create mode 100644 src/MongoDB.Driver/Search/SearchDefinitions.cs create mode 100644 src/MongoDB.Driver/Search/SearchFacet.cs create mode 100644 src/MongoDB.Driver/Search/SearchFacetBuilder.cs create mode 100644 src/MongoDB.Driver/Search/SearchMetaResult.cs create mode 100644 src/MongoDB.Driver/Search/SearchRange.cs create mode 100644 src/MongoDB.Driver/Search/SpanDefinition.cs create mode 100644 src/MongoDB.Driver/Search/SpanDefinitionBuilder.cs create mode 100644 tests/MongoDB.Driver.Tests/Search/PathDefinitionBuilderTests.cs create mode 100644 tests/MongoDB.Driver.Tests/Search/ProjectionDefinitionBuilderTests.cs create mode 100644 tests/MongoDB.Driver.Tests/Search/ScoreDefinitionBuilderTests.cs create mode 100644 tests/MongoDB.Driver.Tests/Search/SearchFacetBuilderTests.cs create mode 100644 tests/MongoDB.Driver.Tests/Search/SpanDefinitionBuilderTests.cs diff --git a/src/MongoDB.Driver/AggregateFluent.cs b/src/MongoDB.Driver/AggregateFluent.cs index a03a75f7e81..a2c44a32e37 100644 --- a/src/MongoDB.Driver/AggregateFluent.cs +++ b/src/MongoDB.Driver/AggregateFluent.cs @@ -240,13 +240,21 @@ public override IAggregateFluent ReplaceWith(AggregateEx } public override IAggregateFluent Search( - SearchDefinition query, + SearchDefinition searchDefinition, HighlightOptions highlight = null, string indexName = null, SearchCountOptions count = null, bool returnStoredSource = false) { - return WithPipeline(_pipeline.Search(query, highlight, indexName, count, returnStoredSource)); + return WithPipeline(_pipeline.Search(searchDefinition, highlight, indexName, count, returnStoredSource)); + } + + public override IAggregateFluent SearchMeta( + SearchDefinition searchDefinition, + string indexName = null, + SearchCountOptions count = null) + { + return WithPipeline(_pipeline.SearchMeta(searchDefinition, indexName, count)); } public override IAggregateFluent SetWindowFields( diff --git a/src/MongoDB.Driver/AggregateFluentBase.cs b/src/MongoDB.Driver/AggregateFluentBase.cs index 9223eccd87e..4f61a2ebf83 100644 --- a/src/MongoDB.Driver/AggregateFluentBase.cs +++ b/src/MongoDB.Driver/AggregateFluentBase.cs @@ -227,6 +227,15 @@ public virtual IAggregateFluent ReplaceWith(AggregateExp throw new NotImplementedException(); } + /// + public virtual IAggregateFluent SearchMeta( + SearchDefinition searchDefinition, + string indexName = null, + SearchCountOptions count = null) + { + throw new NotImplementedException(); + } + /// public virtual IAggregateFluent SetWindowFields( AggregateExpressionDefinition, TWindowFields> output) diff --git a/src/MongoDB.Driver/Builders.cs b/src/MongoDB.Driver/Builders.cs index b339da7644f..9a21daf4f6c 100644 --- a/src/MongoDB.Driver/Builders.cs +++ b/src/MongoDB.Driver/Builders.cs @@ -39,13 +39,22 @@ public static class Builders public static UpdateDefinitionBuilder Update { get; } = new UpdateDefinitionBuilder(); // Search builders + /// Gets a . + public static SearchFacetBuilder Facet { get; } = new SearchFacetBuilder(); + /// Gets a . public static PathDefinitionBuilder Path { get; } = new PathDefinitionBuilder(); /// Gets a . public static ScoreDefinitionBuilder Score { get; } = new ScoreDefinitionBuilder(); + /// Gets a . + public static ScoreFunctionBuilder ScoreFunction { get; } = new ScoreFunctionBuilder(); + /// Gets a . public static SearchDefinitionBuilder Search { get; } = new SearchDefinitionBuilder(); + + /// Gets a . + public static SpanDefinitionBuilder Span { get; } = new SpanDefinitionBuilder(); } } diff --git a/src/MongoDB.Driver/IAggregateFluent.cs b/src/MongoDB.Driver/IAggregateFluent.cs index 7ba11536235..1747fb96f21 100644 --- a/src/MongoDB.Driver/IAggregateFluent.cs +++ b/src/MongoDB.Driver/IAggregateFluent.cs @@ -357,7 +357,7 @@ public interface IAggregateFluent : IAsyncCursorSource /// /// Appends a $search stage to the pipeline. /// - /// The search definition. + /// The search definition. /// The highlight options. /// The index name. /// The count options. @@ -367,12 +367,24 @@ public interface IAggregateFluent : IAsyncCursorSource /// /// The fluent aggregate interface. IAggregateFluent Search( - SearchDefinition query, + SearchDefinition searchDefinition, HighlightOptions highlight = null, string indexName = null, SearchCountOptions count = null, bool returnStoredSource = false); + /// + /// Appends a $searchMeta stage to the pipeline. + /// + /// The search definition. + /// The index name. + /// The count options. + /// The fluent aggregate interface. + IAggregateFluent SearchMeta( + SearchDefinition searchDefinition, + string indexName = null, + SearchCountOptions count = null); + /// /// Appends a $setWindowFields to the pipeline. /// diff --git a/src/MongoDB.Driver/PipelineDefinitionBuilder.cs b/src/MongoDB.Driver/PipelineDefinitionBuilder.cs index c4ecef2b701..158caf03131 100644 --- a/src/MongoDB.Driver/PipelineDefinitionBuilder.cs +++ b/src/MongoDB.Driver/PipelineDefinitionBuilder.cs @@ -1192,6 +1192,28 @@ public static class PipelineDefinitionBuilder return pipeline.AppendStage(PipelineStageDefinitionBuilder.Search(searchDefinition, highlight, indexName, count, returnStoredSource)); } + /// + /// Appends a $searchMeta stage to the pipeline. + /// + /// The type of the input documents. + /// The type of the output documents. + /// The pipeline. + /// The search definition. + /// The index name. + /// The count options. + /// + /// A new pipeline with an additional stage. + /// + public static PipelineDefinition SearchMeta( + this PipelineDefinition pipeline, + SearchDefinition query, + string indexName = null, + SearchCountOptions count = null) + { + Ensure.IsNotNull(pipeline, nameof(pipeline)); + return pipeline.AppendStage(PipelineStageDefinitionBuilder.SearchMeta(query, indexName, count)); + } + /// /// Create a $setWindowFields stage. /// diff --git a/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs b/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs index 78477da9fa6..d448b578c2e 100644 --- a/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs +++ b/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs @@ -1349,6 +1349,40 @@ public static class PipelineStageDefinitionBuilder return stage; } + /// + /// Creates a $searchMeta stage. + /// + /// The type of the input documents. + /// The search definition. + /// The index name. + /// The count options. + /// The stage. + public static PipelineStageDefinition SearchMeta( + SearchDefinition searchDefinition, + string indexName = null, + SearchCountOptions count = null) + { + Ensure.IsNotNull(searchDefinition, nameof(searchDefinition)); + + const string operatorName = "$searchMeta"; + var stage = new DelegatedPipelineStageDefinition( + operatorName, + (s, sr, linqProvider) => + { + var renderedSearchDefinition = searchDefinition.Render(s, sr); + renderedSearchDefinition.Add("count", () => count.Render(), count != null); + renderedSearchDefinition.Add("index", indexName, indexName != null); + + var document = new BsonDocument(operatorName, renderedSearchDefinition); + return new RenderedPipelineStageDefinition( + operatorName, + document, + sr.GetSerializer()); + }); + + return stage; + } + /// /// Creates a $replaceRoot stage. /// diff --git a/src/MongoDB.Driver/ProjectionDefinitionBuilder.cs b/src/MongoDB.Driver/ProjectionDefinitionBuilder.cs index 42fe10e0c9a..528116cb272 100644 --- a/src/MongoDB.Driver/ProjectionDefinitionBuilder.cs +++ b/src/MongoDB.Driver/ProjectionDefinitionBuilder.cs @@ -156,6 +156,40 @@ public static ProjectionDefinition Meta(this ProjectionDef return builder.Combine(projection, builder.Meta(field, metaFieldName)); } + /// + /// Combines an existing projection with a search highlights projection. + /// + /// The type of the document. + /// The projection. + /// The field. + /// + /// A combined projection. + /// + public static ProjectionDefinition MetaSearchHighlights( + this ProjectionDefinition projection, + string field) + { + var builder = Builders.Projection; + return builder.Combine(projection, builder.MetaSearchHighlights(field)); + } + + /// + /// Combines an existing projection with a search score projection. + /// + /// The type of the document. + /// The projection. + /// The field. + /// + /// A combined projection. + /// + public static ProjectionDefinition MetaSearchScore( + this ProjectionDefinition projection, + string field) + { + var builder = Builders.Projection; + return builder.Combine(projection, builder.MetaSearchScore(field)); + } + /// /// Combines an existing projection with a text score projection. /// @@ -171,6 +205,40 @@ public static ProjectionDefinition MetaTextScore(this Proj return builder.Combine(projection, builder.MetaTextScore(field)); } + /// + /// Combines an existing projection with a search metadata projection. + /// + /// The type of the document. + /// The projection. + /// The field. + /// + /// A combined projection. + /// + public static ProjectionDefinition SearchMeta( + this ProjectionDefinition projection, + FieldDefinition field) + { + var builder = Builders.Projection; + return builder.Combine(projection, builder.SearchMeta(field)); + } + + /// + /// Combines an existing projection with a search metadata projection. + /// + /// The type of the document. + /// The projection. + /// The field. + /// + /// A combined projection. + /// + public static ProjectionDefinition SearchMeta( + this ProjectionDefinition projection, + Expression> field) + { + var builder = Builders.Projection; + return builder.Combine(projection, builder.SearchMeta(field)); + } + /// /// Combines an existing projection with an array slice projection. /// @@ -363,6 +431,30 @@ public ProjectionDefinition Meta(string field, string metaFieldName) return new SingleFieldProjectionDefinition(field, new BsonDocument("$meta", metaFieldName)); } + /// + /// Creates a search highlights projection. + /// + /// The field. + /// + /// A search highlights projection. + /// + public ProjectionDefinition MetaSearchHighlights(string field) + { + return Meta(field, "searchHighlights"); + } + + /// + /// Creates a search score projection. + /// + /// The field. + /// + /// A search score projection. + /// + public ProjectionDefinition MetaSearchScore(string field) + { + return Meta(field, "searchScore"); + } + /// /// Creates a text score projection. /// @@ -375,6 +467,30 @@ public ProjectionDefinition MetaTextScore(string field) return Meta(field, "textScore"); } + /// + /// Creates a search metadata projection. + /// + /// The field. + /// + /// A search metadata projection. + /// + public ProjectionDefinition SearchMeta(FieldDefinition field) + { + return new SingleFieldProjectionDefinition(field, new BsonString("$$SEARCH_META")); + } + + /// + /// Creates a search metadata projection. + /// + /// The field. + /// + /// A search metadata projection. + /// + public ProjectionDefinition SearchMeta(Expression> field) + { + return SearchMeta(new ExpressionFieldDefinition(field)); + } + /// /// Creates an array slice projection. /// diff --git a/src/MongoDB.Driver/Search/AutocompleteTokenOrder.cs b/src/MongoDB.Driver/Search/AutocompleteTokenOrder.cs new file mode 100644 index 00000000000..2a699ea1a17 --- /dev/null +++ b/src/MongoDB.Driver/Search/AutocompleteTokenOrder.cs @@ -0,0 +1,33 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace MongoDB.Driver.Search +{ + /// + /// The order in which to search for tokens in an autocomplete search definition. + /// + public enum AutocompleteTokenOrder + { + /// + /// Indicates that tokens in the query can appear in any order in the documents. + /// + Any, + + /// + /// Indicates that tokens in the query must appear adjacent to each other or in the order + /// specified in the query in the documents. + /// + Sequential + } +} diff --git a/src/MongoDB.Driver/Search/CompoundFluent.cs b/src/MongoDB.Driver/Search/CompoundFluent.cs new file mode 100644 index 00000000000..2d9f8ca6fb7 --- /dev/null +++ b/src/MongoDB.Driver/Search/CompoundFluent.cs @@ -0,0 +1,114 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; + +namespace MongoDB.Driver.Search +{ + /// + /// Fluent interface for compound search definitions. + /// + /// The type of the document. + public abstract class CompoundFluent + { + /// + /// Adds clauses which must match to produce results. + /// + /// The clauses. + /// The compound fluent interface. + public abstract CompoundFluent Must(IEnumerable> clauses); + + /// + /// Adds clauses which must match to produce results. + /// + /// The clauses. + /// The compound fluent interface. + public CompoundFluent Must(params SearchDefinition[] clauses) => + Must((IEnumerable>)clauses); + + /// + /// Adds clauses which must not match for a document to be included in the + /// results. + /// + /// The clauses. + /// The compound fluent interface. + public abstract CompoundFluent MustNot(IEnumerable> clauses); + + /// + /// Adds clauses which must not match for a document to be included in the + /// results. + /// + /// The clauses. + /// The compound fluent interface. + public CompoundFluent MustNot(params SearchDefinition[] clauses) => + MustNot((IEnumerable>)clauses); + + /// + /// Adds clauses which cause documents in the result set to be scored higher if + /// they match. + /// + /// The clauses. + /// The compound fluent interface. + public abstract CompoundFluent Should(IEnumerable> clauses); + + /// + /// Adds clauses which cause documents in the result set to be scored higher if + /// they match. + /// + /// The clauses. + /// The compound fluent interface. + public CompoundFluent Should(params SearchDefinition[] clauses) => + Should((IEnumerable>)clauses); + + /// + /// Adds clauses which must all match for a document to be included in the + /// results. + /// + /// The clauses. + /// The compound fluent interface. + public abstract CompoundFluent Filter(IEnumerable> clauses); + + /// + /// Adds clauses which must all match for a document to be included in the + /// results. + /// + /// The clauses. + /// The compound fluent interface. + public CompoundFluent Filter(params SearchDefinition[] clauses) => + Filter((IEnumerable>)clauses); + + /// + /// Sets a value specifying the minimum number of should clauses the must match + /// to include a document in the results. + /// + /// The value to set. + /// The compound fluent interface. + public abstract CompoundFluent MinimumShouldMatch(int minimumShouldMatch); + + /// + /// Constructs a search definition from the fluent interface. + /// + /// A compound search definition. + public abstract SearchDefinition ToSearchDefinition(); + + /// + /// Performs an implicit conversion from a + /// to a . + /// + /// The compound fluent interface. + /// The result of the conversion. + public static implicit operator SearchDefinition(CompoundFluent compound) => + compound.ToSearchDefinition(); + } +} diff --git a/src/MongoDB.Driver/Search/CompoundFluentImpl.cs b/src/MongoDB.Driver/Search/CompoundFluentImpl.cs new file mode 100644 index 00000000000..69f904bde7d --- /dev/null +++ b/src/MongoDB.Driver/Search/CompoundFluentImpl.cs @@ -0,0 +1,57 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + internal sealed class CompoundFluentImpl : CompoundFluent + { + private List> _must; + private List> _mustNot; + private List> _should; + private List> _filter; + private int _minimumShouldMatch = 0; + + public override CompoundFluent Must(IEnumerable> clauses) => + AddClauses(ref _must, clauses); + + public override CompoundFluent MustNot(IEnumerable> clauses) => + AddClauses(ref _mustNot, clauses); + + public override CompoundFluent Should(IEnumerable> clauses) => + AddClauses(ref _should, clauses); + + public override CompoundFluent Filter(IEnumerable> clauses) => + AddClauses(ref _filter, clauses); + + public override CompoundFluent MinimumShouldMatch(int minimumShouldMatch) + { + _minimumShouldMatch = minimumShouldMatch; + return this; + } + + public override SearchDefinition ToSearchDefinition() => + new CompoundSearchDefinition(_must, _mustNot, _should, _filter, _minimumShouldMatch); + + private CompoundFluentImpl AddClauses(ref List> clauses, IEnumerable> newClauses) + { + clauses ??= new(); + clauses.AddRange(Ensure.IsNotNull(newClauses, nameof(newClauses))); + + return this; + } + } +} diff --git a/src/MongoDB.Driver/Search/GeoShapeRelation.cs b/src/MongoDB.Driver/Search/GeoShapeRelation.cs new file mode 100644 index 00000000000..c78a59f079b --- /dev/null +++ b/src/MongoDB.Driver/Search/GeoShapeRelation.cs @@ -0,0 +1,43 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace MongoDB.Driver.Search +{ + /// + /// The relation of the query shape geometry to the indexed field geometry in a + /// geo shape search definition. + /// + public enum GeoShapeRelation + { + /// + /// Indicates that the indexed geometry contains the query geometry. + /// + Contains, + + /// + /// Indicates that both the query and indexed geometries have nothing in common. + /// + Disjoint, + + /// + /// Indicates that both the query and indexed geometries intersect. + /// + Intersects, + + /// + /// Indicates that the indexed geometry is within the query geometry. + /// + Within + } +} diff --git a/src/MongoDB.Driver/Search/GeoWithin.cs b/src/MongoDB.Driver/Search/GeoWithin.cs new file mode 100644 index 00000000000..42491a0ca99 --- /dev/null +++ b/src/MongoDB.Driver/Search/GeoWithin.cs @@ -0,0 +1,113 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using MongoDB.Bson; +using MongoDB.Driver.Core.Misc; +using MongoDB.Driver.GeoJsonObjectModel; + +namespace MongoDB.Driver.Search +{ + /// + /// Base class for objects specifying GeoWith query + /// search within. + /// + /// The type of the coordinates. + public abstract class GeoWithin where TCoordinates : GeoJsonCoordinates + { + internal abstract BsonElement Render(); + } + + /// + /// Object that specifies the bottom left and top right GeoJSON points of a box to + /// search within. + /// + /// The type of the coordinates. + public sealed class GeoWithinBox : GeoWithin where TCoordinates : GeoJsonCoordinates + { + /// + /// Initializes a new instance of the class. + /// + /// The bottom left GeoJSON point. + /// The top right GeoJSON point. + public GeoWithinBox(GeoJsonPoint bottomLeft, GeoJsonPoint topRight) + { + BottomLeft = Ensure.IsNotNull(bottomLeft, nameof(bottomLeft)); + TopRight = Ensure.IsNotNull(topRight, nameof(topRight)); + } + + /// Gets the bottom left GeoJSON point. + public GeoJsonPoint BottomLeft { get; } + + /// Gets the top right GeoJSON point. + public GeoJsonPoint TopRight { get; } + + internal override BsonElement Render() => + new("box", new BsonDocument + { + { "bottomLeft", BottomLeft.ToBsonDocument() }, + { "topRight", TopRight.ToBsonDocument() } + }); + } + + /// + /// Object that specifies the center point and the radius in meters to search within. + /// + public sealed class GeoWithinCircle : GeoWithin where TCoordinates : GeoJsonCoordinates + { + /// + /// Initializes a new instance of the class. + /// + /// Center of the circle specified as a GeoJSON point. + /// Radius specified in meters. + public GeoWithinCircle(GeoJsonPoint center, double radius) + { + Center = Ensure.IsNotNull(center, nameof(center)); + Radius = Ensure.IsGreaterThanZero(radius, nameof(radius)); + } + + /// Gets the center of the circle specified as a GeoJSON point. + public GeoJsonPoint Center { get; } + + /// Gets the radius specified in meters. + public double Radius { get; } + + internal override BsonElement Render() => + new("circle", new BsonDocument + { + { "center", Center.ToBsonDocument() }, + { "radius", Radius } + }); + } + + /// + /// Object that specifies the GeoJson geometry to search within. + /// + /// The type of the coordinates. + public sealed class GeoWithinGeometry : GeoWithin where TCoordinates : GeoJsonCoordinates + { + /// + /// Initializes a new instance of the class. + /// + /// GeoJSON object specifying the MultiPolygon or Polygon. + public GeoWithinGeometry(GeoJsonGeometry geometry) + { + Geometry = Ensure.IsNotNull(geometry, nameof(geometry)); + } + + /// Gets the bottom left GeoJSON point. + public GeoJsonGeometry Geometry { get; } + + internal override BsonElement Render() => new("geometry", Geometry.ToBsonDocument()); + } +} diff --git a/src/MongoDB.Driver/Search/HighlightOptions.cs b/src/MongoDB.Driver/Search/HighlightOptions.cs index 1eb3b2e81b2..39b025772d2 100644 --- a/src/MongoDB.Driver/Search/HighlightOptions.cs +++ b/src/MongoDB.Driver/Search/HighlightOptions.cs @@ -28,6 +28,20 @@ public sealed class HighlightOptions private int? _maxCharsToExamine; private int? _maxNumPassages; + // constructors + /// + /// Initializes a new instance of the class. + /// + /// The document field to search. + /// maximum number of characters to examine. + /// The number of high-scoring passages. + public HighlightOptions(PathDefinition path, int? maxCharsToExamine = null, int? maxNumPassages = null) + { + _path = Ensure.IsNotNull(path, nameof(path)); + _maxCharsToExamine = maxCharsToExamine; + _maxNumPassages = maxNumPassages; + } + /// /// Gets or sets the document field to search. /// diff --git a/src/MongoDB.Driver/Search/HighlightOptionsBuilder.cs b/src/MongoDB.Driver/Search/HighlightOptionsBuilder.cs deleted file mode 100644 index 4005a5a2945..00000000000 --- a/src/MongoDB.Driver/Search/HighlightOptionsBuilder.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2010-present MongoDB Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Linq.Expressions; - -namespace MongoDB.Driver.Search -{ - /// - /// A build for highlighting options. - /// - /// The type of the document. - public sealed class HighlightOptionsBuilder - { - /// - /// Creates highlighting options. - /// - /// The document field to search. - /// - /// The maximum number of characters to examine on a document when performing highlighting - /// for a field. - /// - /// - /// The number of high-scoring passages to return per document in the highlighting results - /// for each field. - /// - /// Highlighting options. - public HighlightOptions Options( - PathDefinition path, - int? maxCharsToExamine = null, - int? maxNumPassages = null) - => new() - { - Path = path, - MaxCharsToExamine = maxCharsToExamine, - MaxNumPassages = maxNumPassages - }; - - /// - /// Creates highlighting options. - /// - /// The type of the field. - /// The document field to search. - /// - /// The maximum number of characters to examine on a document when performing highlighting - /// for a field. - /// - /// - /// The number of high-scoring passages to return per document in the highlighting results - /// for each field. - /// - /// Highlighting options. - public HighlightOptions Options( - Expression> path, - int? maxCharsToExamine = null, - int? maxNumPassages = null) => - Options(new ExpressionFieldDefinition(path), maxCharsToExamine, maxNumPassages); - } -} diff --git a/src/MongoDB.Driver/Search/ScoreDefinitionBuilder.cs b/src/MongoDB.Driver/Search/ScoreDefinitionBuilder.cs index c4f3190533b..e0822f1e3f6 100644 --- a/src/MongoDB.Driver/Search/ScoreDefinitionBuilder.cs +++ b/src/MongoDB.Driver/Search/ScoreDefinitionBuilder.cs @@ -33,7 +33,8 @@ public sealed class ScoreDefinitionBuilder /// /// A boost score modifier. /// - public ScoreDefinition Boost(double value) => new BoostValueScoreDefinition(value); + public ScoreDefinition Boost(double value) => + new BoostValueScoreDefinition(value); /// /// Creates a score modifier that multiples a result's base score by the value of a numeric @@ -76,9 +77,19 @@ public sealed class ScoreDefinitionBuilder /// public ScoreDefinition Constant(double value) => new ConstantScoreDefinition(value); + + /// + /// Creates a score modifier that computes the final score through an expression. + /// + /// The expression used to compute the score. + /// + /// A function score modifier. + /// + public ScoreDefinition Function(ScoreFunction function) => + new FunctionScoreDefinition(function); } - internal class BoostValueScoreDefinition : ScoreDefinition + internal sealed class BoostValueScoreDefinition : ScoreDefinition { private readonly double _value; @@ -87,14 +98,11 @@ public BoostValueScoreDefinition(double value) _value = Ensure.IsGreaterThanZero(value, nameof(value)); } - public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) - => new() - { - { "boost", new BsonDocument("value", _value) } - }; + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new("boost", new BsonDocument("value", _value)); } - internal class BoostPathScoreDefinition : ScoreDefinition + internal sealed class BoostPathScoreDefinition : ScoreDefinition { private readonly PathDefinition _path; private readonly double _undefined; @@ -105,18 +113,14 @@ public BoostPathScoreDefinition(PathDefinition path, double undefined _undefined = undefined; } - public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) - { - var document = new BsonDocument() + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new("boost", new BsonDocument { { "path", _path.Render(documentSerializer, serializerRegistry) }, { "undefined", _undefined, _undefined != 0 } - }; - - return new("boost", document); - } + }); } - + internal sealed class ConstantScoreDefinition : ScoreDefinition { private readonly double _value; @@ -126,9 +130,20 @@ public ConstantScoreDefinition(double value) _value = Ensure.IsGreaterThanZero(value, nameof(value)); } - public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => new() + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new("constant", new BsonDocument("value", _value)); + } + + internal sealed class FunctionScoreDefinition : ScoreDefinition + { + private readonly ScoreFunction _function; + + public FunctionScoreDefinition(ScoreFunction function) { - { "constant", new BsonDocument("value", _value) } - }; + _function = Ensure.IsNotNull(function, nameof(function)); + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new("function", _function.Render(documentSerializer, serializerRegistry)); } } diff --git a/src/MongoDB.Driver/Search/ScoreFunction.cs b/src/MongoDB.Driver/Search/ScoreFunction.cs new file mode 100644 index 00000000000..d875fc2ad65 --- /dev/null +++ b/src/MongoDB.Driver/Search/ScoreFunction.cs @@ -0,0 +1,34 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using MongoDB.Bson; +using MongoDB.Bson.Serialization; + +namespace MongoDB.Driver.Search +{ + /// + /// Base class for search score functions. + /// + /// The type of the document. + public abstract class ScoreFunction + { + /// + /// Renders the score function to a . + /// + /// The document serializer. + /// The serializer registry. + /// A . + public abstract BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry); + } +} diff --git a/src/MongoDB.Driver/Search/ScoreFunctionBuilder.cs b/src/MongoDB.Driver/Search/ScoreFunctionBuilder.cs new file mode 100644 index 00000000000..294989c88aa --- /dev/null +++ b/src/MongoDB.Driver/Search/ScoreFunctionBuilder.cs @@ -0,0 +1,276 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// A builder for a score function. + /// + /// The type of the document. + public sealed class ScoreFunctionBuilder + { + /// + /// Creates a function that incorporates an indexed numeric field value into the score. + /// + /// The path to the numeric field. + /// + /// The value to use if the numeric field specified using is + /// missing in the document. + /// + /// A path score function. + public ScoreFunction Path(PathDefinition path, double undefined = 0) => + new PathScoreFunction(path, undefined); + + /// + /// Creates a function that incorporates an indexed numeric field value into the score. + /// + /// The path to the numeric field. + /// + /// The value to use if the numeric field specified using is + /// missing in the document. + /// + /// A path score function. + public ScoreFunction Path(Expression> path, double undefined = 0) => + Path(new ExpressionFieldDefinition(path), undefined); + + /// + /// Creates a function that represents the relevance score, which is the score Atlas Search + /// assigns documents based on relevance. + /// + /// A relevance score function. + public ScoreFunction Relevance() => new RelevanceScoreFunction(); + + /// + /// Creates a function that represents a constant number. + /// + /// Number that indicates a fixed value. + /// A constant score function. + public ScoreFunction Constant(double value) => + new ConstantScoreFunction(value); + + /// + /// Creates a function that adds a series of numbers. + /// + /// An array of expressions, which can have negative values. + /// An addition score function. + public ScoreFunction Add(IEnumerable> operands) => + new ArithmeticScoreFunction("add", operands); + + /// + /// Creates a function that adds a series of numbers. + /// + /// An array of expressions, which can have negative values. + /// An addition score function. + public ScoreFunction Add(params ScoreFunction[] operands) => + Add((IEnumerable>)operands); + + /// + /// Creates a function that multiplies a series of numbers. + /// + /// An array of expressions, which can have negative values. + /// A multiplication score function. + public ScoreFunction Multiply(IEnumerable> operands) => + new ArithmeticScoreFunction("multiply", operands); + + /// + /// Creates a function that multiplies a series of numbers. + /// + /// An array of expressions, which can have negative values. + /// A mulitplication score function. + public ScoreFunction Multiply(params ScoreFunction[] operands) => + Multiply((IEnumerable>)operands); + + /// + /// Creates a function that decays, or reduces by multiplying, the final scores of the + /// documents based on the distance of a numeric field from a specified origin point. + /// + /// The path to the numeric field. + /// The point of origin from which to calculate the distance. + /// + /// The distance from plus or minus at + /// which scores must be multiplied. + /// + /// + /// The rate at which to multiply score values, which must be a positive number between + /// 0 and 1 exclusive. + /// + /// + /// The number of use to determine the distance from . + /// + /// A Guassian score function. + public ScoreFunction Gauss( + PathDefinition path, + double origin, + double scale, + double decay = 0.5, + double offset = 0) + => new GaussScoreFunction(path, origin, scale, decay, offset); + + /// + /// Creates a function that decays, or reduces by multiplying, the final scores of the + /// documents based on the distance of a numeric field from a specified origin point. + /// + /// The path to the numeric field. + /// The point of origin from which to calculate the distance. + /// + /// The distance from plus or minus at + /// which scores must be multiplied. + /// + /// + /// The rate at which to multiply score values, which must be a positive number between + /// 0 and 1 exclusive. + /// + /// + /// The number of use to determine the distance from . + /// + /// A Guassian score function. + public ScoreFunction Gauss( + Expression> path, + double origin, + double scale, + double decay = 0.5, + double offset = 0) + => Gauss(new ExpressionFieldDefinition(path), origin, scale, decay, offset); + + /// + /// Creates a function that calculates the base-10 logarithm of a number. + /// + /// The number. + /// A logarithmic score function. + public ScoreFunction Log(ScoreFunction operand) => + new UnaryScoreFunction("log", operand); + + /// + /// Creates a function that adds 1 to a number and then calculates its base-10 logarithm. + /// + /// The number. + /// A logarithmic score function. + public ScoreFunction Log1p(ScoreFunction operand) => + new UnaryScoreFunction("log1p", operand); + } + + internal sealed class PathScoreFunction : ScoreFunction + { + private readonly PathDefinition _path; + private readonly double _undefined; + + public PathScoreFunction(PathDefinition path, double undefined) + { + _path = Ensure.IsNotNull(path, nameof(path)); + _undefined = undefined; + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegister) + { + var renderedPath = _path.Render(documentSerializer, serializerRegister); + var pathDocument = _undefined == 0 ? renderedPath : new BsonDocument() + { + { "value", renderedPath }, + { "undefined", _undefined } + }; + + return new("path", pathDocument); + } + } + + internal sealed class RelevanceScoreFunction : ScoreFunction + { + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegister) => + new("score", "relevance"); + } + + internal sealed class ConstantScoreFunction : ScoreFunction + { + private readonly double _value; + + public ConstantScoreFunction(double value) + { + _value = value; + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegister) => + new("constant", _value); + } + + internal sealed class ArithmeticScoreFunction : ScoreFunction + { + private readonly string _operatorName; + private readonly IEnumerable> _operands; + + public ArithmeticScoreFunction(string operatorName, IEnumerable> operands) + { + _operatorName = operatorName; + _operands = Ensure.IsNotNull(operands, nameof(operands)); + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegister) => + new(_operatorName, new BsonArray(_operands.Select(o => o.Render(documentSerializer, serializerRegister)))); + } + + internal sealed class GaussScoreFunction : ScoreFunction + { + private readonly PathDefinition _path; + private readonly double _origin; + private readonly double _scale; + private readonly double _decay; + private readonly double _offset; + + public GaussScoreFunction( + PathDefinition path, + double origin, + double scale, + double decay, + double offset) + { + _path = Ensure.IsNotNull(path, nameof(path)); + _origin = origin; + _scale = scale; + _decay = Ensure.IsBetween(decay, 0, 1, nameof(decay)); + _offset = offset; + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegister) => + new("gauss", new BsonDocument() + { + { "path", _path.Render(documentSerializer, serializerRegister) }, + { "origin", _origin }, + { "scale", _scale }, + { "decay", _decay, _decay != 0.5 }, + { "offset", _offset, _offset != 0 }, + }); + } + + internal sealed class UnaryScoreFunction : ScoreFunction + { + private readonly string _operatorName; + private readonly ScoreFunction _operand; + + public UnaryScoreFunction(string operatorName, ScoreFunction operand) + { + _operatorName = operatorName; + _operand = Ensure.IsNotNull(operand, nameof(operand)); + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegister) => + new(_operatorName, _operand.Render(documentSerializer, serializerRegister)); + } +} diff --git a/src/MongoDB.Driver/Search/SearchCountOptions.cs b/src/MongoDB.Driver/Search/SearchCountOptions.cs index 7f26fef5c8c..2c8d2d3bb0c 100644 --- a/src/MongoDB.Driver/Search/SearchCountOptions.cs +++ b/src/MongoDB.Driver/Search/SearchCountOptions.cs @@ -20,7 +20,7 @@ namespace MongoDB.Driver.Search /// /// Options for counting the search results. /// - public class SearchCountOptions + public sealed class SearchCountOptions { private SearchCountType _type = SearchCountType.LowerBound; private int? _threshold; @@ -44,8 +44,8 @@ public SearchCountType Type set => _threshold = Ensure.IsNullOrGreaterThanZero(value, nameof(value)); } - internal BsonDocument Render() - => new() + internal BsonDocument Render() => + new() { { "type", _type.ToCamelCase(), _type != SearchCountType.LowerBound }, { "threshold", _threshold, _threshold != null } diff --git a/src/MongoDB.Driver/Search/SearchCountType.cs b/src/MongoDB.Driver/Search/SearchCountType.cs index 4dfac693a98..4312ba32312 100644 --- a/src/MongoDB.Driver/Search/SearchCountType.cs +++ b/src/MongoDB.Driver/Search/SearchCountType.cs @@ -1,4 +1,4 @@ -// Copyright 2021-present MongoDB Inc. +// Copyright 2010-present MongoDB Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/MongoDB.Driver/Search/SearchDefinition.cs b/src/MongoDB.Driver/Search/SearchDefinition.cs index 8b7ec459bf2..fa65af6fa6f 100644 --- a/src/MongoDB.Driver/Search/SearchDefinition.cs +++ b/src/MongoDB.Driver/Search/SearchDefinition.cs @@ -102,4 +102,62 @@ public JsonSearchDefinition(string json) public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => BsonDocument.Parse(Json); } + + internal abstract class OperatorSearchDefinition : SearchDefinition + { + private protected enum OperatorType + { + Autocomplete, + Compound, + EmbeddedDocument, + Equals, + Exists, + Facet, + GeoShape, + GeoWithin, + MoreLikeThis, + Near, + Phrase, + QueryString, + Range, + Regex, + Search, + Span, + Term, + Text, + Wildcard + } + + private readonly PathDefinition _path; + private readonly ScoreDefinition _score; + private readonly OperatorType _operatorType; + + private protected OperatorSearchDefinition(OperatorType operatorType) : this(operatorType, null) + { + } + + private protected OperatorSearchDefinition(OperatorType operatorType, ScoreDefinition score) + { + _operatorType = operatorType; + _score = score; + } + + private protected OperatorSearchDefinition(OperatorType operatorType, PathDefinition path, ScoreDefinition score) + { + _operatorType = operatorType; + _path = Ensure.IsNotNull(path, nameof(path)); + _score = score; + } + + private protected virtual BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => new(); + + public sealed override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) + { + var renderedOperator = RenderOperator(documentSerializer, serializerRegistry); + renderedOperator.Add("path", () => _path.Render(documentSerializer, serializerRegistry), _path != null); + renderedOperator.Add("score", () => _score.Render(documentSerializer, serializerRegistry), _score != null); + + return new(_operatorType.ToCamelCase(), renderedOperator); + } + } } diff --git a/src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs b/src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs index 14598e090c4..2af38d071ce 100644 --- a/src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs +++ b/src/MongoDB.Driver/Search/SearchDefinitionBuilder.cs @@ -13,10 +13,10 @@ // limitations under the License. using System; +using System.Collections.Generic; using System.Linq.Expressions; using MongoDB.Bson; -using MongoDB.Bson.Serialization; -using MongoDB.Driver.Core.Misc; +using MongoDB.Driver.GeoJsonObjectModel; namespace MongoDB.Driver.Search { @@ -26,6 +26,574 @@ namespace MongoDB.Driver.Search /// The type of the document. public sealed class SearchDefinitionBuilder { + /// + /// Creates a search definition that performs a search for a word or phrase that contains + /// a sequence of characters from an incomplete input string. + /// + /// The query definition specifying the string or strings to search for. + /// The indexed field to search. + /// The order in which to search for tokens. + /// The options for fuzzy search. + /// The score modifier. + /// An autocomplete search definition. + public SearchDefinition Autocomplete( + QueryDefinition query, + PathDefinition path, + AutocompleteTokenOrder tokenOrder = AutocompleteTokenOrder.Any, + FuzzyOptions fuzzy = null, + ScoreDefinition score = null) => + new AutocompleteSearchDefinition(query, path, tokenOrder, fuzzy, score); + + /// + /// Creates a search definition that performs a search for a word or phrase that contains + /// a sequence of characters from an incomplete search string. + /// + /// The type of the field. + /// The query definition specifying the string or strings to search for. + /// The indexed field to search. + /// The order in which to search for tokens. + /// The options for fuzzy search. + /// The score modifier. + /// An autocomplete search definition. + public SearchDefinition Autocomplete( + QueryDefinition query, + Expression> path, + AutocompleteTokenOrder tokenOrder = AutocompleteTokenOrder.Any, + FuzzyOptions fuzzy = null, + ScoreDefinition score = null) + => Autocomplete(query, new ExpressionFieldDefinition(path), tokenOrder, fuzzy, score); + + /// + /// Creates a search definition that combines two or more operators into a single query. + /// + /// + public CompoundFluent Compound() => new CompoundFluentImpl(); + + /// + /// Creates a search definition that queries for documents where an indexed field is equal + /// to the specified value. + /// + /// The indexed field to search. + /// The value to query for. + /// The score modifier. + /// An equality search definition. + public SearchDefinition Equals( + FieldDefinition path, + bool value, + ScoreDefinition score = null) => + new EqualsSearchDefinition(path, value, score); + + /// + /// Creates a search definition that queries for documents where an indexed field is equal + /// to the specified value. + /// + /// The indexed field to search. + /// The value to query for. + /// The score modifier. + /// An equality search definition. + public SearchDefinition Equals( + FieldDefinition path, + ObjectId value, + ScoreDefinition score = null) => + new EqualsSearchDefinition(path, value, score); + + /// + /// Creates a search definition that queries for documents where an indexed field is equal + /// to the specified value. + /// + /// The indexed field to search. + /// The value to query for. + /// The score modifier. + /// An equality search definition. + public SearchDefinition Equals( + Expression> path, + bool value, + ScoreDefinition score = null) => + Equals(new ExpressionFieldDefinition(path), value, score); + + /// + /// Creates a search definition that queries for documents where an indexed field is equal + /// to the specified value. + /// + /// The indexed field to search. + /// The value to query for. + /// The score modifier. + /// An equality search definition. + public SearchDefinition Equals( + Expression> path, + ObjectId value, + ScoreDefinition score = null) => + Equals(new ExpressionFieldDefinition(path), value, score); + + /// + /// Creates a search definition that tests if a path to a specified indexed field name + /// exists in a document. + /// + /// The field to test for. + /// An existence search definition. + public SearchDefinition Exists(FieldDefinition path) => + new ExistsSearchDefinition(path); + + /// + /// Creates a search definition that tests if a path to a specified indexed field name + /// exists in a document. + /// + /// The type of the field. + /// The field to test for. + /// An existence search definition. + public SearchDefinition Exists(Expression> path) => + Exists(new ExpressionFieldDefinition(path)); + + /// + /// Creates a search definition that groups results by values or ranges in the specified + /// faceted fields and returns the count for each of those groups. + /// + /// The operator to use to perform the facet over. + /// Information for bucketing the data for each facet. + /// A facet search definition. + public SearchDefinition Facet( + SearchDefinition @operator, + IEnumerable> facets) => + new FacetSearchDefinition(@operator, facets); + + /// + /// Creates a search definition that groups results by values or ranges in the specified + /// faceted fields and returns the count for each of those groups. + /// + /// The operator to use to perform the facet over. + /// Information for bucketing the data for each facet. + /// A facet search definition. + public SearchDefinition Facet( + SearchDefinition @operator, + params SearchFacet[] facets) => + Facet(@operator, (IEnumerable>)facets); + + /// + /// Creates a search definition that queries for shapes with a given geometry. + /// + /// The type of the coordinates. + /// + /// GeoJSON object specifying the Polygon, MultiPolygon, or LineString shape or point + /// to search. + /// + /// Indexed geo type field or fields to search. + /// + /// Relation of the query shape geometry to the indexed field geometry. + /// + /// The score modifier. + /// A geo shape search definition. + public SearchDefinition GeoShape( + GeoJsonGeometry geometry, + PathDefinition path, + GeoShapeRelation relation, + ScoreDefinition score = null) + where TCoordinates : GeoJsonCoordinates => + new GeoShapeSearchDefinition(geometry, path, relation, score); + + /// + /// Creates a search definition that queries for shapes with a given geometry. + /// + /// The type of the coordinates. + /// The type of the field. + /// + /// GeoJSON object specifying the Polygon, MultiPolygon, or LineString shape or point + /// to search. + /// + /// Indexed geo type field or fields to search. + /// + /// Relation of the query shape geometry to the indexed field geometry. + /// + /// The score modifier. + /// A geo shape search definition. + public SearchDefinition GeoShape( + GeoJsonGeometry geometry, + Expression> path, + GeoShapeRelation relation, + ScoreDefinition score = null) + where TCoordinates : GeoJsonCoordinates => + GeoShape( + geometry, + new ExpressionFieldDefinition(path), + relation, + score); + + /// + /// Creates a search definition that queries for geographic points within a given + /// geometry. + /// + /// The type of the coordinates. + /// + /// GeoJSON object specifying the MultiPolygon or Polygon to search within. + /// + /// Indexed geo type field or fields to search. + /// The score modifier. + /// A geo within search definition. + public SearchDefinition GeoWithin( + GeoJsonGeometry geometry, + PathDefinition path, + ScoreDefinition score = null) + where TCoordinates : GeoJsonCoordinates => + GeoWithin(new GeoWithinGeometry(geometry), path, score); + + /// + /// Creates a search definition that queries for geographic points within a given + /// geometry. + /// + /// The type of the coordinates. + /// The type of the field. + /// + /// GeoJSON object specifying the MultiPolygon or Polygon to search within. + /// + /// Indexed geo type field or fields to search. + /// The score modifier. + /// A geo within search definition. + public SearchDefinition GeoWithin( + GeoJsonGeometry geometry, + Expression> path, + ScoreDefinition score = null) + where TCoordinates : GeoJsonCoordinates => + GeoWithin(new GeoWithinGeometry(geometry), path, score); + + /// + /// Creates a search definition that queries for geographic points within a given geo object. + /// + /// The type of the coordinates. + /// The type of the field. + /// Object that specifies the geo object to search within./// + /// Indexed geo type field or fields to search. + /// The score modifier. + /// A geo within search definition. + public SearchDefinition GeoWithin( + GeoWithin geoWithinQuery, + Expression> path, + ScoreDefinition score = null) + where TCoordinates : GeoJsonCoordinates => + GeoWithin(geoWithinQuery, new ExpressionFieldDefinition(path), score); + + /// + /// Creates a search definition that queries for geographic points within a given geo object. + /// + /// The type of the coordinates. + /// Object that specifies the geo object to search within./// + /// Indexed geo type field or fields to search. + /// The score modifier. + /// A geo within search definition. + public SearchDefinition GeoWithin( + GeoWithin geoWithinQuery, + PathDefinition path, + ScoreDefinition score = null) + where TCoordinates : GeoJsonCoordinates => + new GeoWithinSearchDefinition(geoWithinQuery, path, score); + + /// + /// Creates a search definition that returns documents similar to the input documents. + /// + /// + /// One or more documents that Atlas Search uses to extract representative terms for. + /// + /// A more like this search definition. + public SearchDefinition MoreLikeThis(IEnumerable like) => + new MoreLikeThisSearchDefinition(like); + + /// + /// Creates a search definition that returns documents similar to the input documents. + /// + /// + /// One or more documents that Atlas Search uses to extract representative terms for. + /// + /// A more like this search definition. + public SearchDefinition MoreLikeThis(params TDocument[] like) => + MoreLikeThis((IEnumerable)like); + + /// + /// Creates a search definition that supports querying and scoring numeric and date values. + /// + /// The indexed field or fields to search. + /// The number, date, or geographic point to search near. + /// The value to use to calculate scores of result documents. + /// The score modifier. + /// A near search definition. + public SearchDefinition Near( + PathDefinition path, + double origin, + double pivot, + ScoreDefinition score = null) => + new NearSearchDefinition(path, origin, pivot, score); + + /// + /// Creates a search definition that supports querying and scoring numeric and date values. + /// + /// The type of the field. + /// The indexed field or fields to search. + /// The number, date, or geographic point to search near. + /// The value to use to calculate scores of result documents. + /// The score modifier. + /// A near search definition. + public SearchDefinition Near( + Expression> path, + double origin, + double pivot, + ScoreDefinition score = null) => + Near(new ExpressionFieldDefinition(path), origin, pivot, score); + + /// + /// Creates a search definition that supports querying and scoring numeric and date values. + /// + /// The indexed field or fields to search. + /// The number, date, or geographic point to search near. + /// The value to use to calculate scores of result documents. + /// The score modifier. + /// A near search definition. + public SearchDefinition Near( + PathDefinition path, + int origin, + int pivot, + ScoreDefinition score = null) => + new NearSearchDefinition(path, new BsonInt32(origin), new BsonInt32(pivot), score); + + /// + /// Creates a search definition that supports querying and scoring numeric and date values. + /// + /// The type of the field. + /// The indexed field or fields to search. + /// The number, date, or geographic point to search near. + /// The value to use to calculate scores of result documents. + /// The score modifier. + /// A near search definition. + public SearchDefinition Near( + Expression> path, + int origin, + int pivot, + ScoreDefinition score = null) => + Near(new ExpressionFieldDefinition(path), origin, pivot, score); + + /// + /// Creates a search definition that supports querying and scoring numeric and date values. + /// + /// The indexed field or fields to search. + /// The number, date, or geographic point to search near. + /// The value to use to calculate scores of result documents. + /// The score modifier. + /// A near search definition. + public SearchDefinition Near( + PathDefinition path, + long origin, + long pivot, + ScoreDefinition score = null) => + new NearSearchDefinition(path, new BsonInt64(origin), new BsonInt64(pivot), score); + + /// + /// Creates a search definition that supports querying and scoring numeric and date values. + /// + /// The type of the field. + /// The indexed field or fields to search. + /// The number, date, or geographic point to search near. + /// The value to use to calculate scores of result documents. + /// The score modifier. + /// A near search definition. + public SearchDefinition Near( + Expression> path, + long origin, + long pivot, + ScoreDefinition score = null) => + Near(new ExpressionFieldDefinition(path), origin, pivot, score); + + /// + /// Creates a search definition that supports querying and scoring numeric and date values. + /// + /// The indexed field or fields to search. + /// The number, date, or geographic point to search near. + /// The value to use to calculate scores of result documents. + /// The score modifier. + /// A near search definition. + public SearchDefinition Near( + PathDefinition path, + DateTime origin, + long pivot, + ScoreDefinition score = null) => + new NearSearchDefinition(path, new BsonDateTime(origin), new BsonInt64(pivot), score); + + /// + /// Creates a search definition that supports querying and scoring numeric and date values. + /// + /// The type of the field. + /// The indexed field or fields to search. + /// The number, date, or geographic point to search near. + /// The value to use to calculate scores of result documents. + /// The score modifier. + /// A near search definition. + public SearchDefinition Near( + Expression> path, + DateTime origin, + long pivot, + ScoreDefinition score = null) => + Near(new ExpressionFieldDefinition(path), origin, pivot, score); + + /// + /// Creates a search definition that supports querying and scoring numeric and date values. + /// + /// The type of the coordinates. + /// The indexed field or fields to search. + /// The number, date, or geographic point to search near. + /// The value to use to calculate scores of result documents. + /// The score modifier. + /// A near search definition. + public SearchDefinition Near( + PathDefinition path, + GeoJsonPoint origin, + double pivot, + ScoreDefinition score = null) + where TCoordinates : GeoJsonCoordinates => + new NearSearchDefinition(path, origin.ToBsonDocument(), pivot, score); + + /// + /// Creates a search definition that supports querying and scoring numeric and date values. + /// + /// The type of the coordinates + /// The type of the fields. + /// The indexed field or fields to search. + /// The number, date, or geographic point to search near. + /// The value to user to calculate scores of result documents. + /// The score modifier. + /// A near search definition. + public SearchDefinition Near( + Expression> path, + GeoJsonPoint origin, + double pivot, + ScoreDefinition score = null) + where TCoordinates : GeoJsonCoordinates => + Near(new ExpressionFieldDefinition(path), origin, pivot, score); + + /// + /// Creates a search definition that performs search for documents containing an ordered + /// sequence of terms. + /// + /// The string or strings to search for. + /// The indexed field or fields to search. + /// The allowable distance between words in the query phrase. + /// The score modifier. + /// A phrase search definition. + public SearchDefinition Phrase( + QueryDefinition query, + PathDefinition path, + int? slop = null, + ScoreDefinition score = null) => + new PhraseSearchDefinition(query, path, slop, score); + + /// + /// Creates a search definition that performs search for documents containing an ordered + /// sequence of terms. + /// + /// The type of the field. + /// The string or strings to search for. + /// The indexed field or fields to search. + /// The allowable distance between words in the query phrase. + /// The score modifier. + /// A phrase search definition. + public SearchDefinition Phrase( + QueryDefinition query, + Expression> path, + int? slop = null, + ScoreDefinition score = null) => + Phrase(query, new ExpressionFieldDefinition(path), slop, score); + + /// + /// Creates a search definition that queries a combination of indexed fields and values. + /// + /// The indexed field to search by default. + /// One or more indexed fields and values to search. + /// The score modifier. + /// A query string search definition. + public SearchDefinition QueryString( + FieldDefinition defaultPath, + string query, + ScoreDefinition score = null) => + new QueryStringSearchDefinition(defaultPath, query, score); + + /// + /// Creates a search definition that queries a combination of indexed fields and values. + /// + /// The type of the field. + /// The indexed field to search by default. + /// One or more indexed fields and values to search. + /// The score modifier. + /// A query string search definition. + public SearchDefinition QueryString( + Expression> defaultPath, + string query, + ScoreDefinition score = null) => + QueryString(new ExpressionFieldDefinition(defaultPath), query, score); + + /// + /// Creates a search definition that queries for documents where a floating-point + /// field is in the specified range. + /// + /// A fluent range interface. + public SearchDefinition Range( + SearchRange range, + Expression> path, + ScoreDefinition score = null) + where TField : struct, IComparable => + Range(range, new ExpressionFieldDefinition(path), score); + + /// + /// Creates a search definition that queries for documents where a floating-point + /// field is in the specified range. + /// + /// A fluent range interface. + public SearchDefinition Range( + SearchRange range, + PathDefinition path, + ScoreDefinition score = null) + where TField : struct, IComparable => + new RangeSearchDefinition(range, path, score); + + /// + /// Creates a search definition that interprets the query as a regular expression. + /// + /// The string or strings to search for. + /// The indexed field or fields to search. + /// + /// Must be set to true if the query is run against an analyzed field. + /// + /// The score modifier. + /// A regular expression search definition. + public SearchDefinition Regex( + QueryDefinition query, + PathDefinition path, + bool allowAnalyzedField = false, + ScoreDefinition score = null) + { + return new RegexSearchDefinition(query, path, allowAnalyzedField, score); + } + + /// + /// Creates a search definition that interprets the query as a regular expression. + /// + /// The type of the field. + /// The string or strings to search for. + /// The indexed field or fields to search. + /// + /// Must be set to true if the query is run against an analyzed field. + /// + /// The score modifier. + /// A regular expression search definition. + public SearchDefinition Regex( + QueryDefinition query, + Expression> path, + bool allowAnalyzedField = false, + ScoreDefinition score = null) => + Regex(query, new ExpressionFieldDefinition(path), allowAnalyzedField, score); + + /// + /// Creates a search definition that finds text search matches within regions of a text + /// field. + /// + /// The span clause. + /// A span search definition. + public SearchDefinition Span(SpanDefinition clause) => + new SpanSearchDefinition(clause); + /// /// Creates a search definition that performs full-text search using the analyzer specified /// in the index configuration. @@ -58,40 +626,42 @@ public sealed class SearchDefinitionBuilder FuzzyOptions fuzzy = null, ScoreDefinition score = null) => Text(query, new ExpressionFieldDefinition(path), fuzzy, score); - } - internal sealed class TextSearchDefinition : SearchDefinition - { - private readonly QueryDefinition _query; - private readonly PathDefinition _path; - private readonly FuzzyOptions _fuzzy; - private readonly ScoreDefinition _score; - - public TextSearchDefinition( + /// + /// Creates a search definition that uses special characters in the search string that can + /// match any character. + /// + /// The string or strings to search for. + /// The indexed field or fields to search. + /// + /// Must be set to true if the query is run against an analyzed field. + /// + /// The score modifier. + /// A wildcard search definition. + public SearchDefinition Wildcard( QueryDefinition query, PathDefinition path, - FuzzyOptions fuzzy, - ScoreDefinition score) - { - _query = Ensure.IsNotNull(query, nameof(query)); - _path = Ensure.IsNotNull(path, nameof(path)); - _fuzzy = fuzzy; - _score = score; - } + bool allowAnalyzedField = false, + ScoreDefinition score = null) => + new WildcardSearchDefinition(query, path, allowAnalyzedField, score); - public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) - => new() - { - { - "text", - new BsonDocument() - { - { "query", _query.Render() }, - { "path", _path.Render(documentSerializer, serializerRegistry) }, - { "fuzzy", () => _fuzzy.Render(), _fuzzy != null }, - { "score", () => _score.Render(documentSerializer, serializerRegistry), _score != null } - } - } - }; + /// + /// Creates a search definition that uses special characters in the search string that can + /// match any character. + /// + /// The type of the field. + /// The string or strings to search for. + /// The indexed field or fields to search. + /// + /// Must be set to true if the query is run against an analyzed field. + /// + /// The score modifier. + /// A wildcard search definition. + public SearchDefinition Wildcard( + QueryDefinition query, + Expression> path, + bool allowAnalyzedField = false, + ScoreDefinition score = null) => + Wildcard(query, new ExpressionFieldDefinition(path), allowAnalyzedField, score); } } diff --git a/src/MongoDB.Driver/Search/SearchDefinitions.cs b/src/MongoDB.Driver/Search/SearchDefinitions.cs new file mode 100644 index 00000000000..44e73bcdd9a --- /dev/null +++ b/src/MongoDB.Driver/Search/SearchDefinitions.cs @@ -0,0 +1,379 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Linq; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; +using MongoDB.Driver.GeoJsonObjectModel; + +namespace MongoDB.Driver.Search +{ + internal sealed class AutocompleteSearchDefinition : OperatorSearchDefinition + { + private readonly QueryDefinition _query; + private readonly AutocompleteTokenOrder _tokenOrder; + private readonly FuzzyOptions _fuzzy; + + public AutocompleteSearchDefinition( + QueryDefinition query, + PathDefinition path, + AutocompleteTokenOrder tokenOrder, + FuzzyOptions fuzzy, + ScoreDefinition score) + : base(OperatorType.Autocomplete, path, score) + { + _query = Ensure.IsNotNull(query, nameof(query)); + _tokenOrder = tokenOrder; + _fuzzy = fuzzy; + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "query", _query.Render() }, + { "tokenOrder", _tokenOrder.ToCamelCase(), _tokenOrder == AutocompleteTokenOrder.Sequential }, + { "fuzzy", () => _fuzzy.Render(), _fuzzy != null }, + }; + } + + internal sealed class CompoundSearchDefinition : OperatorSearchDefinition + { + private readonly List> _must; + private readonly List> _mustNot; + private readonly List> _should; + private readonly List> _filter; + private readonly int _minimumShouldMatch; + + public CompoundSearchDefinition( + List> must, + List> mustNot, + List> should, + List> filter, + int minimumShouldMatch) : base(OperatorType.Compound) + { + // This constructor should always be called from a fluent interface that + // ensures that the parameters are not null and copies the lists, so there is + // no need to do any of that here. + _must = must; + _mustNot = mustNot; + _should = should; + _filter = filter; + _minimumShouldMatch = minimumShouldMatch; + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) + { + return new() + { + { "must", Render(_must), _must != null }, + { "mustNot", Render(_mustNot), _mustNot != null }, + { "should", Render(_should), _should != null }, + { "filter", Render(_filter), _filter != null }, + { "minimumShouldMatch", _minimumShouldMatch, _minimumShouldMatch > 0 }, + }; + + Func Render(List> searchDefinitions) => + () => new BsonArray(searchDefinitions.Select(clause => clause.Render(documentSerializer, serializerRegistry))); + } + } + + internal sealed class EqualsSearchDefinition : OperatorSearchDefinition + { + private readonly BsonValue _value; + + public EqualsSearchDefinition(FieldDefinition path, BsonValue value, ScoreDefinition score) + : base(OperatorType.Equals, path, score) + { + _value = value; + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new("value", _value); + } + + internal sealed class ExistsSearchDefinition : OperatorSearchDefinition + { + public ExistsSearchDefinition(FieldDefinition path) : base(OperatorType.Exists, path, null) + { + } + } + + internal sealed class FacetSearchDefinition : OperatorSearchDefinition + { + private readonly SearchDefinition _operator; + private readonly IEnumerable> _facets; + + public FacetSearchDefinition(SearchDefinition @operator, IEnumerable> facets) + : base(OperatorType.Facet) + { + _operator = Ensure.IsNotNull(@operator, nameof(@operator)); + _facets = Ensure.IsNotNull(facets, nameof(facets)); + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "operator", _operator.Render(documentSerializer, serializerRegistry) }, + { "facets", new BsonDocument(_facets.Select(f => new BsonElement(f.Name, f.Render(documentSerializer, serializerRegistry)))) } + }; + } + + internal sealed class GeoShapeSearchDefinition : OperatorSearchDefinition + where TCoordinates : GeoJsonCoordinates + { + private readonly GeoJsonGeometry _geometry; + private readonly GeoShapeRelation _relation; + + public GeoShapeSearchDefinition( + GeoJsonGeometry geometry, + PathDefinition path, + GeoShapeRelation relation, + ScoreDefinition score) + : base(OperatorType.GeoShape, path, score) + { + _geometry = Ensure.IsNotNull(geometry, nameof(geometry)); + _relation = relation; + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "geometry", _geometry.ToBsonDocument() }, + { "relation", _relation.ToCamelCase() } + }; + } + + internal sealed class GeoWithinSearchDefinition : OperatorSearchDefinition + where TCoordinates : GeoJsonCoordinates + { + private readonly GeoWithin _geoWithinQuery; + + public GeoWithinSearchDefinition( + GeoWithin geoWithinQuery, + PathDefinition path, + ScoreDefinition score) + : base(OperatorType.GeoWithin, path, score) + { + _geoWithinQuery = Ensure.IsNotNull(geoWithinQuery, nameof(geoWithinQuery)); + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new(_geoWithinQuery.Render()); + } + + internal sealed class MoreLikeThisSearchDefinition : OperatorSearchDefinition + { + private readonly IEnumerable _like; + + public MoreLikeThisSearchDefinition(IEnumerable like) : base(OperatorType.MoreLikeThis) + { + _like = Ensure.IsNotNull(like, nameof(like)); + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new("like", new BsonArray(_like.Select(e => e.ToBsonDocument(documentSerializer)))); + } + + internal sealed class NearSearchDefinition : OperatorSearchDefinition + { + private readonly BsonValue _origin; + private readonly BsonValue _pivot; + + public NearSearchDefinition( + PathDefinition path, + BsonValue origin, + BsonValue pivot, + ScoreDefinition score = null) + : base(OperatorType.Near, path, score) + { + _origin = origin; + _pivot = pivot; + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "origin", _origin }, + { "pivot", _pivot } + }; + } + + internal sealed class PhraseSearchDefinition : OperatorSearchDefinition + { + private readonly QueryDefinition _query; + private readonly int? _slop; + + public PhraseSearchDefinition( + QueryDefinition query, + PathDefinition path, + int? slop, + ScoreDefinition score) + : base(OperatorType.Phrase, path, score) + { + _query = Ensure.IsNotNull(query, nameof(query)); + _slop = slop; + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "query", _query.Render() }, + { "slop", _slop, _slop != null } + }; + } + + internal sealed class QueryStringSearchDefinition : OperatorSearchDefinition + { + private readonly FieldDefinition _defaultPath; + private readonly string _query; + + public QueryStringSearchDefinition(FieldDefinition defaultPath, string query, ScoreDefinition score) + : base(OperatorType.QueryString, score) + { + _defaultPath = Ensure.IsNotNull(defaultPath, nameof(defaultPath)); + _query = Ensure.IsNotNull(query, nameof(query)); + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "defaultPath", _defaultPath.Render(documentSerializer, serializerRegistry).FieldName }, + { "query", _query } + }; + } + + internal sealed class RangeSearchDefinition : OperatorSearchDefinition + where TField : struct, IComparable + { + private readonly SearchRange _range; + + public RangeSearchDefinition( + SearchRange range, + PathDefinition path, + ScoreDefinition score) + : base(OperatorType.Range, path, score) + { + _range = range; + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { _range.IsMinInclusive ? "gte" : "gt", () => ToBsonValue(_range.Min.Value), _range.Min != null }, + { _range.IsMaxInclusive ? "lte" : "lt", () => ToBsonValue(_range.Max.Value), _range.Max != null }, + }; + + private static BsonValue ToBsonValue(TField value) => + value switch + { + sbyte int8Value => (BsonValue)int8Value, + byte uint8Value => (BsonValue)uint8Value, + short int16Value => (BsonValue)int16Value, + ushort uint16Value => (BsonValue)uint16Value, + int int32Value => (BsonValue)int32Value, + uint uint32Value => (BsonValue)uint32Value, + long int64Value => (BsonValue)int64Value, + double doubleValue => (BsonValue)doubleValue, + DateTime dateTimeValue => (BsonValue)dateTimeValue, + _ => throw new InvalidCastException() + }; + } + + internal sealed class RegexSearchDefinition : OperatorSearchDefinition + { + private readonly QueryDefinition _query; + private readonly bool _allowAnalyzedField; + + public RegexSearchDefinition( + QueryDefinition query, + PathDefinition path, + bool allowAnalyzedField, + ScoreDefinition score) : base(OperatorType.Regex, path, score) + { + _query = Ensure.IsNotNull(query, nameof(query)); + _allowAnalyzedField = allowAnalyzedField; + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "query", _query.Render() }, + { "allowAnalyzedField", _allowAnalyzedField, _allowAnalyzedField }, + }; + } + + internal sealed class SpanSearchDefinition : OperatorSearchDefinition + { + private readonly SpanDefinition _clause; + + public SpanSearchDefinition(SpanDefinition clause) : base(OperatorType.Span) + { + _clause = Ensure.IsNotNull(clause, nameof(clause)); + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + _clause.Render(documentSerializer, serializerRegistry); + } + + internal sealed class TextSearchDefinition : OperatorSearchDefinition + { + private readonly QueryDefinition _query; + private readonly FuzzyOptions _fuzzy; + + public TextSearchDefinition( + QueryDefinition query, + PathDefinition path, + FuzzyOptions fuzzy, + ScoreDefinition score) + : base(OperatorType.Text, path, score) + { + _query = Ensure.IsNotNull(query, nameof(query)); + _fuzzy = fuzzy; + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "query", _query.Render() }, + { "fuzzy", () => _fuzzy.Render(), _fuzzy != null }, + }; + } + + internal sealed class WildcardSearchDefinition : OperatorSearchDefinition + { + private readonly QueryDefinition _query; + private readonly bool _allowAnalyzedField; + + public WildcardSearchDefinition( + QueryDefinition query, + PathDefinition path, + bool allowAnalyzedField, + ScoreDefinition score) + : base(OperatorType.Wildcard, path, score) + { + _query = Ensure.IsNotNull(query, nameof(query)); + _allowAnalyzedField = allowAnalyzedField; + } + + private protected override BsonDocument RenderOperator(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "query", _query.Render() }, + { "allowAnalyzedField", _allowAnalyzedField, _allowAnalyzedField }, + }; + } +} diff --git a/src/MongoDB.Driver/Search/SearchFacet.cs b/src/MongoDB.Driver/Search/SearchFacet.cs new file mode 100644 index 00000000000..eaac6ecbeb4 --- /dev/null +++ b/src/MongoDB.Driver/Search/SearchFacet.cs @@ -0,0 +1,48 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using MongoDB.Bson; +using MongoDB.Bson.Serialization; + +namespace MongoDB.Driver.Search +{ + /// + /// Base class for search facets. + /// + /// The type of the document. + public abstract class SearchFacet + { + /// + /// Initializes a new instance of the class. + /// + /// The name of the facet. + protected SearchFacet(string name) + { + Name = name; + } + + /// + /// Gets the name of the facet. + /// + public string Name { get; } + + /// + /// Renders the search facet to a . + /// + /// The document serializer. + /// The serializer registry. + /// A . + public abstract BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry); + } +} diff --git a/src/MongoDB.Driver/Search/SearchFacetBuilder.cs b/src/MongoDB.Driver/Search/SearchFacetBuilder.cs new file mode 100644 index 00000000000..e04593bfd6b --- /dev/null +++ b/src/MongoDB.Driver/Search/SearchFacetBuilder.cs @@ -0,0 +1,274 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// A builder for a search facet. + /// + /// The type of the document. + public sealed class SearchFacetBuilder + { + /// + /// Creates a facet that narrows down Atlas Search results based on the most frequent + /// string values in the specified string field. + /// + /// The name of the facet. + /// The field path to facet on. + /// + /// The maximum number of facet categories to return in the results. + /// + /// A string search facet. + public SearchFacet String(string name, PathDefinition path, int? numBuckets = null) => + new StringSearchFacet(name, path, numBuckets); + + /// + /// Creates a facet that narrows down Atlas Search result based on the most frequent + /// string values in the specified string field. + /// + /// The type of the field. + /// The name of the facet. + /// The field path to facet on. + /// + /// The maximum number of facet categories to return in the results. + /// + /// A string search facet. + public SearchFacet String(string name, Expression> path, int? numBuckets = null) => + String(name, new ExpressionFieldDefinition(path), numBuckets); + + /// + /// Creates a facet that determines the frequency of numeric values by breaking the search + /// results into separate ranges of numbers. + /// + /// The name of the facet. + /// The field path to facet on. + /// + /// A list of numeric values that specify the boundaries for each bucket. + /// + /// + /// The name of an additional bucket that counts documents returned from the operator that + /// do not fall within the specified boundaries. + /// + /// A number search facet. + public SearchFacet Number( + string name, + PathDefinition path, + IEnumerable boundaries, + string @default = null) => + new NumberSearchFacet(name, path, boundaries, @default); + + /// + /// Creates a facet that determines the frequency of numeric values by breaking the search + /// results into separate ranges of numbers. + /// + /// The name of the facet. + /// The field path to facet on. + /// + /// A list of numeric values that specify the boundaries for each bucket. + /// + /// A number search facet. + public SearchFacet Number( + string name, + PathDefinition path, + params BsonValue[] boundaries) => + Number(name, path, (IEnumerable)boundaries); + + /// + /// Creates a facet that determines the frequency of numeric values by breaking the search + /// results into separate ranges of numbers. + /// + /// The type of the field. + /// The name of the facet. + /// The field path to facet on. + /// + /// A list of numeric values that specify the boundaries for each bucket. + /// + /// + /// The name of an additional bucket that counts documents returned from the operator that + /// do not fall within the specified boundaries. + /// + /// A number search facet. + public SearchFacet Number( + string name, + Expression> path, + IEnumerable boundaries, + string @default = null) => + Number(name, new ExpressionFieldDefinition(path), boundaries, @default); + + /// + /// Creates a facet that determines the frequency of numeric values by breaking the search + /// results into separate ranges of numbers. + /// + /// The type of the field. + /// The name of the facet. + /// The field path to facet on. + /// + /// A list of numeric values that specify the boundaries for each bucket. + /// + /// A number search facet. + public SearchFacet Number( + string name, + Expression> path, + params BsonValue[] boundaries) => + Number(name, new ExpressionFieldDefinition(path), boundaries); + + /// + /// Creates a facet that narrows down search result based on a date. + /// + /// The name of the fact. + /// The field path to facet on. + /// + /// A list of date values that specify the boundaries for each bucket. + /// + /// + /// The name of an additional bucket that counts documents returned from the operator that + /// do not fall within the specified boundaries. + /// + /// A date search facet. + public SearchFacet Date( + string name, + PathDefinition path, + IEnumerable boundaries, + string @default = null) => + new DateSearchFacet(name, path, boundaries, @default); + + /// + /// Creates a facet that narrows down search result based on a date. + /// + /// The name of the fact. + /// The field path to facet on. + /// + /// A list of date values that specify the boundaries for each bucket. + /// + /// A date search facet. + public SearchFacet Date( + string name, + PathDefinition path, + params DateTime[] boundaries) => + Date(name, path, (IEnumerable)boundaries); + + /// + /// Creates a facet that narrows down search result based on a date. + /// + /// The type of the field. + /// The name of the fact. + /// The field path to facet on. + /// + /// A list of date values that specify the boundaries for each bucket. + /// + /// + /// The name of an additional bucket that counts documents returned from the operator that + /// do not fall within the specified boundaries. + /// + /// A date search facet. + public SearchFacet Date( + string name, + Expression> path, + IEnumerable boundaries, + string @default = null) => + Date(name, new ExpressionFieldDefinition(path), boundaries, @default); + + /// + /// Creates a facet that narrows down search result based on a date. + /// + /// The type of the field. + /// The name of the fact. + /// The field path to facet on. + /// + /// A list of date values that specify the boundaries for each bucket. + /// + /// A date search facet. + public SearchFacet Date( + string name, + Expression> path, + params DateTime[] boundaries) => + Date(name, new ExpressionFieldDefinition(path), boundaries); + } + + internal sealed class StringSearchFacet : SearchFacet + { + private readonly PathDefinition _path; + private readonly int? _numBuckets; + + public StringSearchFacet(string name, PathDefinition path, int? numBuckets = null) + : base(name) + { + _path = Ensure.IsNotNull(path, nameof(path)); + _numBuckets = Ensure.IsNullOrBetween(numBuckets, 1, 1000, nameof(numBuckets)); + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "type", "string" }, + { "path", _path.Render(documentSerializer, serializerRegistry) }, + { "numBuckets", _numBuckets, _numBuckets != null } + }; + } + + internal sealed class NumberSearchFacet : SearchFacet + { + private readonly PathDefinition _path; + private readonly IEnumerable _boundaries; + private readonly string _default; + + public NumberSearchFacet(string name, PathDefinition path, IEnumerable boundaries, string @default) + : base(name) + { + _path = Ensure.IsNotNull(path, nameof(path)); + _boundaries = Ensure.IsNotNull(boundaries, nameof(boundaries)); + _default = @default; + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "type", "number" }, + { "path", _path.Render(documentSerializer, serializerRegistry) }, + { "boundaries", new BsonArray(_boundaries) }, + { "default", _default, _default != null } + }; + } + + internal sealed class DateSearchFacet : SearchFacet + { + private readonly PathDefinition _path; + private readonly IEnumerable _boundaries; + private readonly string _default; + + public DateSearchFacet(string name, PathDefinition path, IEnumerable boundaries, string @default) + : base(name) + { + _path = Ensure.IsNotNull(path, nameof(path)); + _boundaries = Ensure.IsNotNull(boundaries, nameof(boundaries)); + _default = @default; + } + + public override BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "type", "date" }, + { "path", _path.Render(documentSerializer, serializerRegistry) }, + { "boundaries", new BsonArray(_boundaries) }, + { "default", _default, _default != null } + }; + } +} diff --git a/src/MongoDB.Driver/Search/SearchMetaResult.cs b/src/MongoDB.Driver/Search/SearchMetaResult.cs new file mode 100644 index 00000000000..83372e2e6f5 --- /dev/null +++ b/src/MongoDB.Driver/Search/SearchMetaResult.cs @@ -0,0 +1,86 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; + +namespace MongoDB.Driver.Search +{ + /// + /// A result set for a search metadata query. + /// + public sealed class SearchMetaResult + { + /// + /// Gets or sets the count result set. + /// + [BsonElement("count")] + public SearchMetaCountResult Count { get; private set; } + + /// + /// Gets or sets the facet result sets. + /// + [BsonElement("facet")] + public Dictionary Facet { get; private set; } + } + + /// + /// A search count result set. + /// + public sealed class SearchMetaCountResult + { + /// + /// Gets or sets the lower bound for this result set. + /// + [BsonElement("lowerBound")] + public long? LowerBound { get; private set; } + + /// + /// Gets or sets the total for this result set. + /// + [BsonElement("total")] + public long? Total { get; private set; } + } + + /// + /// A search facet result set. + /// + public sealed class SearchMetaFacetResult + { + /// + /// Gets or sets a list of bucket result sets. + /// + [BsonElement("buckets")] + public List Buckets { get; private set; } + } + + /// + /// A search facet bucket result set. + /// + public sealed class SearchMetaFacetBucketResult + { + /// + /// Gets or sets the unique identifier that identifies this facet bucket. + /// + [BsonId] + public BsonValue Id { get; private set; } + + /// + /// Gets or sets the count of documents in this facet bucket. + /// + [BsonElement("count")] + public long Count { get; private set; } + } +} diff --git a/src/MongoDB.Driver/Search/SearchRange.cs b/src/MongoDB.Driver/Search/SearchRange.cs new file mode 100644 index 00000000000..3737152c5c8 --- /dev/null +++ b/src/MongoDB.Driver/Search/SearchRange.cs @@ -0,0 +1,118 @@ +using System; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// Object that specifies range of scalar and DateTime values. + /// + /// The type of the range value. + public struct SearchRange where TValue : struct, IComparable + { + /// Empty range. + public static SearchRange Empty { get; } = new(default, default, default, default); + + /// + /// Initializes a new instance of the class. + /// + /// The lower bound of the range. + /// The upper bound of the range + /// Indicates whether the lower bound of the range is inclusive. + /// Indicates whether the upper bound of the range is inclusive. + public SearchRange(TValue? min, TValue? max, bool isMinInclusive, bool isMaxInclusive) + { + if (min != null && max != null) + { + Ensure.IsGreaterThanOrEqualTo(max.Value, min.Value, nameof(max)); + } + + Min = min; + Max = max; + IsMinInclusive = isMinInclusive; + IsMaxInclusive = isMaxInclusive; + } + + /// Gets the lower bound of the range. + public TValue? Min { get; } + /// Gets the lower bound of the range. + public TValue? Max { get; } + /// Gets the value that indicates whether the lower bound of the range is inclusive. + public bool IsMinInclusive { get; } + /// Gets the value that indicates whether the upper bound of the range is inclusive. + public bool IsMaxInclusive { get; } + } + + /// + /// A builder for a SearchRange. + /// + public static class SearchRangeBuilder + { + /// + /// Creates a greater than search range. + /// + /// The value. + /// Search range. + public static SearchRange Gt(TValue value) where TValue : struct, IComparable + => SearchRange.Empty.Gt(value); + + /// + /// Creates a greater or equal than search range. + /// + /// The value. + /// Search range. + public static SearchRange Gte(TValue value) where TValue : struct, IComparable + => SearchRange.Empty.Gte(value); + + /// + /// Creates a less than search range. + /// + /// The value. + /// Search range. + public static SearchRange Lt(TValue value) where TValue : struct, IComparable + => SearchRange.Empty.Lt(value); + + /// + /// Creates a less than or equal search range. + /// + /// The value. + /// search range. + public static SearchRange Lte(TValue value) where TValue : struct, IComparable + => SearchRange.Empty.Lte(value); + + /// + /// Adds a greater than value to a search range. + /// + /// Search range. + /// The value. + /// Search range. + public static SearchRange Gt(this SearchRange searchRange, TValue value) where TValue : struct, IComparable + => new(value, searchRange.Max, false, searchRange.IsMaxInclusive); + + /// + /// Adds a greater or equal than value to a search range. + /// + /// Search range. + /// The value. + /// Search range. + public static SearchRange Gte(this SearchRange searchRange, TValue value) where TValue : struct, IComparable + => new(value, searchRange.Max, true, searchRange.IsMaxInclusive); + + /// + /// Adds a less than value to a search range. + /// + /// Search range. + /// The value. + /// Search range. + public static SearchRange Lt(this SearchRange searchRange, TValue value) where TValue : struct, IComparable + => new(searchRange.Min, value, searchRange.IsMinInclusive, false); + + /// + /// Adds a less than or equal value to a search range. + /// + /// Search range. + /// The value. + /// search range. + public static SearchRange Lte(this SearchRange searchRange, TValue value) where TValue : struct, IComparable + => new(searchRange.Min, value, searchRange.IsMinInclusive, true); + } +} diff --git a/src/MongoDB.Driver/Search/SpanDefinition.cs b/src/MongoDB.Driver/Search/SpanDefinition.cs new file mode 100644 index 00000000000..5e38ef6ae7c --- /dev/null +++ b/src/MongoDB.Driver/Search/SpanDefinition.cs @@ -0,0 +1,50 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using MongoDB.Bson; +using MongoDB.Bson.Serialization; + +namespace MongoDB.Driver.Search +{ + /// + /// Base class for span clauses. + /// + /// + public abstract class SpanDefinition + { + private protected enum ClauseType + { + First, + Near, + Or, + Subtract, + Term + } + + private readonly ClauseType _clauseType; + + private protected SpanDefinition(ClauseType clauseType) => _clauseType = clauseType; + + private protected virtual BsonDocument RenderClause(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => new(); + + /// + /// Renders the span clause to a . + /// + /// The document serializer. + /// The serializer registry. + /// A . + public BsonDocument Render(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new(_clauseType.ToCamelCase(), RenderClause(documentSerializer, serializerRegistry)); + } +} diff --git a/src/MongoDB.Driver/Search/SpanDefinitionBuilder.cs b/src/MongoDB.Driver/Search/SpanDefinitionBuilder.cs new file mode 100644 index 00000000000..2ce723b325b --- /dev/null +++ b/src/MongoDB.Driver/Search/SpanDefinitionBuilder.cs @@ -0,0 +1,198 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Driver; +using MongoDB.Driver.Core.Misc; + +namespace MongoDB.Driver.Search +{ + /// + /// A builder for a span clause. + /// + /// The type of the document. + public sealed class SpanDefinitionBuilder + { + /// + /// Creates a span clause that matches near the beginning of the string. + /// + /// The span operator. + /// The highest position in which to match the query. + /// A first span clause. + public SpanDefinition First(SpanDefinition @operator, int endPositionLte) => + new FirstSpanDefinition(@operator, endPositionLte); + + /// + /// Creates a span clause that matches multiple string found near each other. + /// + /// The clauses. + /// The allowable distance between words in the query phrase. + /// Whether to require that the clauses appear in the specified order. + /// A near span clause. + public SpanDefinition Near( + IEnumerable> clauses, + int slop, + bool inOrder = false) => + new NearSpanDefinition(clauses, slop, inOrder); + + /// + /// Creates a span clause that matches any of its subclauses. + /// + /// The clauses. + /// An or span clause. + public SpanDefinition Or(IEnumerable> clauses) => + new OrSpanDefinition(clauses); + + /// + /// Creates a span clause that matches any of its subclauses. + /// + /// The clauses. + /// An or span clause. + public SpanDefinition Or(params SpanDefinition[] clauses) => + Or((IEnumerable>)clauses); + + /// + /// Creates a span clause that excludes certain strings from the search results. + /// + /// Clause to be included. + /// Clause to be excluded. + /// A subtract span clause. + public SpanDefinition Subtract( + SpanDefinition include, + SpanDefinition exclude) => + new SubtractSpanDefinition(include, exclude); + + /// + /// Creates a span clause that matches a single term. + /// + /// The string or strings to search for. + /// The indexed field or fields to search. + /// A term span clause. + public SpanDefinition Term(QueryDefinition query, PathDefinition path) => + new TermSpanDefinition(query, path); + + /// + /// Creates a span clause that matches a single term. + /// + /// The type of the field. + /// The string or string to search for. + /// The indexed field or fields to search. + /// A term span clause. + public SpanDefinition Term( + QueryDefinition query, + Expression> path) => + Term(query, new ExpressionFieldDefinition(path)); + } + + internal sealed class FirstSpanDefinition : SpanDefinition + { + private readonly SpanDefinition _operator; + private readonly int _endPositionLte; + + public FirstSpanDefinition(SpanDefinition @operator, int endPositionLte) + : base(ClauseType.First) + { + _operator = Ensure.IsNotNull(@operator, nameof(@operator)); + _endPositionLte = endPositionLte; + } + private protected override BsonDocument RenderClause(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "operator", _operator.Render(documentSerializer, serializerRegistry) }, + { "endPositionLte", _endPositionLte } + }; + } + + internal sealed class NearSpanDefinition : SpanDefinition + { + private readonly List> _clauses; + private readonly int _slop; + private readonly bool _inOrder; + + public NearSpanDefinition(IEnumerable> clauses, int slop, bool inOrder) + : base(ClauseType.Near) + { + _clauses = Ensure.IsNotNull(clauses, nameof(clauses)).ToList(); + _slop = slop; + _inOrder = inOrder; + } + + private protected override BsonDocument RenderClause(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "clauses", new BsonArray(_clauses.Select(clause => clause.Render(documentSerializer, serializerRegistry))) }, + { "slop", _slop }, + { "inOrder", _inOrder }, + }; + } + + internal sealed class OrSpanDefinition : SpanDefinition + { + private readonly List> _clauses; + + public OrSpanDefinition(IEnumerable> clauses) + : base(ClauseType.Or) + { + _clauses = Ensure.IsNotNull(clauses, nameof(clauses)).ToList(); + } + + private protected override BsonDocument RenderClause(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new("clauses", new BsonArray(_clauses.Select(clause => clause.Render(documentSerializer, serializerRegistry)))); + } + + internal sealed class SubtractSpanDefinition : SpanDefinition + { + private readonly SpanDefinition _include; + private readonly SpanDefinition _exclude; + + public SubtractSpanDefinition(SpanDefinition include, SpanDefinition exclude) + : base(ClauseType.Subtract) + { + _include = Ensure.IsNotNull(include, nameof(include)); + _exclude = Ensure.IsNotNull(exclude, nameof(exclude)); + } + + private protected override BsonDocument RenderClause(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "include", _include.Render(documentSerializer, serializerRegistry) }, + { "exclude", _exclude.Render(documentSerializer, serializerRegistry) }, + }; + } + + internal sealed class TermSpanDefinition : SpanDefinition + { + private readonly QueryDefinition _query; + private readonly PathDefinition _path; + + public TermSpanDefinition(QueryDefinition query, PathDefinition path) + : base(ClauseType.Term) + { + _query = Ensure.IsNotNull(query, nameof(query)); + _path = Ensure.IsNotNull(path, nameof(path)); + } + + private protected override BsonDocument RenderClause(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry) => + new() + { + { "query", _query.Render() }, + { "path", _path.Render(documentSerializer, serializerRegistry) }, + }; + } +} diff --git a/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs index 0d3b38123e9..c772501da59 100644 --- a/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs @@ -20,6 +20,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; +using MongoDB.Driver.Search; using Moq; using Xunit; @@ -172,6 +173,140 @@ public void UnionWith_should_throw_when_withCollection_is_null() argumentNullException.ParamName.Should().Be("withCollection"); } + [Fact] + public void Search_should_add_expected_stage() + { + var pipeline = new EmptyPipelineDefinition(); + var builder = new SearchDefinitionBuilder(); + var result = pipeline.Search(builder.Text("foo", "bar")); + var stages = RenderStages(result, BsonDocumentSerializer.Instance); + stages[0].Should().Be( + BsonDocument.Parse("{ $search: { text: { query: 'foo', path: 'bar' } } }")); + } + + [Fact] + public void Search_should_add_expected_stage_with_highlight() + { + var pipeline = new EmptyPipelineDefinition(); + var builder = new SearchDefinitionBuilder(); + var result = pipeline.Search(builder.Text("foo", "bar"), new HighlightOptions("foo")); + var stages = RenderStages(result, BsonDocumentSerializer.Instance); + stages[0].Should().BeEquivalentTo( + BsonDocument.Parse("{ $search: { text: { query: 'foo', path: 'bar' }, highlight: { path: 'foo' } } }")); + } + + [Fact] + public void Search_should_add_expected_stage_with_index() + { + var pipeline = new EmptyPipelineDefinition(); + var builder = new SearchDefinitionBuilder(); + var result = pipeline.Search(builder.Text("foo", "bar"), indexName: "foo"); + var stages = RenderStages(result, BsonDocumentSerializer.Instance); + stages[0].Should().Be( + BsonDocument.Parse("{ $search: { text: { query: 'foo', path: 'bar' }, index: 'foo' } }")); + } + + [Fact] + public void Search_should_add_expected_stage_with_count() + { + var pipeline = new EmptyPipelineDefinition(); + var builder = new SearchDefinitionBuilder(); + var count = new SearchCountOptions() + { + Type = SearchCountType.Total + }; + var result = pipeline.Search(builder.Text("foo", "bar"), count: count); + var stages = RenderStages(result, BsonDocumentSerializer.Instance); + stages[0].Should().Be( + BsonDocument.Parse("{ $search: { text: { query: 'foo', path: 'bar' }, count: { type: 'total' } } }")); + } + + [Fact] + public void Search_should_add_expected_stage_with_return_stored_source() + { + var pipeline = new EmptyPipelineDefinition(); + var builder = new SearchDefinitionBuilder(); + var result = pipeline.Search(builder.Text("foo", "bar"), returnStoredSource: true); + var stages = RenderStages(result, BsonDocumentSerializer.Instance); + stages[0].Should().Be( + BsonDocument.Parse("{ $search: { text: { query: 'foo', path: 'bar' }, returnStoredSource: true } }")); + } + + [Fact] + public void Search_should_throw_when_pipeline_is_null() + { + PipelineDefinition pipeline = null; + var builder = new SearchDefinitionBuilder(); + var exception = Record.Exception(() => pipeline.Search(builder.Text("foo", "bar"))); + exception.Should().BeOfType() + .Which.ParamName.Should().Be("pipeline"); + } + + [Fact] + public void Search_should_throw_when_query_is_null() + { + var pipeline = new EmptyPipelineDefinition(); + var exception = Record.Exception(() => pipeline.Search(null)); + exception.Should().BeOfType() + .Which.ParamName.Should().Be("query"); + } + + [Fact] + public void SearchMeta_should_add_expected_stage() + { + var pipeline = new EmptyPipelineDefinition(); + var builder = new SearchDefinitionBuilder(); + var result = pipeline.SearchMeta(builder.Text("foo", "bar")); + var stages = RenderStages(result, BsonDocumentSerializer.Instance); + stages[0].Should().Be( + BsonDocument.Parse("{ $searchMeta: { text: { query: 'foo', path: 'bar' } } }")); + } + + [Fact] + public void SearchMeta_should_add_expected_stage_with_index() + { + var pipeline = new EmptyPipelineDefinition(); + var builder = new SearchDefinitionBuilder(); + var result = pipeline.SearchMeta(builder.Text("foo", "bar"), indexName: "foo"); + var stages = RenderStages(result, BsonDocumentSerializer.Instance); + stages[0].Should().Be( + BsonDocument.Parse("{ $searchMeta: { text: { query: 'foo', path: 'bar' }, index: 'foo' } }")); + } + + [Fact] + public void SearchMeta_should_add_expected_stage_with_count() + { + var pipeline = new EmptyPipelineDefinition(); + var builder = new SearchDefinitionBuilder(); + var count = new SearchCountOptions() + { + Type = SearchCountType.Total + }; + var result = pipeline.SearchMeta(builder.Text("foo", "bar"), count: count); + var stages = RenderStages(result, BsonDocumentSerializer.Instance); + stages[0].Should().Be( + BsonDocument.Parse("{ $searchMeta: { text: { query: 'foo', path: 'bar' }, count: { type: 'total' } } }")); + } + + [Fact] + public void SearchMeta_should_throw_when_pipeline_is_null() + { + PipelineDefinition pipeline = null; + var builder = new SearchDefinitionBuilder(); + var exception = Record.Exception(() => pipeline.SearchMeta(builder.Text("foo", "bar"))); + exception.Should().BeOfType() + .Which.ParamName.Should().Be("pipeline"); + } + + [Fact] + public void SearchMeta_should_throw_when_query_is_null() + { + var pipeline = new EmptyPipelineDefinition(); + var exception = Record.Exception(() => pipeline.SearchMeta(null)); + exception.Should().BeOfType() + .Which.ParamName.Should().Be("query"); + } + // private methods private IList RenderStages(PipelineDefinition pipeline, IBsonSerializer inputSerializer) { diff --git a/tests/MongoDB.Driver.Tests/Search/PathDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/Search/PathDefinitionBuilderTests.cs new file mode 100644 index 00000000000..2f94d72e3e8 --- /dev/null +++ b/tests/MongoDB.Driver.Tests/Search/PathDefinitionBuilderTests.cs @@ -0,0 +1,147 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using FluentAssertions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver.Search; +using Xunit; + +namespace MongoDB.Driver.Tests.Search +{ + public class PathDefinitionBuilderTests + { + [Fact] + public void Single() + { + var subject = CreateSubject(); + + AssertRendered(subject.Single("x"), new BsonString("x")); + } + + [Fact] + public void Single_Typed() + { + var subject = CreateSubject(); + + AssertRendered(subject.Single(x => x.FirstName), new BsonString("fn")); + AssertRendered(subject.Single("FirstName"), new BsonString("fn")); + } + + [Fact] + public void Multi() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Multi("x", "y"), + new BsonArray() + { + new BsonString("x"), + new BsonString("y") + }); + AssertRendered( + subject.Multi( + new List>() + { + "x", + "y" + }), + new BsonArray() + { + new BsonString("x"), + new BsonString("y") + }); + } + + [Fact] + public void Multi_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Multi(x => x.FirstName, x => x.LastName), + new BsonArray() + { + new BsonString("fn"), + new BsonString("ln") + }); + AssertRendered( + subject.Multi("FirstName", "LastName"), + new BsonArray() + { + new BsonString("fn"), + new BsonString("ln") + }); + } + + [Fact] + public void Analyzer() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Analyzer("x", "english"), + "{ value: 'x', multi: 'english' }"); + } + + [Fact] + public void Analyzer_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Analyzer(x => x.FirstName, "english"), + "{ value: 'fn', multi: 'english' }"); + AssertRendered( + subject.Analyzer("FirstName", "english"), + "{ value: 'fn', multi: 'english' }"); + } + + [Fact] + public void Wildcard() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Wildcard("*"), + "{ wildcard: '*' }"); + } + + private void AssertRendered(PathDefinition path, string expected) => + AssertRendered(path, BsonDocument.Parse(expected)); + + private void AssertRendered(PathDefinition path, BsonValue expected) + { + var documentSerializer = BsonSerializer.SerializerRegistry.GetSerializer(); + var renderedPath = path.Render(documentSerializer, BsonSerializer.SerializerRegistry); + + renderedPath.Should().Be(expected); + } + + private PathDefinitionBuilder CreateSubject() => + new PathDefinitionBuilder(); + + private class Person + { + [BsonElement("fn")] + public string FirstName { get; set; } + + [BsonElement("ln")] + public string LastName { get; set; } + } + } +} diff --git a/tests/MongoDB.Driver.Tests/Search/ProjectionDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/Search/ProjectionDefinitionBuilderTests.cs new file mode 100644 index 00000000000..b5b4a4e7784 --- /dev/null +++ b/tests/MongoDB.Driver.Tests/Search/ProjectionDefinitionBuilderTests.cs @@ -0,0 +1,62 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using FluentAssertions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using Xunit; + +namespace MongoDB.Driver.Tests.Search +{ + public class ProjectionDefinitionBuilderTests + { + [Fact] + public void MetaSearchHighlights() + { + var subject = CreateSubject(); + + AssertRendered(subject.MetaSearchHighlights("a"), "{ a: { $meta: 'searchHighlights' } }"); + } + + [Fact] + public void MetaSearchScore() + { + var subject = CreateSubject(); + + AssertRendered(subject.MetaSearchScore("a"), "{ a : { $meta: 'searchScore' } }"); + } + + [Fact] + public void SearchMeta() + { + var subject = CreateSubject(); + + AssertRendered(subject.SearchMeta("a"), "{ a: '$$SEARCH_META' }"); + } + + private void AssertRendered(ProjectionDefinition projection, string expected) => + AssertRendered(projection, BsonDocument.Parse(expected)); + + private void AssertRendered(ProjectionDefinition projection, BsonDocument expected) + { + var documentSerializer = BsonSerializer.SerializerRegistry.GetSerializer(); + var renderedProjection = projection.Render(documentSerializer, BsonSerializer.SerializerRegistry); + + renderedProjection.Should().BeEquivalentTo(expected); + } + + private ProjectionDefinitionBuilder CreateSubject() => + new ProjectionDefinitionBuilder(); + } +} diff --git a/tests/MongoDB.Driver.Tests/Search/ScoreDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/Search/ScoreDefinitionBuilderTests.cs new file mode 100644 index 00000000000..01aca62c86c --- /dev/null +++ b/tests/MongoDB.Driver.Tests/Search/ScoreDefinitionBuilderTests.cs @@ -0,0 +1,96 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using FluentAssertions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver.Search; +using Xunit; + +namespace MongoDB.Driver.Tests.Search +{ + public class ScoreDefinitionBuilderTests + { + [Fact] + public void Boost() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Boost(1), + "{ boost: { value: 1 } }"); + AssertRendered( + subject.Boost("x"), + "{ boost: { path: 'x' } }"); + AssertRendered( + subject.Boost("x", 1), + "{ boost: { path: 'x', undefined: 1 } }"); + } + + [Fact] + public void Boost_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Boost(x => x.Age), + "{ boost: { path: 'age' } }"); + AssertRendered( + subject.Boost("Age"), + "{ boost: { path: 'age' } }"); + } + + [Fact] + public void Constant() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Constant(1), + "{ constant: { value: 1 } }"); + } + + [Fact] + public void Function() + { + var subject = CreateSubject(); + + var functionBuilder = new ScoreFunctionBuilder(); + AssertRendered( + subject.Function(functionBuilder.Path("x")), + "{ function: { path: 'x' } }"); + } + + private void AssertRendered(ScoreDefinition score, string expected) => + AssertRendered(score, BsonDocument.Parse(expected)); + + private void AssertRendered(ScoreDefinition score, BsonDocument expected) + { + var documentSerializer = BsonSerializer.SerializerRegistry.GetSerializer(); + var renderedQuery = score.Render(documentSerializer, BsonSerializer.SerializerRegistry); + + renderedQuery.Should().BeEquivalentTo(expected); + } + + private ScoreDefinitionBuilder CreateSubject() => + new ScoreDefinitionBuilder(); + + private class Person + { + [BsonElement("age")] + public int Age { get; set; } + } + } +} diff --git a/tests/MongoDB.Driver.Tests/Search/SearchDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/Search/SearchDefinitionBuilderTests.cs index a27cd4d125a..9b25943bc3c 100644 --- a/tests/MongoDB.Driver.Tests/Search/SearchDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/Search/SearchDefinitionBuilderTests.cs @@ -1,4 +1,4 @@ -// Copyright 2021-present MongoDB Inc. +// Copyright 2010-present MongoDB Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,6 +13,7 @@ // limitations under the License. using System; +using System.Collections.Generic; using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization; @@ -25,14 +26,692 @@ namespace MongoDB.Driver.Tests.Search { public class SearchDefinitionBuilderTests { + private static readonly GeoJsonPolygon __testPolygon = + new GeoJsonPolygon( + new GeoJsonPolygonCoordinates( + new GeoJsonLinearRingCoordinates( + new List() + { + new GeoJson2DGeographicCoordinates(-161.323242, 22.512557), + new GeoJson2DGeographicCoordinates(-152.446289, 22.065278), + new GeoJson2DGeographicCoordinates(-156.09375, 17.811456), + new GeoJson2DGeographicCoordinates(-161.323242, 22.512557) + }))); + private static readonly GeoWithinBox __testBox = + new GeoWithinBox( + new GeoJsonPoint( + new GeoJson2DGeographicCoordinates(-161.323242, 22.065278)), + new GeoJsonPoint( + new GeoJson2DGeographicCoordinates(-152.446289, 22.512557))); + private static readonly GeoWithinCircle __testCircle = + new GeoWithinCircle( + new GeoJsonPoint( + new GeoJson2DGeographicCoordinates(-161.323242, 22.512557)), + 7.5); + + [Fact] + public void Autocomplete() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Autocomplete("foo", "x"), + "{ autocomplete: { query: 'foo', path: 'x' } }"); + AssertRendered( + subject.Autocomplete("foo", new[] { "x", "y" }), + "{ autocomplete: { query: 'foo', path: ['x', 'y'] } }"); + AssertRendered( + subject.Autocomplete(new[] { "foo", "bar" }, "x"), + "{ autocomplete: { query: ['foo', 'bar'], path: 'x' } }"); + AssertRendered( + subject.Autocomplete(new[] { "foo", "bar" }, new[] { "x", "y" }), + "{ autocomplete: { query: ['foo', 'bar'], path: ['x', 'y'] } }"); + + AssertRendered( + subject.Autocomplete("foo", "x", AutocompleteTokenOrder.Any), + "{ autocomplete: { query: 'foo', path: 'x' } }"); + AssertRendered( + subject.Autocomplete("foo", "x", AutocompleteTokenOrder.Sequential), + "{ autocomplete: { query: 'foo', path: 'x', tokenOrder: 'sequential' } }"); + + AssertRendered( + subject.Autocomplete("foo", "x", fuzzy: new FuzzyOptions()), + "{ autocomplete: { query: 'foo', path: 'x', fuzzy: {} } }"); + AssertRendered( + subject.Autocomplete("foo", "x", fuzzy: new FuzzyOptions() + { + MaxEdits = 1, + PrefixLength = 5, + MaxExpansions = 25 + }), + "{ autocomplete: { query: 'foo', path: 'x', fuzzy: { maxEdits: 1, prefixLength: 5, maxExpansions: 25 } } }"); + + var scoreBuilder = new ScoreDefinitionBuilder(); + AssertRendered( + subject.Autocomplete("foo", "x", score: scoreBuilder.Constant(1)), + "{ autocomplete: { query: 'foo', path: 'x', score: { constant: { value: 1 } } } }"); + } + + [Fact] + public void Autocomplete_Typed() + { + var subject = CreateSubject(); + AssertRendered( + subject.Autocomplete("foo", x => x.FirstName), + "{ autocomplete: { query: 'foo', path: 'fn' } }"); + AssertRendered( + subject.Autocomplete("foo", "FirstName"), + "{ autocomplete: { query: 'foo', path: 'fn' } }"); + + AssertRendered( + subject.Autocomplete( + "foo", + new FieldDefinition[] + { + new ExpressionFieldDefinition(x => x.FirstName), + new ExpressionFieldDefinition(x => x.LastName) + }), + "{ autocomplete: { query: 'foo', path: ['fn', 'ln'] } }"); + AssertRendered( + subject.Autocomplete("foo", new[] { "FirstName", "LastName" }), + "{ autocomplete: { query: 'foo', path: ['fn', 'ln'] } }"); + + AssertRendered( + subject.Autocomplete(new[] { "foo", "bar" }, x => x.FirstName), + "{ autocomplete: { query: ['foo', 'bar'], path: 'fn' } }"); + AssertRendered( + subject.Autocomplete(new[] { "foo", "bar" }, "FirstName"), + "{ autocomplete: { query: ['foo', 'bar'], path: 'fn' } }"); + + AssertRendered( + subject.Autocomplete( + new[] { "foo", "bar" }, + new FieldDefinition[] + { + new ExpressionFieldDefinition(x => x.FirstName), + new ExpressionFieldDefinition(x => x.LastName) + }), + "{ autocomplete: { query: ['foo', 'bar'], path: ['fn', 'ln'] } }"); + AssertRendered( + subject.Autocomplete(new[] { "foo", "bar" }, new[] { "FirstName", "LastName" }), + "{ autocomplete: { query: ['foo', 'bar'], path: ['fn', 'ln'] } }"); + } + + [Fact] + public void Compound() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Compound() + .Must( + subject.Exists("x"), + subject.Exists("y")) + .MustNot( + subject.Exists("foo"), + subject.Exists("bar")) + .Must( + subject.Exists("z")), + "{ compound: { must: [{ exists: { path: 'x' } }, { exists: { path: 'y' } }, { exists: { path: 'z' } }], mustNot: [{ exists: { path: 'foo' } }, { exists: { path: 'bar' } }] } }"); + } + + [Fact] + public void Equals() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Equals("x", true), + "{ equals: { path: 'x', value: true } }"); + AssertRendered( + subject.Equals("x", ObjectId.Empty), + "{ equals: { path: 'x', value: { $oid: '000000000000000000000000' } } }"); + + var scoreBuilder = new ScoreDefinitionBuilder(); + AssertRendered( + subject.Equals("x", true, scoreBuilder.Constant(1)), + "{ equals: { path: 'x', value: true, score: { constant: { value: 1 } } } }"); + } + + [Fact] + public void Equals_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Equals(x => x.Retired, true), + "{ equals: { path: 'ret', value: true } }"); + AssertRendered( + subject.Equals("Retired", true), + "{ equals: { path: 'ret', value: true } }"); + + AssertRendered( + subject.Equals(x => x.Id, ObjectId.Empty), + "{ equals: { path: '_id', value: { $oid: '000000000000000000000000' } } }"); + } + + [Fact] + public void Exists() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Exists("x"), + "{ exists: { path: 'x' } }"); + } + + [Fact] + public void Exists_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Exists(x => x.FirstName), + "{ exists: { path: 'fn' } }"); + AssertRendered( + subject.Exists("FirstName"), + "{ exists: { path: 'fn' } }"); + } + + [Fact] + public void Facet() + { + var subject = CreateSubject(); + var facetBuilder = new SearchFacetBuilder(); + + AssertRendered( + subject.Facet( + subject.Phrase("foo", "x"), + facetBuilder.String("string", "y", 100)), + "{ facet: { operator: { phrase: { query: 'foo', path: 'x' } }, facets: { string: { type: 'string', path: 'y', numBuckets: 100 } } } }"); + } + + [Fact] + public void Facet_Typed() + { + var subject = CreateSubject(); + var facetBuilder = new SearchFacetBuilder(); + + AssertRendered( + subject.Facet( + subject.Phrase("foo", x => x.LastName), + facetBuilder.String("string", x => x.FirstName, 100)), + "{ facet: { operator: { phrase: { query: 'foo', path: 'ln' } }, facets: { string: { type: 'string', path: 'fn', numBuckets: 100 } } } }"); + AssertRendered( + subject.Facet( + subject.Phrase("foo", "LastName"), + facetBuilder.String("string", "FirstName", 100)), + "{ facet: { operator: { phrase: { query: 'foo', path: 'ln' } }, facets: { string: { type: 'string', path: 'fn', numBuckets: 100 } } } }"); + } + + [Fact] + public void Filter() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Compound().Filter( + subject.Exists("x"), + subject.Exists("y")), + "{ compound: { filter: [{ exists: { path: 'x' } }, { exists: { path: 'y' } }] } }"); + } + + [Fact] + public void GeoShape() + { + var subject = CreateSubject(); + + AssertRendered( + subject.GeoShape( + __testPolygon, + "location", + GeoShapeRelation.Disjoint), + "{ geoShape: { geometry: { type: 'Polygon', coordinates: [[[-161.323242, 22.512557], [-152.446289, 22.065278], [-156.09375, 17.811456], [-161.323242, 22.512557]]] }, path: 'location', relation: 'disjoint' } }"); + } + + [Fact] + public void GeoShape_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.GeoShape( + __testPolygon, + x => x.Location, + GeoShapeRelation.Disjoint), + "{ geoShape: { geometry: { type: 'Polygon', coordinates: [[[-161.323242, 22.512557], [-152.446289, 22.065278], [-156.09375, 17.811456], [-161.323242, 22.512557]]] }, path: 'location', relation: 'disjoint' } }"); + AssertRendered( + subject.GeoShape( + __testPolygon, + "Location", + GeoShapeRelation.Disjoint), + "{ geoShape: { geometry: { type: 'Polygon', coordinates: [[[-161.323242, 22.512557], [-152.446289, 22.065278], [-156.09375, 17.811456], [-161.323242, 22.512557]]] }, path: 'location', relation: 'disjoint' } }"); + } + + [Fact] + public void GeoWithin() + { + var subject = CreateSubject(); + + AssertRendered( + subject.GeoWithin(__testPolygon, "location"), + "{ geoWithin: { geometry: { type: 'Polygon', coordinates: [[[-161.323242, 22.512557], [-152.446289, 22.065278], [-156.09375, 17.811456], [-161.323242, 22.512557]]] }, path: 'location' } }"); + AssertRendered( + subject.GeoWithin(__testBox, "location"), + "{ geoWithin: { box: { bottomLeft: { type: 'Point', coordinates: [-161.323242, 22.065278] }, topRight: { type: 'Point', coordinates: [-152.446289, 22.512557] } }, path: 'location' } }"); + AssertRendered( + subject.GeoWithin(__testCircle, "location"), + "{ geoWithin: { circle: { center: { type: 'Point', coordinates: [-161.323242, 22.512557] }, radius: 7.5 }, path: 'location' } }"); + } + + [Fact] + public void GeoWithin_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.GeoWithin(__testPolygon, x => x.Location), + "{ geoWithin: { geometry: { type: 'Polygon', coordinates: [[[-161.323242, 22.512557], [-152.446289, 22.065278], [-156.09375, 17.811456], [-161.323242, 22.512557]]] }, path: 'location' } }"); + AssertRendered( + subject.GeoWithin(__testPolygon, "Location"), + "{ geoWithin: { geometry: { type: 'Polygon', coordinates: [[[-161.323242, 22.512557], [-152.446289, 22.065278], [-156.09375, 17.811456], [-161.323242, 22.512557]]] }, path: 'location' } }"); + + AssertRendered( + subject.GeoWithin(__testBox, x => x.Location), + "{ geoWithin: { box: { bottomLeft: { type: 'Point', coordinates: [-161.323242, 22.065278] }, topRight: { type: 'Point', coordinates: [-152.446289, 22.512557] } }, path: 'location' } }"); + AssertRendered( + subject.GeoWithin(__testBox, "Location"), + "{ geoWithin: { box: { bottomLeft: { type: 'Point', coordinates: [-161.323242, 22.065278] }, topRight: { type: 'Point', coordinates: [-152.446289, 22.512557] } }, path: 'location' } }"); + + AssertRendered( + subject.GeoWithin(__testCircle, x => x.Location), + "{ geoWithin: { circle: { center: { type: 'Point', coordinates: [-161.323242, 22.512557] }, radius: 7.5 }, path: 'location' } }"); + AssertRendered( + subject.GeoWithin(__testCircle, "Location"), + "{ geoWithin: { circle: { center: { type: 'Point', coordinates: [-161.323242, 22.512557] }, radius: 7.5 }, path: 'location' } }"); + } + + [Fact] + public void MoreLikeThis() + { + var subject = CreateSubject(); + + AssertRendered( + subject.MoreLikeThis( + new BsonDocument("x", "foo"), + new BsonDocument("x", "bar")), + "{ moreLikeThis: { like: [{ x: 'foo' }, { x: 'bar' }] } }"); + } + + [Fact] + public void MoreLikeThis_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.MoreLikeThis( + new SimplePerson + { + FirstName = "John", + LastName = "Doe" + }, + new SimplePerson + { + FirstName = "Jane", + LastName = "Doe" + }), + "{ moreLikeThis: { like: [{ fn: 'John', ln: 'Doe' }, { fn: 'Jane', ln: 'Doe' }] } }"); + } + + [Fact] + public void Must() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Compound().Must( + subject.Exists("x"), + subject.Exists("y")), + "{ compound: { must: [{ exists: { path: 'x' } }, { exists: { path: 'y' } }] } }"); + } + + [Fact] + public void MustNot() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Compound().MustNot( + subject.Exists("x"), + subject.Exists("y")), + "{ compound: { mustNot: [{ exists: { path: 'x' } }, { exists: { path: 'y' } }] } }"); + } + + [Fact] + public void Near() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Near("x", 5.0, 1.0), + "{ near: { path: 'x', origin: 5.0, pivot: 1.0 } }"); + AssertRendered( + subject.Near("x", 5, 1), + "{ near: { path: 'x', origin: 5, pivot: 1 } }"); + AssertRendered( + subject.Near("x", 5L, 1L), + "{ near: { path: 'x', origin: { $numberLong: '5' }, pivot: { $numberLong: '1' } } }"); + AssertRendered( + subject.Near("x", new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc), 1000L), + "{ near: { path: 'x', origin: { $date: '2000-01-01T00:00:00Z' }, pivot: { $numberLong: '1000' } } }"); + + var scoreBuilder = new ScoreDefinitionBuilder(); + AssertRendered( + subject.Near("x", 5.0, 1.0, scoreBuilder.Constant(1)), + "{ near: { path: 'x', origin: 5, pivot: 1, score: { constant: { value: 1 } } } }"); + } + + [Fact] + public void Near_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Near(x => x.Age, 35.0, 5.0), + "{ near: { path: 'age', origin: 35.0, pivot: 5.0 } }"); + AssertRendered( + subject.Near("Age", 35.0, 5.0), + "{ near: { path: 'age', origin: 35.0, pivot: 5.0 } }"); + + AssertRendered( + subject.Near(x => x.Age, 35, 5), + "{ near: { path: 'age', origin: 35, pivot: 5 } }"); + AssertRendered( + subject.Near("Age", 35, 5), + "{ near: { path: 'age', origin: 35, pivot: 5 } }"); + + AssertRendered( + subject.Near(x => x.Age, 35L, 5L), + "{ near: { path: 'age', origin: { $numberLong: '35' }, pivot: { $numberLong: '5' } } }"); + AssertRendered( + subject.Near("Age", 35L, 5L), + "{ near: { path: 'age', origin: { $numberLong: '35' }, pivot: { $numberLong: '5' } } }"); + + AssertRendered( + subject.Near(x => x.Birthday, new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc), 1000L), + "{ near: { path: 'dob', origin: { $date: '2000-01-01T00:00:00Z' }, pivot: { $numberLong: '1000' } } }"); + AssertRendered( + subject.Near("Birthday", new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc), 1000L), + "{ near: { path: 'dob', origin: { $date: '2000-01-01T00:00:00Z' }, pivot: { $numberLong: '1000' } } }"); + } + + [Fact] + public void Phrase() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Phrase("foo", "x"), + "{ phrase: { query: 'foo', path: 'x' } }"); + AssertRendered( + subject.Phrase("foo", new[] { "x", "y" }), + "{ phrase: { query: 'foo', path: ['x', 'y'] } }"); + AssertRendered( + subject.Phrase(new[] { "foo", "bar" }, "x"), + "{ phrase: { query: ['foo', 'bar'], path: 'x' } }"); + AssertRendered( + subject.Phrase(new[] { "foo", "bar" }, new[] { "x", "y" }), + "{ phrase: { query: ['foo', 'bar'], path: ['x', 'y'] } }"); + + AssertRendered( + subject.Phrase("foo", "x", 5), + "{ phrase: { query: 'foo', path: 'x', slop: 5 } }"); + + var scoreBuilder = new ScoreDefinitionBuilder(); + AssertRendered( + subject.Phrase("foo", "x", score: scoreBuilder.Constant(1)), + "{ phrase: { query: 'foo', path: 'x', score: { constant: { value: 1 } } } }"); + } + + [Fact] + public void Phrase_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Phrase("foo", x => x.FirstName), + "{ phrase: { query: 'foo', path: 'fn' } }"); + AssertRendered( + subject.Phrase("foo", "FirstName"), + "{ phrase: { query: 'foo', path: 'fn' } }"); + + AssertRendered( + subject.Phrase( + "foo", + new FieldDefinition[] + { + new ExpressionFieldDefinition(x => x.FirstName), + new ExpressionFieldDefinition(x => x.LastName) + }), + "{ phrase: { query: 'foo', path: ['fn', 'ln'] } }"); + AssertRendered( + subject.Phrase("foo", new[] { "FirstName", "LastName" }), + "{ phrase: { query: 'foo', path: ['fn', 'ln'] } }"); + + AssertRendered( + subject.Phrase(new[] { "foo", "bar" }, x => x.FirstName), + "{ phrase: { query: ['foo', 'bar'], path: 'fn' } }"); + AssertRendered( + subject.Phrase(new[] { "foo", "bar" }, "FirstName"), + "{ phrase: { query: ['foo', 'bar'], path: 'fn' } }"); + + AssertRendered( + subject.Phrase( + new[] { "foo", "bar" }, + new FieldDefinition[] + { + new ExpressionFieldDefinition(x => x.FirstName), + new ExpressionFieldDefinition(x => x.LastName) + }), + "{ phrase: { query: ['foo', 'bar'], path: ['fn', 'ln'] } }"); + AssertRendered( + subject.Phrase(new[] { "foo", "bar" }, new[] { "FirstName", "LastName" }), + "{ phrase: { query: ['foo', 'bar'], path: ['fn', 'ln'] } }"); + } + + [Fact] + public void QueryString() + { + var subject = CreateSubject(); + + AssertRendered( + subject.QueryString("x", "foo"), + "{ queryString: { defaultPath: 'x', query: 'foo' } }"); + + var scoreBuilder = new ScoreDefinitionBuilder(); + AssertRendered( + subject.QueryString("x", "foo", scoreBuilder.Constant(1)), + "{ queryString: { defaultPath: 'x', query: 'foo', score: { constant: { value: 1 } } } }"); + } + + [Fact] + public void QueryString_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.QueryString(x => x.FirstName, "foo"), + "{ queryString: { defaultPath: 'fn', query: 'foo' } }"); + AssertRendered( + subject.QueryString("FirstName", "foo"), + "{ queryString: { defaultPath: 'fn', query: 'foo' } }"); + } + + [Fact] + public void RangeDateTime() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Range(SearchRangeBuilder + .Gte(new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc)) + .Lte(new DateTime(2009, 12, 31, 0, 0, 0, DateTimeKind.Utc)), + "x"), + "{ range: { path: 'x', gte: { $date: '2000-01-01T00:00:00Z' }, lte: { $date: '2009-12-31T00:00:00Z' } } }"); + } + + [Fact] + public void RangeDouble() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Range(SearchRangeBuilder.Gt(1.5).Lt(2.5), "x"), + "{ range: { path: 'x', gt: 1.5, lt: 2.5 } }"); + } + + [Fact] + public void RangeInt32() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Range(SearchRangeBuilder.Gt(1).Lt(10), "x"), + "{ range: { path: 'x', gt: 1, lt: 10 } }"); + AssertRendered( + subject.Range(SearchRangeBuilder.Lt(10).Gt(1), "x"), + "{ range: { path: 'x', gt: 1, lt: 10 } }"); + AssertRendered( + subject.Range(SearchRangeBuilder.Gte(1).Lte(10), "x"), + "{ range: { path: 'x', gte: 1, lte: 10 } }"); + AssertRendered( + subject.Range(SearchRangeBuilder.Lte(10).Gte(1), "x"), + "{ range: { path: 'x', gte: 1, lte: 10 } }"); + } + + [Fact] + public void RangeInt32_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Range(SearchRangeBuilder.Gte(18).Lt(65), x => x.Age), + "{ range: { path: 'age', gte: 18, lt: 65 } }"); + AssertRendered( + subject.Range(SearchRangeBuilder.Gte(18).Lt(65), "Age"), + "{ range: { path: 'age', gte: 18, lt: 65 } }"); + } + + [Fact] + public void Regex() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Regex("foo", "x"), + "{ regex: { query: 'foo', path: 'x' } }"); + AssertRendered( + subject.Regex("foo", new[] { "x", "y" }), + "{ regex: { query: 'foo', path: ['x', 'y'] } }"); + AssertRendered( + subject.Regex(new[] { "foo", "bar" }, "x"), + "{ regex: { query: ['foo', 'bar'], path: 'x' } }"); + AssertRendered( + subject.Regex(new[] { "foo", "bar" }, new[] { "x", "y" }), + "{ regex: { query: ['foo', 'bar'], path: ['x', 'y'] } }"); + + AssertRendered( + subject.Regex("foo", "x", false), + "{ regex: { query: 'foo', path: 'x' } }"); + AssertRendered( + subject.Regex("foo", "x", true), + "{ regex: { query: 'foo', path: 'x', allowAnalyzedField: true } }"); + + var scoreBuilder = new ScoreDefinitionBuilder(); + AssertRendered( + subject.Regex("foo", "x", score: scoreBuilder.Constant(1)), + "{ regex: { query: 'foo', path: 'x', score: { constant: { value: 1 } } } }"); + } + + [Fact] + public void Regex_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Regex("foo", x => x.FirstName), + "{ regex: { query: 'foo', path: 'fn' } }"); + AssertRendered( + subject.Regex("foo", "FirstName"), + "{ regex: { query: 'foo', path: 'fn' } }"); + + AssertRendered( + subject.Regex( + "foo", + new FieldDefinition[] + { + new ExpressionFieldDefinition(x => x.FirstName), + new ExpressionFieldDefinition(x => x.LastName) + }), + "{ regex: { query: 'foo', path: ['fn', 'ln'] } }"); + AssertRendered( + subject.Regex("foo", new[] { "FirstName", "LastName" }), + "{ regex: { query: 'foo', path: ['fn', 'ln'] } }"); + + AssertRendered( + subject.Regex(new[] { "foo", "bar" }, x => x.FirstName), + "{ regex: { query: ['foo', 'bar'], path: 'fn' } }"); + AssertRendered( + subject.Regex(new[] { "foo", "bar" }, "FirstName"), + "{ regex: { query: ['foo', 'bar'], path: 'fn' } }"); + + AssertRendered( + subject.Regex( + new[] { "foo", "bar" }, + new FieldDefinition[] + { + new ExpressionFieldDefinition(x => x.FirstName), + new ExpressionFieldDefinition(x => x.LastName) + }), + "{ regex: { query: ['foo', 'bar'], path: ['fn', 'ln'] } }"); + AssertRendered( + subject.Regex(new[] { "foo", "bar" }, new[] { "FirstName", "LastName" }), + "{ regex: { query: ['foo', 'bar'], path: ['fn', 'ln'] } }"); + } + + [Fact] + public void Should() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Compound() + .Should( + subject.Exists("x"), + subject.Exists("y")) + .MinimumShouldMatch(2), + "{ compound: { should: [{ exists: { path: 'x' } }, { exists: { path: 'y' } }], minimumShouldMatch: 2 } }"); + } + + [Fact] + public void Span() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Span(Builders.Span + .First(Builders.Span.Term("foo", "x"), 5)), + "{ span: { first: { operator: { term: { query: 'foo', path: 'x' } }, endPositionLte: 5 } } }"); + } + [Fact] public void Text() { var subject = CreateSubject(); - AssertRendered(subject.Text("foo", "x"), + AssertRendered( + subject.Text("foo", "x"), "{ text: { query: 'foo', path: 'x' } }"); - AssertRendered( subject.Text("foo", new[] { "x", "y" }), "{ text: { query: 'foo', path: ['x', 'y'] } }"); @@ -107,23 +786,95 @@ public void Text_Typed() "{ text: { query: ['foo', 'bar'], path: ['fn', 'ln'] } }"); } - private void AssertRendered(SearchDefinition query, string expected) + [Fact] + public void Wildcard() { - AssertRendered(query, BsonDocument.Parse(expected)); + var subject = CreateSubject(); + + AssertRendered( + subject.Wildcard("foo", "x"), + "{ wildcard: { query: 'foo', path: 'x' } }"); + AssertRendered( + subject.Wildcard("foo", new[] { "x", "y" }), + "{ wildcard: { query: 'foo', path: ['x', 'y'] } }"); + AssertRendered( + subject.Wildcard(new[] { "foo", "bar" }, "x"), + "{ wildcard: { query: ['foo', 'bar'], path: 'x' } }"); + AssertRendered( + subject.Wildcard(new[] { "foo", "bar" }, new[] { "x", "y" }), + "{ wildcard: { query: ['foo', 'bar'], path: ['x', 'y'] } }"); + + AssertRendered( + subject.Wildcard("foo", "x", false), + "{ wildcard: { query: 'foo', path: 'x' } }"); + AssertRendered( + subject.Wildcard("foo", "x", true), + "{ wildcard: { query: 'foo', path: 'x', allowAnalyzedField: true } }"); + + var scoreBuilder = new ScoreDefinitionBuilder(); + AssertRendered( + subject.Wildcard("foo", "x", score: scoreBuilder.Constant(1)), + "{ wildcard: { query: 'foo', path: 'x', score: { constant: { value: 1 } } } }"); } + [Fact] + public void Wildcard_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Wildcard("foo", x => x.FirstName), + "{ wildcard: { query: 'foo', path: 'fn' } }"); + AssertRendered( + subject.Wildcard("foo", "FirstName"), + "{ wildcard: { query: 'foo', path: 'fn' } }"); + + AssertRendered( + subject.Wildcard( + "foo", + new FieldDefinition[] + { + new ExpressionFieldDefinition(x => x.FirstName), + new ExpressionFieldDefinition(x => x.LastName) + }), + "{ wildcard: { query: 'foo', path: ['fn', 'ln'] } }"); + AssertRendered( + subject.Wildcard("foo", new[] { "FirstName", "LastName" }), + "{ wildcard: { query: 'foo', path: ['fn', 'ln'] } }"); + + AssertRendered( + subject.Wildcard(new[] { "foo", "bar" }, x => x.FirstName), + "{ wildcard: { query: ['foo', 'bar'], path: 'fn' } }"); + AssertRendered( + subject.Wildcard(new[] { "foo", "bar" }, "FirstName"), + "{ wildcard: { query: ['foo', 'bar'], path: 'fn' } }"); + + AssertRendered( + subject.Wildcard( + new[] { "foo", "bar" }, + new FieldDefinition[] + { + new ExpressionFieldDefinition(x => x.FirstName), + new ExpressionFieldDefinition(x => x.LastName) + }), + "{ wildcard: { query: ['foo', 'bar'], path: ['fn', 'ln'] } }"); + AssertRendered( + subject.Wildcard(new[] { "foo", "bar" }, new[] { "FirstName", "LastName" }), + "{ wildcard: { query: ['foo', 'bar'], path: ['fn', 'ln'] } }"); + } + + private void AssertRendered(SearchDefinition query, string expected) => + AssertRendered(query, BsonDocument.Parse(expected)); + private void AssertRendered(SearchDefinition query, BsonDocument expected) { var documentSerializer = BsonSerializer.SerializerRegistry.GetSerializer(); var renderedQuery = query.Render(documentSerializer, BsonSerializer.SerializerRegistry); - renderedQuery.Should().Be(expected); + renderedQuery.Should().BeEquivalentTo(expected); } - private SearchDefinitionBuilder CreateSubject() - { - return new SearchDefinitionBuilder(); - } + private SearchDefinitionBuilder CreateSubject() =>new SearchDefinitionBuilder(); private class SimplePerson { diff --git a/tests/MongoDB.Driver.Tests/Search/SearchFacetBuilderTests.cs b/tests/MongoDB.Driver.Tests/Search/SearchFacetBuilderTests.cs new file mode 100644 index 00000000000..ed7bcbed6f2 --- /dev/null +++ b/tests/MongoDB.Driver.Tests/Search/SearchFacetBuilderTests.cs @@ -0,0 +1,143 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using FluentAssertions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver.Search; +using Xunit; + +namespace MongoDB.Driver.Tests.Search +{ + public class SearchFacetBuilderTests + { + [Fact] + public void String() + { + var subject = CreateSubject(); + + AssertRendered( + subject.String("string", "x", 100), + "{ type: 'string', path: 'x', numBuckets: 100 }"); + } + + [Fact] + public void String_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.String("string", x => x.FirstName, 100), + "{ type: 'string', path: 'fn', numBuckets: 100 }"); + AssertRendered( + subject.String("string", "FirstName", 100), + "{ type: 'string', path: 'fn', numBuckets: 100 }"); + } + + [Fact] + public void Number() + { + var subject = CreateSubject(); + var boundaries = new List() + { + 0, + 50, + 100 + }; + + AssertRendered( + subject.Number("number", "x", boundaries, "foo"), + "{ type: 'number', path: 'x', boundaries: [0, 50, 100], default: 'foo' }"); + AssertRendered( + subject.Number("number", "x", boundaries), + "{ type: 'number', path: 'x', boundaries: [0, 50, 100] }"); + } + + [Fact] + public void Number_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Number("number", x => x.Age, 0, 18, 65, 120), + "{ type: 'number', path: 'age', boundaries: [0, 18, 65, 120] }"); + AssertRendered( + subject.Number("number", "Age", 0, 18, 65, 120), + "{ type: 'number', path: 'age', boundaries: [0, 18, 65, 120] }"); + } + + [Fact] + public void Date() + { + var subject = CreateSubject(); + var boundaries = new List() + { + DateTime.MinValue, + DateTime.MaxValue + }; + + AssertRendered( + subject.Date("date", "x", boundaries, "foo"), + "{ type: 'date', path: 'x', boundaries: [{ $date: '0001-01-01T00:00:00Z' }, { $date: '9999-12-31T23:59:59.9999999Z' }], default: 'foo' }"); + AssertRendered( + subject.Date("date", "x", boundaries), + "{ type: 'date', path: 'x', boundaries: [{ $date: '0001-01-01T00:00:00Z' }, { $date: '9999-12-31T23:59:59.9999999Z' }] }"); + } + + [Fact] + public void Date_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Date("date", x => x.Birthday, DateTime.MinValue, DateTime.MaxValue), + "{ type: 'date', path: 'dob', boundaries: [{ $date: '0001-01-01T00:00:00Z' }, { $date: '9999-12-31T23:59:59.9999999Z' }] }"); + AssertRendered( + subject.Date("date", "Birthday", DateTime.MinValue, DateTime.MaxValue), + "{ type: 'date', path: 'dob', boundaries: [{ $date: '0001-01-01T00:00:00Z' }, { $date: '9999-12-31T23:59:59.9999999Z' }] }"); + } + + private void AssertRendered(SearchFacet facet, string expected) => + AssertRendered(facet, BsonDocument.Parse(expected)); + + private void AssertRendered(SearchFacet facet, BsonDocument expected) + { + var documentSerializer = BsonSerializer.SerializerRegistry.GetSerializer(); + var renderedFacet = facet.Render(documentSerializer, BsonSerializer.SerializerRegistry); + + renderedFacet.Should().BeEquivalentTo(expected); + } + + private SearchFacetBuilder CreateSubject() => + new SearchFacetBuilder(); + + private class Person + { + [BsonElement("fn")] + public string FirstName { get; set; } + + [BsonElement("ln")] + public string LastName { get; set; } + + [BsonElement("age")] + public int Age { get; set; } + + [BsonElement("dob")] + public DateTime Birthday { get; set; } + } + } +} diff --git a/tests/MongoDB.Driver.Tests/Search/SpanDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/Search/SpanDefinitionBuilderTests.cs new file mode 100644 index 00000000000..6b93b1e936d --- /dev/null +++ b/tests/MongoDB.Driver.Tests/Search/SpanDefinitionBuilderTests.cs @@ -0,0 +1,172 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using FluentAssertions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver.Search; +using Xunit; + +namespace MongoDB.Driver.Tests.Search +{ + public class SpanDefinitionBuilderTests + { + [Fact] + public void First() + { + var subject = CreateSubject(); + + AssertRendered( + subject.First(subject.Term("foo", "x"), 5), + "{ first: { operator: { term: { query: 'foo', path: 'x' } }, endPositionLte: 5 } }"); + } + + [Fact] + public void First_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.First(subject.Term("born", x => x.Biography), 5), + "{ first: { operator: { term: { query: 'born', path: 'bio' } }, endPositionLte: 5 } }"); + AssertRendered( + subject.First(subject.Term("born", "Biography"), 5), + "{ first: { operator: { term: { query: 'born', path: 'bio' } }, endPositionLte: 5 } }"); + } + + [Fact] + public void Near() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Near( + new List>() + { + subject.Term("foo", "x"), + subject.Term("bar", "x") + }, + 5, + inOrder: true), + "{ near: { clauses: [{ term: { query: 'foo', path: 'x' } }, { term: { query: 'bar', path: 'x' } }], slop: 5, inOrder: true } }"); + } + + [Fact] + public void Near_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Near( + new List>() + { + subject.Term("born", x => x.Biography), + subject.Term("school", x => x.Biography) + }, + 5, + inOrder: true), + "{ near: { clauses: [{ term: { query: 'born', path: 'bio' } }, { term: { query: 'school', path: 'bio' } }], slop: 5, inOrder: true } }"); + AssertRendered( + subject.Near( + new List>() + { + subject.Term("born", "Biography"), + subject.Term("school", "Biography") + }, + 5, + inOrder: true), + "{ near: { clauses: [{ term: { query: 'born', path: 'bio' } }, { term: { query: 'school', path: 'bio' } }], slop: 5, inOrder: true } }"); + } + + [Fact] + public void Or() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Or( + subject.Term("foo", "x"), + subject.Term("bar", "x")), + "{ or: { clauses: [{ term: { query: 'foo', path: 'x' } }, { term: { query: 'bar', path: 'x' } }] } }"); + } + + [Fact] + public void Or_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Or( + subject.Term("engineer", x => x.Biography), + subject.Term("developer", x => x.Biography)), + "{ or: { clauses: [{ term: { query: 'engineer', path: 'bio' } }, { term: { query: 'developer', path: 'bio' } }] } }"); + AssertRendered( + subject.Or( + subject.Term("engineer", "Biography"), + subject.Term("developer", "Biography")), + "{ or: { clauses: [{ term: { query: 'engineer', path: 'bio' } }, { term: { query: 'developer', path: 'bio' } }] } }"); + } + + [Fact] + public void Subtract() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Subtract( + subject.Term("foo", "x"), + subject.Term("bar", "x")), + "{ subtract: { include: { term: { query: 'foo', path: 'x' } }, exclude: { term: { query: 'bar', path: 'x' } } } }"); + } + + [Fact] + public void Subtract_Typed() + { + var subject = CreateSubject(); + + AssertRendered( + subject.Subtract( + subject.Term("engineer", x => x.Biography), + subject.Term("train", x => x.Biography)), + "{ subtract: { include: { term: { query: 'engineer', path: 'bio' } }, exclude: { term: { query: 'train', path: 'bio' } } } }"); + AssertRendered( + subject.Subtract( + subject.Term("engineer", "Biography"), + subject.Term("train", "Biography")), + "{ subtract: { include: { term: { query: 'engineer', path: 'bio' } }, exclude: { term: { query: 'train', path: 'bio' } } } }"); + } + + private void AssertRendered(SpanDefinition span, string expected) => + AssertRendered(span, BsonDocument.Parse(expected)); + + private void AssertRendered(SpanDefinition span, BsonDocument expected) + { + var documentSerializer = BsonSerializer.SerializerRegistry.GetSerializer(); + var renderedSpan = span.Render(documentSerializer, BsonSerializer.SerializerRegistry); + + renderedSpan.Should().BeEquivalentTo(expected); + } + + private SpanDefinitionBuilder CreateSubject() => + new SpanDefinitionBuilder(); + + private class Person + { + [BsonElement("bio")] + public string Biography { get; set; } + } + } +} From 7bcf7c3845eb44567d305e1846b2278c32eff2e6 Mon Sep 17 00:00:00 2001 From: BorisDog Date: Mon, 12 Dec 2022 15:04:41 -0800 Subject: [PATCH 03/21] - Tests fix --- tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs index c772501da59..b8b1762fc73 100644 --- a/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs @@ -248,7 +248,7 @@ public void Search_should_throw_when_query_is_null() var pipeline = new EmptyPipelineDefinition(); var exception = Record.Exception(() => pipeline.Search(null)); exception.Should().BeOfType() - .Which.ParamName.Should().Be("query"); + .Which.ParamName.Should().Be("searchDefinition"); } [Fact] @@ -304,7 +304,7 @@ public void SearchMeta_should_throw_when_query_is_null() var pipeline = new EmptyPipelineDefinition(); var exception = Record.Exception(() => pipeline.SearchMeta(null)); exception.Should().BeOfType() - .Which.ParamName.Should().Be("query"); + .Which.ParamName.Should().Be("searchDefinition"); } // private methods From bd3bb5137c849feade68e97707b4f61bdb3dd47c Mon Sep 17 00:00:00 2001 From: Dmitry Lukyanov Date: Mon, 5 Dec 2022 23:26:21 +0400 Subject: [PATCH 04/21] Hide aws sdk package. (#981) --- src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj | 2 +- tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj b/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj index 710b2100fad..94168099878 100644 --- a/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj +++ b/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj @@ -19,7 +19,7 @@ - + diff --git a/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj b/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj index 326a865a45f..78d3f310c04 100644 --- a/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj +++ b/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj @@ -31,6 +31,7 @@ + From 332b09ab8079ebe5e7239a35dd2afc50c2981626 Mon Sep 17 00:00:00 2001 From: Dmitry Lukyanov Date: Tue, 6 Dec 2022 04:41:33 +0400 Subject: [PATCH 05/21] Revert "Hide aws sdk package. (#981)" (#982) This reverts commit 77d144c715be7b0b658f22a15d00b98254739246. --- src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj | 2 +- tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj b/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj index 94168099878..710b2100fad 100644 --- a/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj +++ b/src/MongoDB.Driver.Core/MongoDB.Driver.Core.csproj @@ -19,7 +19,7 @@ - + diff --git a/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj b/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj index 78d3f310c04..326a865a45f 100644 --- a/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj +++ b/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj @@ -31,7 +31,6 @@ - From ad74cdfd83d1e230b8a08a27cae78c825d58bcfc Mon Sep 17 00:00:00 2001 From: rstam Date: Tue, 6 Dec 2022 17:06:06 -0800 Subject: [PATCH 06/21] CSHARP-4428: LINQ3 not handling down cast in UpdateDefinitionBuilder Set method. --- ...onvertExpressionToFilterFieldTranslator.cs | 207 ++++++++++-------- .../ExpressionToFilterFieldTranslator.cs | 5 +- .../UpdateDefinitionBuilderTests.cs | 30 ++- 3 files changed, 142 insertions(+), 100 deletions(-) diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ConvertExpressionToFilterFieldTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ConvertExpressionToFilterFieldTranslator.cs index 85d4f6ca6e2..9e0f01d9010 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ConvertExpressionToFilterFieldTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ConvertExpressionToFilterFieldTranslator.cs @@ -28,115 +28,61 @@ internal static class ConvertExpressionToFilterFieldTranslator { public static AstFilterField Translate(TranslationContext context, UnaryExpression expression) { - if (expression.NodeType == ExpressionType.Convert) + if (expression.NodeType == ExpressionType.Convert || expression.NodeType == ExpressionType.TypeAs) { var field = ExpressionToFilterFieldTranslator.Translate(context, expression.Operand); - var fieldSerializer = field.Serializer; - var fieldType = fieldSerializer.ValueType; + var fieldType = field.Serializer.ValueType; var targetType = expression.Type; - if (fieldType.IsEnumOrNullableEnum(out _, out var underlyingType)) + if (IsConvertEnumToUnderlyingType(fieldType, targetType)) { - if (targetType.IsSameAsOrNullableOf(underlyingType)) - { - IBsonSerializer enumSerializer; - if (fieldType.IsNullable()) - { - var nullableSerializer = (INullableSerializer)fieldSerializer; - enumSerializer = nullableSerializer.ValueSerializer; - } - else - { - enumSerializer = fieldSerializer; - } - - IBsonSerializer targetSerializer; - var enumUnderlyingTypeSerializer = EnumUnderlyingTypeSerializer.Create(enumSerializer); - if (targetType.IsNullable()) - { - targetSerializer = NullableSerializer.Create(enumUnderlyingTypeSerializer); - } - else - { - targetSerializer = enumUnderlyingTypeSerializer; - } - - return AstFilter.Field(field.Path, targetSerializer); - } + return TranslateConvertEnumToUnderlyingType(field, targetType); } - if (IsNumericType(targetType)) + if (IsNumericConversion(fieldType, targetType)) { - IBsonSerializer targetTypeSerializer = expression.Type switch - { - Type t when t == typeof(byte) => new ByteSerializer(), - Type t when t == typeof(short) => new Int16Serializer(), - Type t when t == typeof(ushort) => new UInt16Serializer(), - Type t when t == typeof(int) => new Int32Serializer(), - Type t when t == typeof(uint) => new UInt32Serializer(), - Type t when t == typeof(long) => new Int64Serializer(), - Type t when t == typeof(ulong) => new UInt64Serializer(), - Type t when t == typeof(float) => new SingleSerializer(), - Type t when t == typeof(double) => new DoubleSerializer(), - Type t when t == typeof(decimal) => new DecimalSerializer(), - _ => throw new ExpressionNotSupportedException(expression) - }; - if (fieldSerializer is IRepresentationConfigurable representationConfigurableFieldSerializer && - targetTypeSerializer is IRepresentationConfigurable representationConfigurableTargetTypeSerializer) - { - var fieldRepresentation = representationConfigurableFieldSerializer.Representation; - if (fieldRepresentation == BsonType.String) - { - targetTypeSerializer = representationConfigurableTargetTypeSerializer.WithRepresentation(fieldRepresentation); - } - } - if (fieldSerializer is IRepresentationConverterConfigurable converterConfigurableFieldSerializer && - targetTypeSerializer is IRepresentationConverterConfigurable converterConfigurableTargetTypeSerializer) - { - targetTypeSerializer = converterConfigurableTargetTypeSerializer.WithConverter(converterConfigurableFieldSerializer.Converter); - } - return AstFilter.Field(field.Path, targetTypeSerializer); + return TranslateNumericConversion(field, targetType); } - if (targetType.IsConstructedGenericType && - targetType.GetGenericTypeDefinition() == typeof(Nullable<>)) + if (IsConvertToNullable(fieldType, targetType)) { - var nullableValueType = targetType.GetGenericArguments()[0]; - if (nullableValueType == fieldType) - { - var nullableSerializerType = typeof(NullableSerializer<>).MakeGenericType(nullableValueType); - var nullableSerializer = (IBsonSerializer)Activator.CreateInstance(nullableSerializerType, fieldSerializer); - return AstFilter.Field(field.Path, nullableSerializer); - } - - if (fieldType.IsConstructedGenericType && - fieldType.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - var fieldValueType = fieldType.GetGenericArguments()[0]; - if (fieldValueType.IsEnum) - { - var enumUnderlyingType = fieldValueType.GetEnumUnderlyingType(); - if (nullableValueType == enumUnderlyingType) - { - var fieldSerializerType = fieldSerializer.GetType(); - if (fieldSerializerType.IsConstructedGenericType && - fieldSerializerType.GetGenericTypeDefinition() == typeof(NullableSerializer<>)) - { - var enumSerializer = ((IChildSerializerConfigurable)fieldSerializer).ChildSerializer; - var enumUnderlyingTypeSerializer = EnumUnderlyingTypeSerializer.Create(enumSerializer); - var nullableSerializerType = typeof(NullableSerializer<>).MakeGenericType(nullableValueType); - var nullableSerializer = (IBsonSerializer)Activator.CreateInstance(nullableSerializerType, enumUnderlyingTypeSerializer); - return AstFilter.Field(field.Path, nullableSerializer); - } - } - } - } + return TranslateConvertToNullable(field); + } + + if (IsConvertToDerivedType(fieldType, targetType)) + { + return TranslateConvertToDerivedType(field, targetType); } } throw new ExpressionNotSupportedException(expression); } + private static bool IsConvertEnumToUnderlyingType(Type fieldType, Type targetType) + { + return + fieldType.IsEnumOrNullableEnum(out _, out var underlyingType) && + targetType.IsSameAsOrNullableOf(underlyingType); + } + + private static bool IsConvertToDerivedType(Type fieldType, Type targetType) + { + return targetType.IsSubclassOf(fieldType); + } + + private static bool IsConvertToNullable(Type fieldType, Type targetType) + { + return + targetType.IsConstructedGenericType && + targetType.GetGenericTypeDefinition() == typeof(Nullable<>) && + targetType.GetGenericArguments()[0] == fieldType; + } + + private static bool IsNumericConversion(Type fieldType, Type targetType) + { + return IsNumericType(fieldType) && IsNumericType(targetType); + } + private static bool IsNumericType(Type type) { switch (Type.GetTypeCode(type)) @@ -147,6 +93,7 @@ private static bool IsNumericType(Type type) case TypeCode.Int16: case TypeCode.Int32: case TypeCode.Int64: + case TypeCode.SByte: case TypeCode.Single: case TypeCode.UInt16: case TypeCode.UInt32: @@ -157,5 +104,81 @@ private static bool IsNumericType(Type type) return false; } } + + private static AstFilterField TranslateConvertEnumToUnderlyingType(AstFilterField field, Type targetType) + { + var fieldSerializer = field.Serializer; + var fieldType = fieldSerializer.ValueType; + + IBsonSerializer enumSerializer; + if (fieldType.IsNullable()) + { + var nullableSerializer = (INullableSerializer)fieldSerializer; + enumSerializer = nullableSerializer.ValueSerializer; + } + else + { + enumSerializer = fieldSerializer; + } + + IBsonSerializer targetSerializer; + var enumUnderlyingTypeSerializer = EnumUnderlyingTypeSerializer.Create(enumSerializer); + if (targetType.IsNullable()) + { + targetSerializer = NullableSerializer.Create(enumUnderlyingTypeSerializer); + } + else + { + targetSerializer = enumUnderlyingTypeSerializer; + } + + return AstFilter.Field(field.Path, targetSerializer); + } + + private static AstFilterField TranslateConvertToDerivedType(AstFilterField field, Type targetType) + { + var targetSerializer = BsonSerializer.LookupSerializer(targetType); + return AstFilter.Field(field.Path, targetSerializer); + } + + private static AstFilterField TranslateConvertToNullable(AstFilterField field) + { + var nullableSerializer = NullableSerializer.Create(field.Serializer); + return AstFilter.Field(field.Path, nullableSerializer); + } + + private static AstFilterField TranslateNumericConversion(AstFilterField field, Type targetType) + { + IBsonSerializer targetTypeSerializer = targetType switch + { + Type t when t == typeof(byte) => new ByteSerializer(), + Type t when t == typeof(sbyte) => new SByteSerializer(), + Type t when t == typeof(short) => new Int16Serializer(), + Type t when t == typeof(ushort) => new UInt16Serializer(), + Type t when t == typeof(int) => new Int32Serializer(), + Type t when t == typeof(uint) => new UInt32Serializer(), + Type t when t == typeof(long) => new Int64Serializer(), + Type t when t == typeof(ulong) => new UInt64Serializer(), + Type t when t == typeof(float) => new SingleSerializer(), + Type t when t == typeof(double) => new DoubleSerializer(), + Type t when t == typeof(decimal) => new DecimalSerializer(), + _ => throw new Exception($"Unexpected target type: {targetType}.") + }; + if (field.Serializer is IRepresentationConfigurable representationConfigurableFieldSerializer && + targetTypeSerializer is IRepresentationConfigurable representationConfigurableTargetTypeSerializer) + { + var fieldRepresentation = representationConfigurableFieldSerializer.Representation; + if (fieldRepresentation == BsonType.String) + { + targetTypeSerializer = representationConfigurableTargetTypeSerializer.WithRepresentation(fieldRepresentation); + } + } + if (field.Serializer is IRepresentationConverterConfigurable converterConfigurableFieldSerializer && + targetTypeSerializer is IRepresentationConverterConfigurable converterConfigurableTargetTypeSerializer) + { + targetTypeSerializer = converterConfigurableTargetTypeSerializer.WithConverter(converterConfigurableFieldSerializer.Converter); + } + return AstFilter.Field(field.Path, targetTypeSerializer); + } } } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ExpressionToFilterFieldTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ExpressionToFilterFieldTranslator.cs index 49aa53eae54..1a2307520b8 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ExpressionToFilterFieldTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ExpressionToFilterFieldTranslator.cs @@ -30,7 +30,10 @@ public static AstFilterField Translate(TranslationContext context, Expression ex case ExpressionType.MemberAccess: return MemberExpressionToFilterFieldTranslator.Translate(context, (MemberExpression)expression); case ExpressionType.Call: return MethodCallExpressionToFilterFieldTranslator.Translate(context, (MethodCallExpression)expression); case ExpressionType.Parameter: return ParameterExpressionToFilterFieldTranslator.Translate(context, (ParameterExpression)expression); - case ExpressionType.Convert: return ConvertExpressionToFilterFieldTranslator.Translate(context, (UnaryExpression)expression); + + case ExpressionType.Convert: + case ExpressionType.TypeAs: + return ConvertExpressionToFilterFieldTranslator.Translate(context, (UnaryExpression)expression); } throw new ExpressionNotSupportedException(expression); diff --git a/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs index 3ed0936ec10..41f882948b8 100644 --- a/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization; @@ -595,11 +596,11 @@ public void Set_Typed_with_cast() { var subject = CreateSubject(); - Assert(subject.Set(x => ((SmsMessage)x).PhoneNumber, "1234567890"), "{$set: {pn: '1234567890'}}"); + Assert(subject.Set(x => ((SmsMessage)x).PhoneNumber, "1234567890"), "{$set: {pn: '1234567890'}}", LinqProvider.V3); var subject2 = CreateSubject(); - Assert(subject2.Set(x => ((SmsMessage)x.Message).PhoneNumber, "1234567890"), "{$set: {'m.pn': '1234567890'}}"); + Assert(subject2.Set(x => ((SmsMessage)x.Message).PhoneNumber, "1234567890"), "{$set: {'m.pn': '1234567890'}}", LinqProvider.V3); } [Fact] @@ -607,11 +608,11 @@ public void Set_Typed_with_type_as() { var subject = CreateSubject(); - Assert(subject.Set(x => (x as SmsMessage).PhoneNumber, "1234567890"), "{$set: {pn: '1234567890'}}"); + Assert(subject.Set(x => (x as SmsMessage).PhoneNumber, "1234567890"), "{$set: {pn: '1234567890'}}", LinqProvider.V3); var subject2 = CreateSubject(); - Assert(subject2.Set(x => (x.Message as SmsMessage).PhoneNumber, "1234567890"), "{$set: {'m.pn': '1234567890'}}"); + Assert(subject2.Set(x => (x.Message as SmsMessage).PhoneNumber, "1234567890"), "{$set: {'m.pn': '1234567890'}}", LinqProvider.V3); } [Fact] @@ -650,7 +651,12 @@ public void Unset_Typed() private void Assert(UpdateDefinition update, BsonDocument expected) { - var renderedUpdate = Render(update).AsBsonDocument; + Assert(update, expected, LinqProvider.V2); + } + + private void Assert(UpdateDefinition update, BsonDocument expected, LinqProvider linqProvider) + { + var renderedUpdate = Render(update, linqProvider).AsBsonDocument; renderedUpdate.Should().Be(expected); } @@ -665,7 +671,12 @@ private void Assert(UpdateDefinition update, string[] expe private void Assert(UpdateDefinition update, string expected) { - Assert(update, BsonDocument.Parse(expected)); + Assert(update, expected, LinqProvider.V2); + } + + private void Assert(UpdateDefinition update, string expected, LinqProvider linqProvider) + { + Assert(update, BsonDocument.Parse(expected), linqProvider); } private void AssertThrow(UpdateDefinition update, string errorMessage) where TException : Exception @@ -681,9 +692,14 @@ private UpdateDefinitionBuilder CreateSubject() } private BsonValue Render(UpdateDefinition update) + { + return Render(update, LinqProvider.V2); + } + + private BsonValue Render(UpdateDefinition update, LinqProvider linqProvider) { var documentSerializer = BsonSerializer.SerializerRegistry.GetSerializer(); - return update.Render(documentSerializer, BsonSerializer.SerializerRegistry, LinqProvider.V2); + return update.Render(documentSerializer, BsonSerializer.SerializerRegistry, linqProvider); } private class Person From ff4c3969d5339a08785fe4541d9f32fd17465f22 Mon Sep 17 00:00:00 2001 From: BorisDog Date: Thu, 8 Dec 2022 11:14:09 -0800 Subject: [PATCH 07/21] CSHARP-4421: Unify all spec tests in single test project (#977) --- .../MongoDB.Bson.Tests.csproj | 6 ------ .../MockClusterableServerFactory.cs | 2 +- .../MockConnection.cs | 2 +- .../MongoAWSAuthenticatorTests.cs | 1 + .../MongoDBCRAuthenticatorTests.cs | 9 +++++---- .../MongoDBX509AuthenticatorTests.cs | 9 +++++---- .../Authentication/PlainAuthenticatorTests.cs | 9 +++++---- .../Core/Clusters/LoadBalancedClusterTests.cs | 2 +- .../Core/Clusters/MultiServerClusterTests.cs | 2 +- .../Core/Clusters/SingleServerClusterTests.cs | 2 +- .../ExclusiveConnectionPoolTests.cs | 2 +- .../ConnectionPools/MaintenanceHelperTests.cs | 1 + .../Connections/ConnectionInitializerTests.cs | 11 ++++++----- .../Core/Servers/LoadBalancedServerTests.cs | 1 - .../Core/Servers/RoundTripTimeMonitorTests.cs | 1 + .../WireProtocol/CommandWriteProtocolTests.cs | 1 + .../MongoDB.Driver.Core.Tests.csproj | 11 ----------- .../MongoDB.Driver.Tests.csproj | 19 +------------------ .../bson-corpus/BsonCorpusTestRunner.cs | 5 +++-- .../bson-decimal128/TestRunner.cs | 5 +++-- ...onnectionMonitoringAndPoolingTestRunner.cs | 5 ++--- .../ConnectionStringTestRunner.cs | 6 +++--- .../InitialDnsSeedlistDiscoveryTestRunner.cs | 4 ++-- .../ConnectionStringTestRunner.cs | 8 ++++---- .../read-write-concern/DocumentTestRunner.cs | 4 ++-- .../MonitoringTestRunner.cs | 6 +++--- .../ServerDiscoveryAndMonitoringProseTests.cs | 8 -------- .../ServerDiscoveryAndMonitoringTestRunner.cs | 17 ++++++++++------- .../server-selection/InWindowTestRunner.cs | 4 ++-- .../server-selection/RttTestRunner.cs | 4 ++-- .../ServerSelectionTestHelpers.cs | 2 +- .../ServerSelectionTestRunner.cs | 6 +++--- .../uuid/prose-tests/ExplicitDecodingTests.cs | 3 ++- .../uuid/prose-tests/ExplicitEncodingTests.cs | 3 ++- 34 files changed, 76 insertions(+), 105 deletions(-) rename tests/{MongoDB.Driver.Core.Tests/Core/Helpers => MongoDB.Driver.Core.TestHelpers}/MockClusterableServerFactory.cs (99%) rename tests/{MongoDB.Driver.Core.Tests/Core/Helpers => MongoDB.Driver.Core.TestHelpers}/MockConnection.cs (99%) rename tests/{MongoDB.Bson.Tests => MongoDB.Driver.Tests}/Specifications/bson-corpus/BsonCorpusTestRunner.cs (98%) rename tests/{MongoDB.Bson.Tests => MongoDB.Driver.Tests}/Specifications/bson-decimal128/TestRunner.cs (97%) rename tests/{MongoDB.Driver.Core.Tests => MongoDB.Driver.Tests}/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs (99%) rename tests/{MongoDB.Driver.Core.Tests => MongoDB.Driver.Tests}/Specifications/connection-string/ConnectionStringTestRunner.cs (99%) rename tests/{MongoDB.Driver.Core.Tests => MongoDB.Driver.Tests}/Specifications/initial-dns-seedlist-discovery/InitialDnsSeedlistDiscoveryTestRunner.cs (97%) rename tests/{MongoDB.Driver.Core.Tests => MongoDB.Driver.Tests}/Specifications/read-write-concern/ConnectionStringTestRunner.cs (96%) rename tests/{MongoDB.Driver.Core.Tests => MongoDB.Driver.Tests}/Specifications/read-write-concern/DocumentTestRunner.cs (97%) rename tests/{MongoDB.Driver.Core.Tests => MongoDB.Driver.Tests}/Specifications/server-discovery-and-monitoring/MonitoringTestRunner.cs (98%) rename tests/{MongoDB.Driver.Core.Tests => MongoDB.Driver.Tests}/Specifications/server-discovery-and-monitoring/ServerDiscoveryAndMonitoringTestRunner.cs (97%) rename tests/{MongoDB.Driver.Core.Tests => MongoDB.Driver.Tests}/Specifications/server-selection/InWindowTestRunner.cs (97%) rename tests/{MongoDB.Driver.Core.Tests => MongoDB.Driver.Tests}/Specifications/server-selection/RttTestRunner.cs (95%) rename tests/{MongoDB.Driver.Core.Tests => MongoDB.Driver.Tests}/Specifications/server-selection/ServerSelectionTestHelpers.cs (99%) rename tests/{MongoDB.Driver.Core.Tests => MongoDB.Driver.Tests}/Specifications/server-selection/ServerSelectionTestRunner.cs (96%) rename tests/{MongoDB.Bson.Tests => MongoDB.Driver.Tests}/Specifications/uuid/prose-tests/ExplicitDecodingTests.cs (98%) rename tests/{MongoDB.Bson.Tests => MongoDB.Driver.Tests}/Specifications/uuid/prose-tests/ExplicitEncodingTests.cs (97%) diff --git a/tests/MongoDB.Bson.Tests/MongoDB.Bson.Tests.csproj b/tests/MongoDB.Bson.Tests/MongoDB.Bson.Tests.csproj index f10ae46d181..7f262a14faa 100644 --- a/tests/MongoDB.Bson.Tests/MongoDB.Bson.Tests.csproj +++ b/tests/MongoDB.Bson.Tests/MongoDB.Bson.Tests.csproj @@ -45,12 +45,6 @@ - - - - - - Always diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Helpers/MockClusterableServerFactory.cs b/tests/MongoDB.Driver.Core.TestHelpers/MockClusterableServerFactory.cs similarity index 99% rename from tests/MongoDB.Driver.Core.Tests/Core/Helpers/MockClusterableServerFactory.cs rename to tests/MongoDB.Driver.Core.TestHelpers/MockClusterableServerFactory.cs index 3c6f604a523..252251907cd 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Helpers/MockClusterableServerFactory.cs +++ b/tests/MongoDB.Driver.Core.TestHelpers/MockClusterableServerFactory.cs @@ -29,7 +29,7 @@ using MongoDB.Driver.Core.Servers; using Moq; -namespace MongoDB.Driver.Core.Helpers +namespace MongoDB.Driver.Core.TestHelpers { public class MockClusterableServerFactory : IClusterableServerFactory { diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Helpers/MockConnection.cs b/tests/MongoDB.Driver.Core.TestHelpers/MockConnection.cs similarity index 99% rename from tests/MongoDB.Driver.Core.Tests/Core/Helpers/MockConnection.cs rename to tests/MongoDB.Driver.Core.TestHelpers/MockConnection.cs index 895397da33a..b4d70359e4f 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Helpers/MockConnection.cs +++ b/tests/MongoDB.Driver.Core.TestHelpers/MockConnection.cs @@ -27,7 +27,7 @@ using MongoDB.Driver.Core.WireProtocol.Messages; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; -namespace MongoDB.Driver.Core.Helpers +namespace MongoDB.Driver.Core.TestHelpers { public class MockConnection : IConnection { diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoAWSAuthenticatorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoAWSAuthenticatorTests.cs index f05a3e44af3..ff05c2d3e17 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoAWSAuthenticatorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoAWSAuthenticatorTests.cs @@ -27,6 +27,7 @@ using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBCRAuthenticatorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBCRAuthenticatorTests.cs index be5015649ae..0f0c22cdd48 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBCRAuthenticatorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBCRAuthenticatorTests.cs @@ -18,14 +18,15 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; +using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; -using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Helpers; +using MongoDB.Driver.Core.Misc; +using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.WireProtocol.Messages; using Xunit; -using MongoDB.Driver.Core.Connections; -using MongoDB.Bson.TestHelpers.XunitExtensions; -using MongoDB.Driver.Core.Misc; namespace MongoDB.Driver.Core.Authentication { diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBX509AuthenticatorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBX509AuthenticatorTests.cs index 38d864cf737..3dbef36d372 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBX509AuthenticatorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBX509AuthenticatorTests.cs @@ -18,14 +18,15 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; +using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; -using MongoDB.Driver.Core.Servers; -using MongoDB.Driver.Core.Helpers; -using Xunit; using MongoDB.Driver.Core.Connections; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Misc; +using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.WireProtocol.Messages; +using Xunit; namespace MongoDB.Driver.Core.Authentication { diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/PlainAuthenticatorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/PlainAuthenticatorTests.cs index b124a5fd501..680c68ae38d 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/PlainAuthenticatorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/PlainAuthenticatorTests.cs @@ -18,14 +18,15 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; +using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; -using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Helpers; +using MongoDB.Driver.Core.Misc; +using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.WireProtocol.Messages; using Xunit; -using MongoDB.Driver.Core.Connections; -using MongoDB.Bson.TestHelpers.XunitExtensions; -using MongoDB.Driver.Core.Misc; namespace MongoDB.Driver.Core.Authentication { diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/LoadBalancedClusterTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/LoadBalancedClusterTests.cs index ddc61b4ca5c..2615d08fa64 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/LoadBalancedClusterTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/LoadBalancedClusterTests.cs @@ -24,9 +24,9 @@ using MongoDB.Driver.Core.Clusters.ServerSelectors; using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Events; -using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.TestHelpers.Logging; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/MultiServerClusterTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/MultiServerClusterTests.cs index c7f7a310d9a..32e0e2feaa4 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/MultiServerClusterTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/MultiServerClusterTests.cs @@ -24,9 +24,9 @@ using MongoDB.Bson.TestHelpers; using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Events; -using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.TestHelpers.Logging; using MongoDB.Driver.Core.Tests.Core.Clusters; using Moq; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/SingleServerClusterTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/SingleServerClusterTests.cs index 60d4464870c..8a4768cfcca 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/SingleServerClusterTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/SingleServerClusterTests.cs @@ -20,8 +20,8 @@ using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Events; -using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.TestHelpers.Logging; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/ExclusiveConnectionPoolTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/ExclusiveConnectionPoolTests.cs index d190a4db1b8..8efb66633f9 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/ExclusiveConnectionPoolTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/ExclusiveConnectionPoolTests.cs @@ -27,10 +27,10 @@ using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Events; -using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Logging; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.TestHelpers.Logging; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/MaintenanceHelperTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/MaintenanceHelperTests.cs index 8237819375c..f7480b74d29 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/MaintenanceHelperTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/MaintenanceHelperTests.cs @@ -29,6 +29,7 @@ using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Logging; using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Connections/ConnectionInitializerTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Connections/ConnectionInitializerTests.cs index f95ca071cd1..2ab40463732 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Connections/ConnectionInitializerTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Connections/ConnectionInitializerTests.cs @@ -20,17 +20,18 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Driver.Core.Clusters; -using MongoDB.Driver.Core.Misc; -using MongoDB.Driver.Core.Servers; -using MongoDB.Driver.Core.Helpers; -using Xunit; using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Authentication; +using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Compression; using MongoDB.Driver.Core.Configuration; +using MongoDB.Driver.Core.Helpers; +using MongoDB.Driver.Core.Misc; +using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.WireProtocol.Messages; using Moq; +using Xunit; namespace MongoDB.Driver.Core.Connections { diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Servers/LoadBalancedServerTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Servers/LoadBalancedServerTests.cs index 122b343e35d..81b7ed339f9 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Servers/LoadBalancedServerTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Servers/LoadBalancedServerTests.cs @@ -32,7 +32,6 @@ using MongoDB.Driver.Core.Logging; using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.TestHelpers.Logging; -using MongoDB.Driver.Specifications.connection_monitoring_and_pooling; using Moq; using Xunit; using Xunit.Abstractions; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Servers/RoundTripTimeMonitorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Servers/RoundTripTimeMonitorTests.cs index 875fd313152..a7f051d67a6 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Servers/RoundTripTimeMonitorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Servers/RoundTripTimeMonitorTests.cs @@ -27,6 +27,7 @@ using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.WireProtocol.Messages; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; using Moq; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/CommandWriteProtocolTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/CommandWriteProtocolTests.cs index 7c337b286fd..e57a78f19e8 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/CommandWriteProtocolTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/CommandWriteProtocolTests.cs @@ -31,6 +31,7 @@ using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.WireProtocol.Messages; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; using Moq; diff --git a/tests/MongoDB.Driver.Core.Tests/MongoDB.Driver.Core.Tests.csproj b/tests/MongoDB.Driver.Core.Tests/MongoDB.Driver.Core.Tests.csproj index 97beed2d159..3520a37b3d7 100644 --- a/tests/MongoDB.Driver.Core.Tests/MongoDB.Driver.Core.Tests.csproj +++ b/tests/MongoDB.Driver.Core.Tests/MongoDB.Driver.Core.Tests.csproj @@ -40,17 +40,6 @@ - - - - - - - - - - - Always diff --git a/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj b/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj index 326a865a45f..6ec7987e80b 100644 --- a/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj +++ b/tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj @@ -44,24 +44,7 @@ - - - - - - - - - - - - - - - - - - + diff --git a/tests/MongoDB.Bson.Tests/Specifications/bson-corpus/BsonCorpusTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/bson-corpus/BsonCorpusTestRunner.cs similarity index 98% rename from tests/MongoDB.Bson.Tests/Specifications/bson-corpus/BsonCorpusTestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/bson-corpus/BsonCorpusTestRunner.cs index ae3e3efd8c0..b8f775d0636 100644 --- a/tests/MongoDB.Bson.Tests/Specifications/bson-corpus/BsonCorpusTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/bson-corpus/BsonCorpusTestRunner.cs @@ -19,13 +19,14 @@ using System.Linq; using System.Text.RegularExpressions; using FluentAssertions; +using MongoDB.Bson; using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers.JsonDrivenTests; using Xunit; -namespace MongoDB.Bson.Tests.Specifications.bson_corpus +namespace MongoDB.Driver.Tests.Specifications.bson_corpus { public class BsonCorpusTestRunner { @@ -300,7 +301,7 @@ private class TestCaseFactory : JsonDrivenTestCaseFactory #endregion // protected properties - protected override string PathPrefix => "MongoDB.Bson.Tests.Specifications.bson_corpus.tests."; + protected override string PathPrefix => "MongoDB.Driver.Tests.Specifications.bson_corpus.tests."; // protected methods protected override IEnumerable CreateTestCases(BsonDocument document) diff --git a/tests/MongoDB.Bson.Tests/Specifications/bson-decimal128/TestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/bson-decimal128/TestRunner.cs similarity index 97% rename from tests/MongoDB.Bson.Tests/Specifications/bson-decimal128/TestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/bson-decimal128/TestRunner.cs index 1baf847ab01..c637063f3c5 100644 --- a/tests/MongoDB.Bson.Tests/Specifications/bson-decimal128/TestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/bson-decimal128/TestRunner.cs @@ -19,12 +19,13 @@ using System.Linq; using System.Reflection; using FluentAssertions; +using MongoDB.Bson; using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using Xunit; -namespace MongoDB.Bson.Specifications.bson_decimal128 +namespace MongoDB.Driver.Tests.Specifications.bson_decimal128 { public class TestRunner { @@ -158,7 +159,7 @@ private class TestCaseFactory : IEnumerable { public IEnumerator GetEnumerator() { - const string prefix = "MongoDB.Bson.Tests.Specifications.bson_decimal128.tests."; + const string prefix = "MongoDB.Driver.Tests.Specifications.bson_decimal128.tests."; var executingAssembly = typeof(TestCaseFactory).GetTypeInfo().Assembly; var enumerable = executingAssembly .GetManifestResourceNames() diff --git a/tests/MongoDB.Driver.Core.Tests/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs similarity index 99% rename from tests/MongoDB.Driver.Core.Tests/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs index 0a45a447b97..2ffa0181bb5 100644 --- a/tests/MongoDB.Driver.Core.Tests/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/connection-monitoring-and-pooling/ConnectionMonitoringAndPoolingTestRunner.cs @@ -33,7 +33,6 @@ using MongoDB.Driver.Core.ConnectionPools; using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Events; -using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Logging; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; @@ -42,7 +41,7 @@ using Moq; using Xunit; -namespace MongoDB.Driver.Specifications.connection_monitoring_and_pooling +namespace MongoDB.Driver.Tests.Specifications.connection_monitoring_and_pooling { [Trait("Category", "Pool")] public class ConnectionMonitoringAndPoolingTestRunner @@ -810,7 +809,7 @@ private void WaitForThread(BsonDocument operation, ConcurrentDictionary "MongoDB.Driver.Core.Tests.Specifications.connection_monitoring_and_pooling.tests.cmap_format."; + protected override string PathPrefix => "MongoDB.Driver.Tests.Specifications.connection_monitoring_and_pooling.tests.cmap_format."; protected override IEnumerable CreateTestCases(BsonDocument document) { diff --git a/tests/MongoDB.Driver.Core.Tests/Specifications/connection-string/ConnectionStringTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/connection-string/ConnectionStringTestRunner.cs similarity index 99% rename from tests/MongoDB.Driver.Core.Tests/Specifications/connection-string/ConnectionStringTestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/connection-string/ConnectionStringTestRunner.cs index 90b8705d03d..d8b268ea095 100644 --- a/tests/MongoDB.Driver.Core.Tests/Specifications/connection-string/ConnectionStringTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/connection-string/ConnectionStringTestRunner.cs @@ -28,7 +28,7 @@ using Xunit; using Xunit.Abstractions; -namespace MongoDB.Driver.Specifications.connection_string +namespace MongoDB.Driver.Tests.Specifications.connection_string { public class ConnectionStringTestRunner : LoggableTestClass { @@ -411,8 +411,8 @@ private class TestCaseFactory : JsonDrivenTestCaseFactory protected override string[] PathPrefixes => new[] { - "MongoDB.Driver.Core.Tests.Specifications.connection_string.tests.", - "MongoDB.Driver.Core.Tests.Specifications.uri_options.tests." + "MongoDB.Driver.Tests.Specifications.connection_string.tests.", + "MongoDB.Driver.Tests.Specifications.uri_options.tests." }; protected override IEnumerable CreateTestCases(BsonDocument document) diff --git a/tests/MongoDB.Driver.Core.Tests/Specifications/initial-dns-seedlist-discovery/InitialDnsSeedlistDiscoveryTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/initial-dns-seedlist-discovery/InitialDnsSeedlistDiscoveryTestRunner.cs similarity index 97% rename from tests/MongoDB.Driver.Core.Tests/Specifications/initial-dns-seedlist-discovery/InitialDnsSeedlistDiscoveryTestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/initial-dns-seedlist-discovery/InitialDnsSeedlistDiscoveryTestRunner.cs index 196bb7bcee9..13b03c6eb59 100644 --- a/tests/MongoDB.Driver.Core.Tests/Specifications/initial-dns-seedlist-discovery/InitialDnsSeedlistDiscoveryTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/initial-dns-seedlist-discovery/InitialDnsSeedlistDiscoveryTestRunner.cs @@ -28,7 +28,7 @@ using System.Threading.Tasks; using Xunit.Abstractions; -namespace MongoDB.Driver.Specifications.initial_dns_seedlist_discovery +namespace MongoDB.Driver.Tests.Specifications.initial_dns_seedlist_discovery { [Trait("Category", "ConnectionString")] [Trait("Category", "SupportLoadBalancing")] @@ -166,7 +166,7 @@ private class TestCaseFactory : IEnumerable { public IEnumerator GetEnumerator() { - const string prefix = "MongoDB.Driver.Core.Tests.Specifications.initial_dns_seedlist_discovery.tests."; + const string prefix = "MongoDB.Driver.Tests.Specifications.initial_dns_seedlist_discovery.tests."; var executingAssembly = typeof(TestCaseFactory).GetTypeInfo().Assembly; return executingAssembly .GetManifestResourceNames() diff --git a/tests/MongoDB.Driver.Core.Tests/Specifications/read-write-concern/ConnectionStringTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/read-write-concern/ConnectionStringTestRunner.cs similarity index 96% rename from tests/MongoDB.Driver.Core.Tests/Specifications/read-write-concern/ConnectionStringTestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/read-write-concern/ConnectionStringTestRunner.cs index 22f5b6fdecd..84e7d93c95d 100644 --- a/tests/MongoDB.Driver.Core.Tests/Specifications/read-write-concern/ConnectionStringTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/read-write-concern/ConnectionStringTestRunner.cs @@ -16,12 +16,12 @@ using System; using FluentAssertions; using MongoDB.Bson; +using MongoDB.Bson.TestHelpers.JsonDrivenTests; +using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Configuration; using Xunit; -using MongoDB.Bson.TestHelpers.XunitExtensions; -using MongoDB.Bson.TestHelpers.JsonDrivenTests; -namespace MongoDB.Driver.Specifications.read_write_concern.tests +namespace MongoDB.Driver.Tests.Specifications.read_write_concern.tests { public class ConnectionStringTestRunner { @@ -109,7 +109,7 @@ private BsonDocument MassageWriteConcernDocument(BsonDocument writeConcern) private class TestCaseFactory : JsonDrivenTestCaseFactory { - protected override string PathPrefix => "MongoDB.Driver.Core.Tests.Specifications.read_write_concern.tests.connection_string."; + protected override string PathPrefix => "MongoDB.Driver.Tests.Specifications.read_write_concern.tests.connection_string."; } } } diff --git a/tests/MongoDB.Driver.Core.Tests/Specifications/read-write-concern/DocumentTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/read-write-concern/DocumentTestRunner.cs similarity index 97% rename from tests/MongoDB.Driver.Core.Tests/Specifications/read-write-concern/DocumentTestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/read-write-concern/DocumentTestRunner.cs index 7b287e59df5..41ffaa01903 100644 --- a/tests/MongoDB.Driver.Core.Tests/Specifications/read-write-concern/DocumentTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/read-write-concern/DocumentTestRunner.cs @@ -20,7 +20,7 @@ using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Bson.TestHelpers.JsonDrivenTests; -namespace MongoDB.Driver.Specifications.read_write_concern.tests +namespace MongoDB.Driver.Tests.Specifications.read_write_concern.tests { public class DocumentTestRunner { @@ -135,7 +135,7 @@ private BsonDocument MassageWriteConcernDocument(BsonDocument writeConcern) private class TestCaseFactory : JsonDrivenTestCaseFactory { - protected override string PathPrefix => "MongoDB.Driver.Core.Tests.Specifications.read_write_concern.tests.document."; + protected override string PathPrefix => "MongoDB.Driver.Tests.Specifications.read_write_concern.tests.document."; } } } diff --git a/tests/MongoDB.Driver.Core.Tests/Specifications/server-discovery-and-monitoring/MonitoringTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/MonitoringTestRunner.cs similarity index 98% rename from tests/MongoDB.Driver.Core.Tests/Specifications/server-discovery-and-monitoring/MonitoringTestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/MonitoringTestRunner.cs index ddd4c010f22..0ce668d3014 100644 --- a/tests/MongoDB.Driver.Core.Tests/Specifications/server-discovery-and-monitoring/MonitoringTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/MonitoringTestRunner.cs @@ -27,14 +27,14 @@ using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Events; -using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; +using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.TestHelpers.Logging; using Xunit; using Xunit.Abstractions; -namespace MongoDB.Driver.Specifications.sdam_monitoring +namespace MongoDB.Driver.Tests.Specifications.server_discovery_and_monitoring { public class MonitoringTestRunner : LoggableTestClass { @@ -365,7 +365,7 @@ private ICluster BuildCluster(BsonDocument definition) // nested types private class TestCaseFactory : JsonDrivenTestCaseFactory { - protected override string PathPrefix => "MongoDB.Driver.Core.Tests.Specifications.server_discovery_and_monitoring.tests.monitoring."; + protected override string PathPrefix => "MongoDB.Driver.Tests.Specifications.server_discovery_and_monitoring.tests.monitoring."; protected override IEnumerable CreateTestCases(BsonDocument document) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/ServerDiscoveryAndMonitoringProseTests.cs b/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/ServerDiscoveryAndMonitoringProseTests.cs index f54b6e571ba..eab2d3a3fad 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/ServerDiscoveryAndMonitoringProseTests.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/ServerDiscoveryAndMonitoringProseTests.cs @@ -249,14 +249,6 @@ private DisposableMongoClient CreateClient(MongoClientSettings mongoClientSettin } } - internal static class ServerReflector - { - public static IServerMonitor _monitor(this IServer server) - { - return (IServerMonitor)Reflector.GetFieldValue(server, nameof(_monitor)); - } - } - internal static class ServerMonitorReflector { public static IRoundTripTimeMonitor _roundTripTimeMonitor(this IServerMonitor serverMonitor) diff --git a/tests/MongoDB.Driver.Core.Tests/Specifications/server-discovery-and-monitoring/ServerDiscoveryAndMonitoringTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/ServerDiscoveryAndMonitoringTestRunner.cs similarity index 97% rename from tests/MongoDB.Driver.Core.Tests/Specifications/server-discovery-and-monitoring/ServerDiscoveryAndMonitoringTestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/ServerDiscoveryAndMonitoringTestRunner.cs index 974ba5d1e84..e2978e23b50 100644 --- a/tests/MongoDB.Driver.Core.Tests/Specifications/server-discovery-and-monitoring/ServerDiscoveryAndMonitoringTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/ServerDiscoveryAndMonitoringTestRunner.cs @@ -15,7 +15,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Threading; using FluentAssertions; @@ -28,7 +27,6 @@ using MongoDB.Driver.Core.ConnectionPools; using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Events; -using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; using MongoDB.Driver.Core.TestHelpers; @@ -37,7 +35,7 @@ using Xunit; using Xunit.Abstractions; -namespace MongoDB.Driver.Specifications.server_discovery_and_monitoring +namespace MongoDB.Driver.Tests.Specifications.server_discovery_and_monitoring { public class ServerDiscoveryAndMonitoringTestRunner : LoggableTestClass { @@ -602,14 +600,14 @@ private class TestCaseFactory : JsonDrivenTestCaseFactory // private constants private readonly string[] MonitoringPrefixes = { - "MongoDB.Driver.Core.Tests.Specifications.server_discovery_and_monitoring.tests.monitoring.", - "MongoDB.Driver.Core.Tests.Specifications.server_discovery_and_monitoring.tests.legacy_hello.monitoring." + "MongoDB.Driver.Tests.Specifications.server_discovery_and_monitoring.tests.monitoring.", + "MongoDB.Driver.Tests.Specifications.server_discovery_and_monitoring.tests.legacy_hello.monitoring." }; // Integration tests are run by ServerDiscoveryAndMonitoringIntegrationTestRunner in MongoDB.Driver.Tests - private const string IntegrationTestPrefix = "MongoDB.Driver.Core.Tests.Specifications.server_discovery_and_monitoring.tests.integration."; + private const string IntegrationTestPrefix = "MongoDB.Driver.Tests.Specifications.server_discovery_and_monitoring.tests.integration."; - protected override string PathPrefix => "MongoDB.Driver.Core.Tests.Specifications.server_discovery_and_monitoring.tests."; + protected override string PathPrefix => "MongoDB.Driver.Tests.Specifications.server_discovery_and_monitoring.tests."; protected override IEnumerable CreateTestCases(BsonDocument document) { @@ -653,6 +651,11 @@ public static IConnectionPool _connectionPool(this Server server) return (IConnectionPool)Reflector.GetFieldValue(server, nameof(_connectionPool)); } + public static IServerMonitor _monitor(this IServer server) + { + return (IServerMonitor)Reflector.GetFieldValue(server, nameof(_monitor)); + } + public static void HandleBeforeHandshakeCompletesException(this Server server, Exception ex) { Reflector.Invoke(server, nameof(HandleBeforeHandshakeCompletesException), ex); diff --git a/tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/InWindowTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/server-selection/InWindowTestRunner.cs similarity index 97% rename from tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/InWindowTestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/server-selection/InWindowTestRunner.cs index 0b40c9815b0..1d8c9aa581b 100644 --- a/tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/InWindowTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/server-selection/InWindowTestRunner.cs @@ -31,7 +31,7 @@ using Xunit; using Xunit.Abstractions; -namespace MongoDB.Driver.Specifications.server_selection +namespace MongoDB.Driver.Tests.Specifications.server_selection { public sealed class InWindowTestRunner : LoggableTestClass { @@ -137,7 +137,7 @@ private class TestCaseFactory : JsonDrivenTestCaseFactory { protected override string[] PathPrefixes => new[] { - "MongoDB.Driver.Core.Tests.Specifications.server_selection.tests.in_window.", + "MongoDB.Driver.Tests.Specifications.server_selection.tests.in_window.", }; protected override IEnumerable CreateTestCases(BsonDocument document) diff --git a/tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/RttTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/server-selection/RttTestRunner.cs similarity index 95% rename from tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/RttTestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/server-selection/RttTestRunner.cs index c05dd8bc693..574bf4bd60e 100644 --- a/tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/RttTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/server-selection/RttTestRunner.cs @@ -24,7 +24,7 @@ using MongoDB.Driver.Core.Misc; using Xunit; -namespace MongoDB.Driver.Specifications.server_selection +namespace MongoDB.Driver.Tests.Specifications.server_selection { public class RttTestRunner { @@ -51,7 +51,7 @@ private class TestCaseFactory : IEnumerable { public IEnumerator GetEnumerator() { - const string prefix = "MongoDB.Driver.Core.Tests.Specifications.server_selection.tests.rtt."; + const string prefix = "MongoDB.Driver.Tests.Specifications.server_selection.tests.rtt."; var executingAssembly = typeof(TestCaseFactory).GetTypeInfo().Assembly; var enumerable = executingAssembly .GetManifestResourceNames() diff --git a/tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/ServerSelectionTestHelpers.cs b/tests/MongoDB.Driver.Tests/Specifications/server-selection/ServerSelectionTestHelpers.cs similarity index 99% rename from tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/ServerSelectionTestHelpers.cs rename to tests/MongoDB.Driver.Tests/Specifications/server-selection/ServerSelectionTestHelpers.cs index 4fc6a7b6b02..e619b322779 100644 --- a/tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/ServerSelectionTestHelpers.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/server-selection/ServerSelectionTestHelpers.cs @@ -22,7 +22,7 @@ using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; -namespace MongoDB.Driver.Specifications.server_selection +namespace MongoDB.Driver.Tests.Specifications.server_selection { internal static class ServerSelectionTestHelper { diff --git a/tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/ServerSelectionTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/server-selection/ServerSelectionTestRunner.cs similarity index 96% rename from tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/ServerSelectionTestRunner.cs rename to tests/MongoDB.Driver.Tests/Specifications/server-selection/ServerSelectionTestRunner.cs index 572c70ab015..4e1e1904c80 100644 --- a/tests/MongoDB.Driver.Core.Tests/Specifications/server-selection/ServerSelectionTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/server-selection/ServerSelectionTestRunner.cs @@ -25,7 +25,7 @@ using MongoDB.Driver.Core.Servers; using Xunit; -namespace MongoDB.Driver.Specifications.server_selection +namespace MongoDB.Driver.Tests.Specifications.server_selection { public class ServerSelectionTestRunner { @@ -150,8 +150,8 @@ private class TestCaseFactory : JsonDrivenTestCaseFactory { protected override string[] PathPrefixes => new[] { - "MongoDB.Driver.Core.Tests.Specifications.server_selection.tests.server_selection.", - "MongoDB.Driver.Core.Tests.Specifications.max_staleness.tests." + "MongoDB.Driver.Tests.Specifications.server_selection.tests.server_selection.", + "MongoDB.Driver.Tests.Specifications.max_staleness.tests." }; protected override IEnumerable CreateTestCases(BsonDocument document) diff --git a/tests/MongoDB.Bson.Tests/Specifications/uuid/prose-tests/ExplicitDecodingTests.cs b/tests/MongoDB.Driver.Tests/Specifications/uuid/prose-tests/ExplicitDecodingTests.cs similarity index 98% rename from tests/MongoDB.Bson.Tests/Specifications/uuid/prose-tests/ExplicitDecodingTests.cs rename to tests/MongoDB.Driver.Tests/Specifications/uuid/prose-tests/ExplicitDecodingTests.cs index c5f93e4bfec..0f36dbb40d0 100644 --- a/tests/MongoDB.Bson.Tests/Specifications/uuid/prose-tests/ExplicitDecodingTests.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/uuid/prose-tests/ExplicitDecodingTests.cs @@ -15,10 +15,11 @@ using System; using FluentAssertions; +using MongoDB.Bson; using MongoDB.Bson.TestHelpers; using Xunit; -namespace MongoDB.Bson.Tests.Specifications.uuid.prose_tests +namespace MongoDB.Driver.Tests.Specifications.uuid.prose_tests { public class ExplicitDecodingTests { diff --git a/tests/MongoDB.Bson.Tests/Specifications/uuid/prose-tests/ExplicitEncodingTests.cs b/tests/MongoDB.Driver.Tests/Specifications/uuid/prose-tests/ExplicitEncodingTests.cs similarity index 97% rename from tests/MongoDB.Bson.Tests/Specifications/uuid/prose-tests/ExplicitEncodingTests.cs rename to tests/MongoDB.Driver.Tests/Specifications/uuid/prose-tests/ExplicitEncodingTests.cs index 47eb443e4cc..ac3785d3cfc 100644 --- a/tests/MongoDB.Bson.Tests/Specifications/uuid/prose-tests/ExplicitEncodingTests.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/uuid/prose-tests/ExplicitEncodingTests.cs @@ -15,10 +15,11 @@ using System; using FluentAssertions; +using MongoDB.Bson; using MongoDB.Bson.TestHelpers; using Xunit; -namespace MongoDB.Bson.Tests.Specifications.uuid.prose_tests +namespace MongoDB.Driver.Tests.Specifications.uuid.prose_tests { public class ExplicitEncodingTests { From cae25829894fe408242fd92408a07be5f95ff87b Mon Sep 17 00:00:00 2001 From: rstam Date: Thu, 8 Dec 2022 11:33:19 -0800 Subject: [PATCH 08/21] CSHARP-4427: Negative array indexes should throw ExpressionNotSupportedException. --- .../Misc/ArraySerializerHelper.cs | 20 +++++++++++ ...yIndexExpressionToFilterFieldTranslator.cs | 33 +++++++++++-------- .../ElementAtMethodToFilterFieldTranslator.cs | 22 +------------ .../GetItemMethodToFilterFieldTranslator.cs | 27 +++------------ .../UpdateDefinitionBuilderTests.cs | 17 ++++++---- 5 files changed, 56 insertions(+), 63 deletions(-) diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Misc/ArraySerializerHelper.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Misc/ArraySerializerHelper.cs index 744e0b62ae0..80eb292c57d 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Misc/ArraySerializerHelper.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Misc/ArraySerializerHelper.cs @@ -14,6 +14,7 @@ */ using System; +using System.Linq.Expressions; using MongoDB.Bson.Serialization; namespace MongoDB.Driver.Linq.Linq3Implementation.Misc @@ -38,5 +39,24 @@ public static IBsonSerializer GetItemSerializer(IBsonSerializer serializer) throw new InvalidOperationException($"{serializer.GetType().FullName} must implement IBsonArraySerializer to be used with LINQ."); } } + + public static IBsonSerializer GetItemSerializer(Expression expression, IBsonSerializer serializer) + { + if (serializer is IBsonArraySerializer arraySerializer) + { + if (arraySerializer.TryGetItemSerializationInfo(out var itemSerializationInfo)) + { + return itemSerializationInfo.Serializer; + } + else + { + throw new ExpressionNotSupportedException(expression, because: $"{serializer.GetType().FullName}.TryGetItemSerializationInfo returned false"); + } + } + else + { + throw new ExpressionNotSupportedException(expression, because: $"{serializer.GetType().FullName} must implement IBsonArraySerializer to be used with LINQ"); + } + } } } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ArrayIndexExpressionToFilterFieldTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ArrayIndexExpressionToFilterFieldTranslator.cs index 5e970092b72..57e81610094 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ArrayIndexExpressionToFilterFieldTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ArrayIndexExpressionToFilterFieldTranslator.cs @@ -14,6 +14,7 @@ */ using System.Linq.Expressions; +using MongoDB.Bson.Serialization; using MongoDB.Driver.Linq.Linq3Implementation.Ast.Filters; using MongoDB.Driver.Linq.Linq3Implementation.ExtensionMethods; using MongoDB.Driver.Linq.Linq3Implementation.Misc; @@ -27,25 +28,31 @@ public static AstFilterField Translate(TranslationContext context, BinaryExpress if (expression.NodeType == ExpressionType.ArrayIndex) { var arrayExpression = expression.Left; - var arrayField = ExpressionToFilterFieldTranslator.Translate(context, arrayExpression); var indexExpression = expression.Right; - var index = indexExpression.GetConstantValue(containingExpression: expression); - if (index < 0) + return Translate(context, expression, fieldExpression: arrayExpression, indexExpression); + } + + throw new ExpressionNotSupportedException(expression); + } + + public static AstFilterField Translate(TranslationContext context, Expression expression, Expression fieldExpression, Expression indexExpression) + { + var field = ExpressionToFilterFieldTranslator.TranslateEnumerable(context, fieldExpression); + var index = indexExpression.GetConstantValue(containingExpression: expression); + var itemSerializer = ArraySerializerHelper.GetItemSerializer(fieldExpression, field.Serializer); + + if (index < 0) + { + var reason = "negative indexes are not valid"; + if (index == -1) { - var reason = "negative indexes are not valid"; - if (index == -1) - { - reason += ". To use the positional operator $ use FirstMatchingElement instead of an index value of -1"; // closing period is added by exception - } - throw new ExpressionNotSupportedException(expression, because: reason); + reason += ". To use the positional operator $ use FirstMatchingElement instead of an index value of -1"; // closing period is added by exception } - - var itemSerializer = ArraySerializerHelper.GetItemSerializer(arrayField.Serializer); - return arrayField.SubField(index.ToString(), itemSerializer); + throw new ExpressionNotSupportedException(expression, because: reason); } - throw new ExpressionNotSupportedException(expression); + return field.SubField(index.ToString(), itemSerializer); } } } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ElementAtMethodToFilterFieldTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ElementAtMethodToFilterFieldTranslator.cs index a0440177b0b..caab7af0051 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ElementAtMethodToFilterFieldTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/ElementAtMethodToFilterFieldTranslator.cs @@ -14,9 +14,7 @@ */ using System.Linq.Expressions; -using MongoDB.Bson.Serialization; using MongoDB.Driver.Linq.Linq3Implementation.Ast.Filters; -using MongoDB.Driver.Linq.Linq3Implementation.ExtensionMethods; using MongoDB.Driver.Linq.Linq3Implementation.Misc; using MongoDB.Driver.Linq.Linq3Implementation.Reflection; @@ -32,27 +30,9 @@ public static AstFilterField Translate(TranslationContext context, MethodCallExp if (method.Is(EnumerableMethod.ElementAt)) { var sourceExpression = arguments[0]; - var field = ExpressionToFilterFieldTranslator.Translate(context, sourceExpression); - var indexExpression = arguments[1]; - var index = indexExpression.GetConstantValue(containingExpression: expression); - - if (index < 0) - { - var reason = "negative indexes are not valid"; - if (index == -1) - { - reason += ". To use the positional operator $ use FirstMatchingElement instead of an index value of -1"; // closing period is added by exception - } - throw new ExpressionNotSupportedException(expression, because: reason); - } - if (field.Serializer is IBsonArraySerializer arraySerializer && - arraySerializer.TryGetItemSerializationInfo(out var itemSerializationInfo)) - { - var itemSerializer = itemSerializationInfo.Serializer; - return field.SubField(index.ToString(), itemSerializer); - } + return ArrayIndexExpressionToFilterFieldTranslator.Translate(context, expression, fieldExpression: sourceExpression, indexExpression); } throw new ExpressionNotSupportedException(expression); diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/GetItemMethodToFilterFieldTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/GetItemMethodToFilterFieldTranslator.cs index 43382307655..1de2a6e41af 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/GetItemMethodToFilterFieldTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ToFilterFieldTranslators/GetItemMethodToFilterFieldTranslator.cs @@ -21,7 +21,6 @@ using MongoDB.Bson.Serialization.Serializers; using MongoDB.Driver.Linq.Linq3Implementation.Ast.Filters; using MongoDB.Driver.Linq.Linq3Implementation.ExtensionMethods; -using MongoDB.Driver.Linq.Linq3Implementation.Misc; namespace MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToFilterTranslators.ToFilterFieldTranslators { @@ -42,40 +41,22 @@ public static AstFilterField Translate(TranslationContext context, MethodCallExp if (indexExpression.Type == typeof(int)) { - var index = indexExpression.GetConstantValue(containingExpression: expression); - return TranslateWithIntIndex(context, expression, method, fieldExpression, index); + return ArrayIndexExpressionToFilterFieldTranslator.Translate(context, expression, fieldExpression, indexExpression); } if (indexExpression.Type == typeof(string)) { - var key = indexExpression.GetConstantValue(containingExpression: expression); - return TranslateWithStringIndex(context, expression, method, fieldExpression, key); + return TranslateWithStringIndex(context, expression, method, fieldExpression, indexExpression); } } throw new ExpressionNotSupportedException(expression); } - private static AstFilterField TranslateWithIntIndex(TranslationContext context, MethodCallExpression expression, MethodInfo method, Expression fieldExpression, int index) - { - var field = ExpressionToFilterFieldTranslator.TranslateEnumerable(context, fieldExpression); - - if (field.Serializer is IBsonArraySerializer arraySerializer && - arraySerializer.TryGetItemSerializationInfo(out var itemSerializationInfo)) - { - var itemSerializer = itemSerializationInfo.Serializer; - if (method.ReturnType.IsAssignableFrom(itemSerializer.ValueType)) - { - return field.SubField(index.ToString(), itemSerializer); - } - } - - throw new ExpressionNotSupportedException(expression); - } - - private static AstFilterField TranslateWithStringIndex(TranslationContext context, MethodCallExpression expression, MethodInfo method, Expression fieldExpression, string key) + private static AstFilterField TranslateWithStringIndex(TranslationContext context, MethodCallExpression expression, MethodInfo method, Expression fieldExpression, Expression indexExpression) { var field = ExpressionToFilterFieldTranslator.Translate(context, fieldExpression); + var key = indexExpression.GetConstantValue(containingExpression: expression); if (typeof(BsonValue).IsAssignableFrom(field.Serializer.ValueType)) { diff --git a/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs index 41f882948b8..29d461f9715 100644 --- a/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs @@ -244,13 +244,13 @@ public void Inc_Typed() public void Incorrect_index_should_throw_expected_exception_with_set() { var subject = CreateSubject(); - string expectedErrorMessage = "Array indexes must be greater than or equal to -1."; + string expectedErrorMessage = "because negative indexes are not valid"; #pragma warning disable 251 - AssertThrow(subject.Set(x => x.FavoriteColors[-2], "yellow"), expectedErrorMessage); + AssertThrow(subject.Set(x => x.FavoriteColors[-2], "yellow"), expectedErrorMessage, LinqProvider.V3); #pragma warning restore - AssertThrow(subject.Set(x => x.Pets[-2].Name, "Fluffencutters"), expectedErrorMessage); - AssertThrow(subject.Set(x => x.Pets.ElementAt(-2).Name, "Fluffencutters"), expectedErrorMessage); + AssertThrow(subject.Set(x => x.Pets[-2].Name, "Fluffencutters"), expectedErrorMessage, LinqProvider.V3); + AssertThrow(subject.Set(x => x.Pets.ElementAt(-2).Name, "Fluffencutters"), expectedErrorMessage, LinqProvider.V3); } [Fact] @@ -681,9 +681,14 @@ private void Assert(UpdateDefinition update, string expect private void AssertThrow(UpdateDefinition update, string errorMessage) where TException : Exception { - var exception = Record.Exception(() => { Render(update); }); + AssertThrow(update, errorMessage, LinqProvider.V2); + } + + private void AssertThrow(UpdateDefinition update, string errorMessage, LinqProvider linqProvider) where TException : Exception + { + var exception = Record.Exception(() => { Render(update, linqProvider); }); exception.Should().BeOfType(); - exception.Message.Should().Be(errorMessage); + exception.Message.Should().Contain(errorMessage); } private UpdateDefinitionBuilder CreateSubject() From 20bc1eb13519b69947d16bbda13d3fb14133b867 Mon Sep 17 00:00:00 2001 From: Dmitry Lukyanov Date: Thu, 8 Dec 2022 23:56:33 +0400 Subject: [PATCH 09/21] CSHARP-4399: Remove use of activate_venv.sh and utils.sh. (#983) --- evergreen/evergreen.yml | 75 +++++++++++++++++++++++------------- evergreen/get-python-path.sh | 29 -------------- 2 files changed, 49 insertions(+), 55 deletions(-) delete mode 100644 evergreen/get-python-path.sh diff --git a/evergreen/evergreen.yml b/evergreen/evergreen.yml index 2e3b77bfa00..0965d68e9a9 100644 --- a/evergreen/evergreen.yml +++ b/evergreen/evergreen.yml @@ -446,11 +446,12 @@ functions: type: test params: silent: true + shell: "bash" working_dir: mongo-csharp-driver script: | ${PREPARE_SHELL} cd ${DRIVERS_TOOLS}/.evergreen/auth_aws - . ./activate_venv.sh + . ./activate-authawsvenv.sh mongo aws_e2e_regular_aws.js - command: shell.exec type: test @@ -470,12 +471,13 @@ functions: type: test params: silent: true + shell: "bash" working_dir: mongo-csharp-driver script: | ${PREPARE_SHELL} # The aws_e2e_assume_role script requires python3 with boto3. cd ${DRIVERS_TOOLS}/.evergreen/auth_aws - . ./activate_venv.sh + . ./activate-authawsvenv.sh mongo aws_e2e_assume_role.js - command: shell.exec type: test @@ -501,6 +503,7 @@ functions: type: test params: silent: true + shell: "bash" working_dir: mongo-csharp-driver script: | ${PREPARE_SHELL} @@ -509,7 +512,7 @@ functions: exit 0 fi cd ${DRIVERS_TOOLS}/.evergreen/auth_aws - . ./activate_venv.sh + . ./activate-authawsvenv.sh mongo aws_e2e_ec2.js - command: shell.exec type: test @@ -532,6 +535,7 @@ functions: type: test params: silent: true + shell: "bash" working_dir: mongo-csharp-driver script: | ${PREPARE_SHELL} @@ -540,7 +544,7 @@ functions: exit 0 fi cd ${DRIVERS_TOOLS}/.evergreen/auth_aws - . ./activate_venv.sh + . ./activate-authawsvenv.sh echo "Project Directory: $PROJECT_DIRECTORY" # SRC_DIRECTORY is workaround since EG_TOOLS expects "src" folder as a root SRC_DIRECTORY=$(dirname $PROJECT_DIRECTORY)/src @@ -560,6 +564,7 @@ functions: - command: shell.exec type: test params: + shell: "bash" working_dir: mongo-csharp-driver script: | ${PREPARE_SHELL} @@ -568,7 +573,7 @@ functions: exit 0 fi cd ${DRIVERS_TOOLS}/.evergreen/auth_aws - . ./activate_venv.sh + . ./activate-authawsvenv.sh mongo aws_e2e_web_identity.js - command: shell.exec type: test @@ -708,10 +713,12 @@ functions: - command: shell.exec params: background: true + shell: "bash" script: | set -o xtrace cd ${DRIVERS_TOOLS}/.evergreen/ocsp - nohup ./venv/Scripts/python ocsp_mock.py \ + . ./activate-ocspvenv.sh + nohup python ocsp_mock.py \ --ca_file ${OCSP_ALGORITHM}/ca.pem \ --ocsp_responder_cert ${OCSP_ALGORITHM}/ca.crt \ --ocsp_responder_key ${OCSP_ALGORITHM}/ca.key \ @@ -727,10 +734,12 @@ functions: - command: shell.exec params: background: true + shell: "bash" script: | set -o xtrace cd ${DRIVERS_TOOLS}/.evergreen/ocsp - nohup ./venv/Scripts/python ocsp_mock.py \ + . ./activate-ocspvenv.sh + nohup python ocsp_mock.py \ --ca_file ${OCSP_ALGORITHM}/ca.pem \ --ocsp_responder_cert ${OCSP_ALGORITHM}/ocsp-responder.crt \ --ocsp_responder_key ${OCSP_ALGORITHM}/ocsp-responder.key \ @@ -746,10 +755,12 @@ functions: - command: shell.exec params: background: true + shell: "bash" script: | set -o xtrace cd ${DRIVERS_TOOLS}/.evergreen/ocsp - nohup ./venv/Scripts/python.exe ocsp_mock.py \ + . ./activate-ocspvenv.sh + nohup python ocsp_mock.py \ --ca_file ${OCSP_ALGORITHM}/ca.pem \ --ocsp_responder_cert ${OCSP_ALGORITHM}/ca.crt \ --ocsp_responder_key ${OCSP_ALGORITHM}/ca.key \ @@ -767,10 +778,12 @@ functions: - command: shell.exec params: background: true + shell: "bash" script: | set -o xtrace cd ${DRIVERS_TOOLS}/.evergreen/ocsp - nohup ./venv/Scripts/python.exe ocsp_mock.py \ + . ./activate-ocspvenv.sh + nohup python ocsp_mock.py \ --ca_file ${OCSP_ALGORITHM}/ca.pem \ --ocsp_responder_cert ${OCSP_ALGORITHM}/ocsp-responder.crt \ --ocsp_responder_key ${OCSP_ALGORITHM}/ocsp-responder.key \ @@ -848,83 +861,93 @@ functions: start-kms-mock-servers: - command: shell.exec params: + shell: "bash" script: | ${PREPARE_SHELL} cd ${DRIVERS_TOOLS}/.evergreen/csfle - . ./activate_venv.sh + . ./activate-kmstlsvenv.sh - command: shell.exec params: background: true + shell: "bash" script: | #expired client cert - PYTHON=$(Venv="${DRIVERS_TOOLS}/.evergreen/csfle/kmstlsvenv" OS=${OS} ${PROJECT_DIRECTORY}/evergreen/get-python-path.sh); cd ${DRIVERS_TOOLS}/.evergreen/csfle - $PYTHON -u kms_http_server.py -v --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 8000 + . ./activate-kmstlsvenv.sh + python -u kms_http_server.py -v --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 8000 - command: shell.exec params: background: true + shell: "bash" script: | #wrong-host client cert - PYTHON=$(Venv="${DRIVERS_TOOLS}/.evergreen/csfle/kmstlsvenv" OS=${OS} ${PROJECT_DIRECTORY}/evergreen/get-python-path.sh); cd ${DRIVERS_TOOLS}/.evergreen/csfle - $PYTHON -u kms_http_server.py -v --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 8001 + . ./activate-kmstlsvenv.sh + python -u kms_http_server.py -v --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 8001 - command: shell.exec params: background: true + shell: "bash" script: | #server.pem client cert - PYTHON=$(Venv="${DRIVERS_TOOLS}/.evergreen/csfle/kmstlsvenv" OS=${OS} ${PROJECT_DIRECTORY}/evergreen/get-python-path.sh); cd ${DRIVERS_TOOLS}/.evergreen/csfle - $PYTHON -u kms_http_server.py -v --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 8002 --require_client_cert + . ./activate-kmstlsvenv.sh + python -u kms_http_server.py -v --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 8002 --require_client_cert start-kms-mock-kmip-server: - command: shell.exec params: + shell: "bash" script: | ${PREPARE_SHELL} cd ${DRIVERS_TOOLS}/.evergreen/csfle - . ./activate_venv.sh + . ./activate-kmstlsvenv.sh - command: shell.exec params: + shell: "bash" background: true script: | - PYTHON=$(Venv="${DRIVERS_TOOLS}/.evergreen/csfle/kmstlsvenv" OS=${OS} ${PROJECT_DIRECTORY}/evergreen/get-python-path.sh); cd ${DRIVERS_TOOLS}/.evergreen/csfle - $PYTHON -u kms_kmip_server.py + . ./activate-kmstlsvenv.sh + python -u kms_kmip_server.py start-kms-mock-gcp-server: - command: shell.exec params: + shell: "bash" script: | ${PREPARE_SHELL} cd ${DRIVERS_TOOLS}/.evergreen/csfle - . ./activate_venv.sh + . ./activate-kmstlsvenv.sh - command: shell.exec params: background: true + shell: "bash" script: | - PYTHON=$(Venv="${DRIVERS_TOOLS}/.evergreen/csfle/kmstlsvenv" OS=${OS} ${PROJECT_DIRECTORY}/evergreen/get-python-path.sh); cd ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms - $PYTHON -m pip install PyJWT + . ./activate-kmstlsvenv.sh + python -m pip install PyJWT mkdir ${DRIVERS_TOOLS}/tmp echo '${GOOGLE_APPLICATION_CREDENTIALS_CONTENT}' > ${DRIVERS_TOOLS}/tmp/testgcpkms_key_file.json export GOOGLE_APPLICATION_CREDENTIALS=${DRIVERS_TOOLS}/tmp/testgcpkms_key_file.json - $PYTHON -u mock_server.py + python -u mock_server.py start-kms-mock-azure-imds-server: - command: shell.exec params: + shell: "bash" script: | ${PREPARE_SHELL} cd ${DRIVERS_TOOLS}/.evergreen/csfle - . ./activate_venv.sh + . ./activate-kmstlsvenv.sh - command: shell.exec params: background: true + shell: "bash" script: | - PYTHON=$(Venv="${DRIVERS_TOOLS}/.evergreen/csfle/kmstlsvenv" OS=${OS} ${PROJECT_DIRECTORY}/evergreen/get-python-path.sh); cd ${DRIVERS_TOOLS}/.evergreen/csfle - $PYTHON bottle.py fake_azure:imds + . ./activate-kmstlsvenv.sh + python bottle.py fake_azure:imds cleanup: - command: shell.exec diff --git a/evergreen/get-python-path.sh b/evergreen/get-python-path.sh deleted file mode 100644 index a99b3155f22..00000000000 --- a/evergreen/get-python-path.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -# Find the version of python on the system. -# -# Environment variables used as input: -# Venv Venv path -# OS The current operating system -# -# Environment variables produced as output: -# PYTHON The python path - -# Don't write anything to output -if [ -z "$Venv" ]; then - if [ -e "/cygdrive/c/python/Python39/python" ]; then - echo "/cygdrive/c/python/Python39/python" - elif [ -e "/opt/mongodbtoolchain/v3/bin/python3" ]; then - echo "/opt/mongodbtoolchain/v3/bin/python3" - elif python3 --version >/dev/null 2>&1; then - echo python3 - else - echo python - fi -else - if [[ "$OS" =~ Windows|windows ]]; then - echo "${Venv}/Scripts/python" - else - echo "${Venv}/bin/python" - fi -fi From 40b011d221339c43a504f0b4341cb29db7054caa Mon Sep 17 00:00:00 2001 From: BorisDog Date: Mon, 12 Dec 2022 08:34:52 -0800 Subject: [PATCH 10/21] CSHARP-4400: Upgrade xunit to 2.4.2 and remove SkippableFact package (#935) --- CSharpDriver.sln | 16 +- tests/BuildProps/Tests.Build.props | 6 +- .../GuidModeValues.cs | 2 +- .../MongoDB.Bson.TestHelpers.csproj | 1 + .../IO/ArrayElementNameAcceleratorTests.cs | 2 +- .../IO/BsonBinaryReaderTests.cs | 4 +- .../IO/BsonBinaryWriterTests.cs | 7 +- .../IO/BsonChunkPoolTests.cs | 2 +- .../IO/BsonDocumentReaderTests.cs | 2 +- .../IO/BsonStreamAdapterTests.cs | 2 +- .../IO/BsonStreamExtensionsTests.cs | 2 +- .../MongoDB.Bson.Tests/IO/BsonWriterTests.cs | 2 +- .../IO/ByteArrayBufferTests.cs | 2 +- .../IO/ByteArrayChunkTests.cs | 2 +- .../IO/ByteBufferFactoryTests.cs | 2 +- .../IO/ByteBufferSliceTests.cs | 2 +- .../IO/ByteBufferStreamTests.cs | 4 +- .../IO/CStringUtf8EncodingTests.cs | 2 +- .../IO/EncodingHelperTests.cs | 2 +- .../IO/InputBufferChunkSourceTests.cs | 2 +- .../MongoDB.Bson.Tests/IO/JsonReaderTests.cs | 2 +- .../MongoDB.Bson.Tests/IO/JsonWriterTests.cs | 4 +- .../IO/MultiChunkBufferTests.cs | 4 +- .../IO/OutputBufferChunkSourceTests.cs | 2 +- .../IO/SingleChunkBufferTests.cs | 2 +- .../IO/ThreadStaticBufferTests.cs | 2 +- .../MongoDB.Bson.Tests/Jira/CSharp147Tests.cs | 2 +- .../MongoDB.Bson.Tests/Jira/CSharp275Tests.cs | 2 +- .../ObjectModel/BsonArrayTests.cs | 1 + .../ObjectModel/BsonBinaryDataTests.cs | 2 +- .../ObjectModel/BsonBooleanTests.cs | 2 +- .../ObjectModel/BsonDocumentTests.cs | 2 +- .../ObjectModel/BsonDoubleTests.cs | 6 +- .../ObjectModel/BsonInt32Tests.cs | 6 +- .../ObjectModel/BsonInt64Tests.cs | 6 +- .../ObjectModel/BsonStringTests.cs | 2 +- .../ObjectModel/BsonTypeMapperTests.cs | 2 +- .../ObjectModel/BsonValueTests.cs | 2 +- .../ObjectModel/LazyBsonDocumentTests.cs | 4 +- .../ObjectModel/RawBsonArrayTests.cs | 2 +- tests/MongoDB.Bson.Tests/PowerOf2Tests.cs | 2 +- .../Properties/AssemblyInfo.cs | 4 + .../Conventions/ConventionRunnerTests.cs | 2 +- .../BsonBinaryDataSerializerTests.cs | 2 +- .../BsonPrimitiveSerializerTests.cs | 2 +- .../Serializers/BsonValueSerializerTests.cs | 2 +- .../CollectionSerializerGenericTests.cs | 2 +- .../Serializers/CollectionSerializerTests.cs | 2 +- .../DateTimeOffsetSerializerTests.cs | 2 +- .../DictionaryGenericSerializerTests.cs | 2 +- .../Serializers/DictionarySerializerTests.cs | 2 +- .../ElementAppendingSerializerTests.cs | 2 +- .../Serializers/EnumSerializerTests.cs | 2 +- .../Serializers/ExtraElementsTests.cs | 2 +- .../ExtraElementsWithImmutableClassTests.cs | 2 +- ...lementsWithPartiallyImmutableClassTests.cs | 2 +- .../Serializers/GuidSerializerTests.cs | 2 +- .../NullableTypeSerializerTests.cs | 2 +- .../Serializers/ObjectSerializerTests.cs | 8 +- .../Logging/LoggableTestClass.cs | 47 ++--- .../XunitExtensions/RequirePlatform.cs | 1 + .../XunitExtensions/RequireServer.cs | 1 + .../XunitExtensions/XunitExtensionsConsts.cs | 8 - .../BatchTransformingAsyncCursorTests.cs | 2 +- .../CollationTests.cs | 2 +- .../AuthenticationHelperTests.cs | 2 +- .../CacheableCredentialsProviderTests.cs | 2 +- .../GssapiSecurityCredentialTests.cs | 8 +- .../MongoAWSAuthenticatorTests.cs | 2 +- .../MongoDBCRAuthenticatorTests.cs | 2 +- .../MongoDBX509AuthenticatorTests.cs | 2 +- .../Authentication/PlainAuthenticatorTests.cs | 2 +- .../Authentication/SaslPrepHelperTests.cs | 2 +- .../ScramSha1AuthenticatorTests.cs | 2 +- .../ScramSha256AuthenticatorTests.cs | 2 +- .../Bindings/ChannelChannelSourceTests.cs | 2 +- .../Core/Bindings/ChannelReadBindingTests.cs | 2 +- .../Bindings/ChannelReadWriteBindingTests.cs | 2 +- .../Core/Bindings/ChannelSourceHandleTests.cs | 2 +- .../ChannelSourceReadWriteBindingTests.cs | 2 +- .../Core/Bindings/CoreSessionOptionsTests.cs | 2 +- .../Core/Bindings/CoreSessionTests.cs | 4 +- .../Core/Bindings/CoreTransactionTests.cs | 2 +- .../Core/Bindings/NoCoreServerSessionTests.cs | 2 +- .../Core/Bindings/NoCoreSessionTests.cs | 2 +- .../Core/Bindings/ReadBindingHandleTests.cs | 2 +- .../Bindings/ReadPreferenceBindingTests.cs | 2 +- .../Bindings/ReadWriteBindingHandleTests.cs | 2 +- .../Core/Bindings/ServerChannelSourceTests.cs | 2 +- .../Bindings/SingleServerReadBindingTests.cs | 2 +- .../SingleServerReadWriteBindingTests.cs | 2 +- .../Bindings/WritableServerBindingTests.cs | 2 +- .../Core/Clusters/ClusterDescriptionTests.cs | 2 +- .../Core/Clusters/ClusterTests.cs | 2 +- .../Core/Clusters/LoadBalancedClusterTests.cs | 2 +- .../Core/Clusters/SingleServerClusterTests.cs | 2 +- .../Core/Compression/CompressorsTests.cs | 2 +- .../Configuration/ClusterSettingsTests.cs | 2 +- .../ConnectionPoolSettingsTests.cs | 2 +- .../Configuration/ConnectionSettingsTests.cs | 2 +- .../Configuration/ConnectionStringTests.cs | 2 +- .../Configuration/TcpStreamSettingsTests.cs | 2 +- .../ExclusiveConnectionPoolTests.cs | 2 +- .../ConnectionPools/MaintenanceHelperTests.cs | 2 +- .../Core/Connections/BinaryConnectionTests.cs | 2 +- .../Connections/ClientDocumentHelperTests.cs | 2 +- .../Connections/CommandEventHelperTests.cs | 2 +- .../Connections/ConnectionInitializerTests.cs | 2 +- .../Core/Connections/HelloHelperTests.cs | 2 +- .../Core/Connections/HelloResultTests.cs | 2 +- .../Core/Connections/TcpStreamFactoryTests.cs | 8 +- .../Core/Events/EventPublisherTests.cs | 2 +- .../Core/Misc/BatchableSourceTests.cs | 2 +- .../Core/Misc/SemaphoreSlimSignalableTests.cs | 2 +- .../Core/Misc/StreamExtensionMethodsTests.cs | 2 +- .../Core/Misc/WireVersionTests.cs | 2 +- .../AggregateExplainOperationTests.cs | 22 +-- .../Operations/AggregateOperationTests.cs | 30 +-- .../AggregateToCollectionOperationTests.cs | 26 +-- ...AsyncCursorSourceEnumerableAdapterTests.cs | 2 +- .../Core/Operations/AsyncCursorTests.cs | 2 +- .../Operations/BulkDeleteOperationTests.cs | 2 +- .../BulkMixedWriteOperationTests.cs | 88 ++++----- .../Operations/BulkUpdateOperationTests.cs | 2 +- .../Operations/ChangeStreamCursorTests.cs | 6 +- .../Operations/ChangeStreamOperationTests.cs | 16 +- .../Operations/CommandOperationBaseTests.cs | 2 +- .../CompositeWriteOperationTests.cs | 2 +- .../CountDocumentsOperationTests.cs | 24 +-- .../Core/Operations/CountOperationTests.cs | 22 +-- .../CreateCollectionOperationTests.cs | 28 +-- .../Operations/CreateIndexRequestTests.cs | 2 +- .../Operations/CreateIndexesOperationTests.cs | 30 +-- .../Operations/CreateViewOperationTests.cs | 12 +- .../DatabaseExistsOperationTests.cs | 6 +- .../Core/Operations/DistinctOperationTests.cs | 16 +- .../DropCollectionOperationTests.cs | 10 +- .../Operations/DropDatabaseOperationTests.cs | 8 +- .../Operations/DropIndexOperationTests.cs | 12 +- .../EndTransactionOperationTests.cs | 2 +- .../EstimatedDocumentCountOperationTests.cs | 14 +- .../Core/Operations/EvalOperationTests.cs | 10 +- .../Core/Operations/ExplainOperationTests.cs | 4 +- .../FindOneAndDeleteOperationTests.cs | 16 +- .../FindOneAndReplaceOperationTests.cs | 22 +-- .../FindOneAndUpdateOperationTests.cs | 24 +-- .../Core/Operations/FindOperationTests.cs | 18 +- .../Core/Operations/GeoNearOperationTests.cs | 10 +- .../Operations/GeoSearchOperationTests.cs | 8 +- .../Core/Operations/GroupOperationTests.cs | 20 +- .../Core/Operations/IndexNameHelperTests.cs | 2 +- .../Operations/InsertOpcodeOperationTests.cs | 6 +- .../ListCollectionsOperationTests.cs | 12 +- .../Operations/ListDatabasesOperationTests.cs | 8 +- .../Operations/ListIndexesOperationTests.cs | 12 +- .../ListIndexesUsingCommandOperationTests.cs | 12 +- .../MapReduceLegacyOperationTests.cs | 6 +- .../Operations/MapReduceOperationBaseTests.cs | 2 +- .../Operations/MapReduceOperationTests.cs | 32 ++-- ...pReduceOutputToCollectionOperationTests.cs | 24 +-- .../Core/Operations/MaxTimeHelperTests.cs | 2 +- .../Core/Operations/ReIndexOperationTests.cs | 6 +- .../Operations/ReadCommandOperationTests.cs | 2 +- .../RenameCollectionOperationTests.cs | 12 +- .../Operations/RetryabilityHelperTests.cs | 2 +- .../RetryableDeleteCommandOperationTests.cs | 2 +- .../RetryableUpdateCommandOperationTests.cs | 2 +- .../Operations/UpdateOpcodeOperationTests.cs | 2 +- .../Operations/WriteCommandOperationTests.cs | 2 +- .../Core/Servers/HeartbeatDelayTests.cs | 2 +- .../Core/Servers/LoadBalancedServerTests.cs | 2 +- .../Core/Servers/ServerTests.cs | 8 +- .../WireProtocol/CommandWriteProtocolTests.cs | 2 +- .../Messages/CommandMessageSectionTests.cs | 2 +- .../Messages/CommandMessageTests.cs | 2 +- .../CommandMessageBinaryEncoderTests.cs | 2 +- .../MessageBinaryEncoderBaseTests.cs | 2 +- .../QueryMessageBinaryEncoderTests.cs | 2 +- .../CommandMessageJsonEncoderTests.cs | 2 +- .../Messages/QueryMessageTests.cs | 2 +- .../CreateIndexCommitQuorumTests.cs | 2 +- .../IAsyncCursorExtensionsTests.cs | 2 +- .../IAsyncCursorSourceExtensionsTests.cs | 2 +- .../Jira/CSharp3173Tests.cs | 2 +- .../LoadBalancingIntergationTests.cs | 16 +- .../MongoExceptionTests.cs | 2 +- .../Properties/AssemblyInfo.cs | 4 +- .../ReadConcernTests.cs | 2 +- .../ReadPreferenceHedgeTests.cs | 2 +- .../ReadPreferenceTests.cs | 2 +- .../TransactionOptionsTests.cs | 2 +- .../WriteConcernTests.cs | 2 +- .../ClientSideEncryption2Examples.cs | 2 +- .../Properties/AssemblyInfo.cs | 3 + .../WithTransactionExample1.cs | 2 +- tests/MongoDB.Driver.Examples/UpdatePrimer.cs | 4 +- .../DelegatingStreamTests.cs | 2 +- .../GridFSBucketOptionsTests.cs | 2 +- .../GridFSBucketTests.cs | 6 +- .../GridFSDownloadStreamBaseTests.cs | 2 +- .../GridFSFileInfoTests.cs | 2 +- .../GridFSFindOptionsTests.cs | 2 +- .../GridFSSeekableDownloadStreamTests.cs | 2 +- .../GridFSUploadOptionsTests.cs | 2 +- .../GridFSUploadStreamTests.cs | 2 +- .../Properties/AssemblyInfo.cs | 4 +- .../Specifications/gridfs/GridFSTestRunner.cs | 5 +- .../Builders/IndexKeysBuilderTests.cs | 6 +- .../Builders/IndexKeysBuilderTypedTests.cs | 6 +- .../ClientDocumentHelperTests.cs | 2 +- .../CollectionStatsResultTests.cs | 2 +- .../DatabaseStatsResultTests.cs | 4 +- .../DefaultLegacyOperationExecutorTests.cs | 2 +- .../Jira/CSharp216Tests.cs | 6 +- .../Jira/CSharp269Tests.cs | 2 +- .../Jira/CSharp365Tests.cs | 2 +- .../BsonDocumentBackedClassSerializerTests.cs | 2 +- .../Linq/ExplainTests.cs | 4 +- .../Linq/SelectNullableTests.cs | 4 +- .../Linq/SelectOfTypeHierarchicalTests.cs | 2 +- .../Linq/SelectQueryTests.cs | 10 +- .../Linq/WithIndexTests.cs | 4 +- .../MongoCollectionTests.cs | 96 +++++----- .../MongoDatabaseTests.cs | 34 ++-- .../MongoServerTests.cs | 6 +- .../Operations/BulkWriteOperationTests.cs | 92 ++++----- .../Operations/CurrentOpOperationTests.cs | 4 +- .../CurrentOpUsingCommandOperation.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../AggregateFluentBucketAutoTests.cs | 10 +- .../AggregateFluentBucketTests.cs | 8 +- .../AggregateFluentFacetTests.cs | 12 +- ...tGraphLookupWithAirportsCollectionTests.cs | 6 +- ...tGraphLookupWithEmployeeCollectionTests.cs | 8 +- .../AggregateFluentTests.cs | 18 +- ...egateGraphLookupEnumerableFromOrToTests.cs | 6 +- .../MongoDB.Driver.Tests/AsyncCursorTests.cs | 8 +- .../AuthenticationTests.cs | 32 ++-- .../CausalConsistencyTests.cs | 18 +- .../ClientSessionHandleTests.cs | 2 +- .../ClientSessionOptionsTests.cs | 2 +- tests/MongoDB.Driver.Tests/ClusterKeyTests.cs | 2 +- tests/MongoDB.Driver.Tests/ClusterTests.cs | 4 +- .../Security/AwsAuthenticationTests.cs | 6 +- .../Security/GssapiAuthenticationTests.cs | 8 +- .../Security/PlainAuthenticationTests.cs | 8 +- .../ConnectionsSurvivePrimaryStepDownTests.cs | 8 +- .../CreateManyIndexOptionsTest.cs | 2 +- .../CreateOneIndexOptionsTest.cs | 2 +- .../CreateViewOptionsTests.cs | 2 +- .../DecryptedSecureStringTests.cs | 2 +- .../DropIndexOptionsTest.cs | 2 +- .../Encryption/AutoEncryptionOptionsTests.cs | 2 +- .../Encryption/AutoEncryptionTests.cs | 8 +- .../Encryption/ClientEncryptionTests.cs | 20 +- .../EstimatedDocumentCountOptionsTests.cs | 2 +- .../FilterDefinitionBuilderTests.cs | 34 ++-- tests/MongoDB.Driver.Tests/FindFluentTests.cs | 2 +- .../IAggregateFluentExtensionsTests.cs | 6 +- .../IFindFluentExtensionsTests.cs | 2 +- .../IMongoClientExtensionsTests.cs | 2 +- .../IMongoCollectionExtensionsTests.cs | 2 +- .../IMongoDatabaseExtensionsTests.cs | 2 +- .../Jira/CSharp2564Tests.cs | 2 +- .../Jira/CSharp3188Tests.cs | 4 +- .../Jira/CSharp3915Tests.cs | 12 +- .../JsonDrivenTests/JsonDrivenTestFactory.cs | 1 + .../AggregateQueryableExecutionModelTests.cs | 2 +- .../MongoQueryProviderImplTests.cs | 2 +- .../MongoQueryableTests.cs | 64 +++---- .../AggregateGroupTranslatorTests.cs | 8 +- .../AggregateProjectTranslatorTests.cs | 180 +++++++++--------- .../Translators/PredicateTranslatorTests.cs | 12 +- .../MongoQueryableTests.cs | 64 +++---- .../AggregateGroupTranslatorTests.cs | 8 +- .../AggregateProjectTranslatorTests.cs | 180 +++++++++--------- .../Translators/PredicateTranslatorTests.cs | 12 +- .../Jira/CSharp2422Tests.cs | 2 +- .../Jira/CSharp2471Tests.cs | 4 +- .../Jira/CSharp2472Tests.cs | 2 +- .../Jira/CSharp2727Tests.cs | 4 +- .../Jira/CSharp3136Tests.cs | 12 +- .../Jira/CSharp3933Tests.cs | 2 +- .../Jira/CSharp4079Tests.cs | 2 +- .../Jira/CSharp4220Tests.cs | 2 +- .../Jira/CSharp4234Tests.cs | 2 +- .../Jira/CSharp4244Tests.cs | 2 +- .../ListDatabasesTests.cs | 4 +- .../MongoClientSettingsTests.cs | 4 +- .../MongoDB.Driver.Tests/MongoClientTests.cs | 2 +- .../MongoCollectionImplTests.cs | 4 +- tests/MongoDB.Driver.Tests/MongoDBRefTests.cs | 2 +- .../MongoDatabaseImplTests.cs | 4 +- .../MongoIndexManagerTests.cs | 2 +- .../MongoUrlBuilderTests.cs | 2 +- tests/MongoDB.Driver.Tests/MongoUrlTests.cs | 2 +- .../MongocryptdFactoryTests.cs | 2 +- .../OcspIntegrationTests.cs | 4 +- .../OfTypeMongoCollectionTests.cs | 4 +- .../PasswordEvidenceTests.cs | 2 +- .../PinnedShardRouterTests.cs | 6 +- .../PipelineDefinitionBuilderTests.cs | 2 +- .../PipelineStageDefinitionBuilderTests.cs | 14 +- .../Properties/AssemblyInfo.cs | 4 +- .../ReadPreferenceOnStandaloneTests.cs | 2 +- .../RetryableWritesTests.cs | 20 +- .../MongoClientJsonDrivenTestRunnerBase.cs | 3 +- .../AtlasDataLakeTestRunner.cs | 4 +- .../prose-tests/AtlasDataLakeProseTests.cs | 10 +- .../Specifications/auth/AuthTestRunner.cs | 4 +- .../bson-corpus/BsonCorpusTestRunner.cs | 2 +- .../ChangeStreamUnifiedTestRunner.cs | 2 +- .../ClientSideEncryptionTestRunner.cs | 4 +- .../ClientSideEncryptionUnifiedTestRunner.cs | 4 +- .../prose-tests/ClientEncryptionProseTests.cs | 36 ++-- .../CollectionManagementUnifiedTestRunner.cs | 2 +- .../CommandLoggingUnifiedTestRunner.cs | 2 +- .../CommandMonitoringTestRunner.cs | 3 +- .../CommandMonitoringUnifiedTestRunner.cs | 2 +- .../CmapUnifiedTestRunner.cs | 2 +- ...onnectionMonitoringAndPoolingTestRunner.cs | 2 +- .../ConnectionStringTestRunner.cs | 5 +- .../Specifications/crud/CrudTestRunner.cs | 3 +- .../crud/CrudUnifiedTestRunner.cs | 2 +- .../crud/prose-tests/CrudProseTests.cs | 4 +- .../InitialDnsSeedlistDiscoveryTestRunner.cs | 2 +- .../load-balancers/LoadBalancersTestRunner.cs | 4 +- .../ConnectionStringTestRunner.cs | 2 +- .../read-write-concern/DocumentTestRunner.cs | 2 +- .../read-write-concern/OperationTestRunner.cs | 2 +- .../RetryableReadsProseTests.cs | 4 +- .../RetryableReadsTestRunner.cs | 3 +- .../RetryableReadsUnifiedTestRunner.cs | 2 +- .../RetryableWriteTestRunner.cs | 3 +- .../RetryableWritesUnifiedTestRunner.cs | 2 +- .../prose-tests/CommandConstructionTests.cs | 14 +- .../prose-tests/MMapV1Tests.cs | 4 +- .../prose-tests/PoolClearRetryability.cs | 4 +- .../MonitoringTestRunner.cs | 2 +- ...overyAndMonitoringIntegrationTestRunner.cs | 2 +- .../ServerDiscoveryAndMonitoringProseTests.cs | 8 +- .../prose-tests/ServerDiscoveryProseTests.cs | 4 +- .../sessions/SessionsProseTests.cs | 8 +- .../sessions/SessionsTestRunner.cs | 2 +- .../sessions/SessionsUnifiedTestRunner.cs | 2 +- .../TransactionsConvenientApiTestRunner.cs | 2 +- .../transactions/TransactionTestRunner.cs | 3 +- .../TransactionUnifiedTestRunner.cs | 2 +- .../UnifiedTestFormatValidFailTestRunner.cs | 4 +- .../UnifiedTestFormatValidPassTestRunner.cs | 4 +- .../VersionedApiUnifiedTestRunner.cs | 2 +- .../Matchers/UnifiedErrorMatcher.cs | 2 +- .../Matchers/UnifiedEventMatcher.cs | 2 +- .../Matchers/UnifiedValueMatcher.cs | 2 +- .../UnifiedLoopOperation.cs | 2 +- .../UnifiedTestRunner.cs | 4 +- .../UpdateDefinitionBuilderTests.cs | 2 +- .../MongoDB.TestHelpers.csproj | 15 ++ .../Properties/AssemblyInfo.cs | 18 ++ .../XunitExtensions/AssertionException.cs | 4 +- .../XunitExtensions/ClassValuesAttribute.cs | 4 +- .../XunitExtensions/IValueGenerator.cs | 4 +- .../IValueGeneratorAttribute.cs | 4 +- .../ParameterAttributeDataAttribute.cs | 4 +- .../XunitExtensions/RandomSeedAttribute.cs | 5 +- .../XunitExtensions/RangeAttribute.cs | 4 +- .../XunitExtensions/RequireEnvironment.cs | 6 +- .../XunitExtensions/RequireProcess.cs | 6 +- .../TimeoutEnforcing/ITestExceptionHandler.cs | 24 +++ .../SkippableTestMessageBus.cs | 61 ++++++ .../TimeoutEnforcingTestInvoker.cs | 48 ++++- .../TimeoutEnforcingTestRunner.cs | 4 +- ...TimeoutEnforcingXunitTestAssemblyRunner.cs | 4 +- .../TimeoutEnforcingXunitTestCaseRunner.cs | 4 +- .../TimeoutEnforcingXunitTestClassRunner.cs | 4 +- ...meoutEnforcingXunitTestCollectionRunner.cs | 4 +- .../TimeoutEnforcingXunitTestFramework.cs | 4 +- ...eoutEnforcingXunitTestFrameworkExecutor.cs | 4 +- .../TimeoutEnforcingXunitTestMethodRunner.cs | 9 +- ...meoutEnforcingXunitTheoryTestCaseRunner.cs | 4 +- .../XunitExtensions/ValuesAttribute.cs | 4 +- .../XunitExtensionsConstants.cs | 27 +++ tests/SkippableTests/FactTests.cs | 21 -- tests/SkippableTests/SkippableFactTests.cs | 27 --- tests/SkippableTests/SkippableTests.csproj | 27 --- tests/SkippableTests/SkippableTheoryTests.cs | 33 ---- tests/SkippableTests/TheoryTests.cs | 23 --- tests/SkippableTests/xunit.runner.json | 5 - .../MongoDB.Driver.SmokeTests.Sdk.csproj | 2 +- 389 files changed, 1500 insertions(+), 1469 deletions(-) delete mode 100644 tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/XunitExtensionsConsts.cs create mode 100644 tests/MongoDB.TestHelpers/MongoDB.TestHelpers.csproj create mode 100644 tests/MongoDB.TestHelpers/Properties/AssemblyInfo.cs rename tests/{MongoDB.Bson.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/AssertionException.cs (90%) rename tests/{MongoDB.Bson.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/ClassValuesAttribute.cs (93%) rename tests/{MongoDB.Bson.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/IValueGenerator.cs (87%) rename tests/{MongoDB.Bson.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/IValueGeneratorAttribute.cs (87%) rename tests/{MongoDB.Bson.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/ParameterAttributeDataAttribute.cs (96%) rename tests/{MongoDB.Bson.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/RandomSeedAttribute.cs (92%) rename tests/{MongoDB.Bson.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/RangeAttribute.cs (94%) rename tests/{MongoDB.Bson.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/RequireEnvironment.cs (95%) rename tests/{MongoDB.Bson.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/RequireProcess.cs (91%) create mode 100644 tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/ITestExceptionHandler.cs create mode 100644 tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/SkippableTestMessageBus.cs rename tests/{MongoDB.Driver.Core.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestInvoker.cs (59%) rename tests/{MongoDB.Driver.Core.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestRunner.cs (93%) rename tests/{MongoDB.Driver.Core.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestAssemblyRunner.cs (93%) rename tests/{MongoDB.Driver.Core.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCaseRunner.cs (94%) rename tests/{MongoDB.Driver.Core.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestClassRunner.cs (93%) rename tests/{MongoDB.Driver.Core.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCollectionRunner.cs (93%) rename tests/{MongoDB.Driver.Core.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFramework.cs (90%) rename tests/{MongoDB.Driver.Core.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFrameworkExecutor.cs (92%) rename tests/{MongoDB.Driver.Core.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestMethodRunner.cs (90%) rename tests/{MongoDB.Driver.Core.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTheoryTestCaseRunner.cs (94%) rename tests/{MongoDB.Bson.TestHelpers => MongoDB.TestHelpers}/XunitExtensions/ValuesAttribute.cs (91%) create mode 100644 tests/MongoDB.TestHelpers/XunitExtensions/XunitExtensionsConstants.cs delete mode 100644 tests/SkippableTests/FactTests.cs delete mode 100644 tests/SkippableTests/SkippableFactTests.cs delete mode 100644 tests/SkippableTests/SkippableTests.csproj delete mode 100644 tests/SkippableTests/SkippableTheoryTests.cs delete mode 100644 tests/SkippableTests/TheoryTests.cs delete mode 100644 tests/SkippableTests/xunit.runner.json diff --git a/CSharpDriver.sln b/CSharpDriver.sln index 7f3ad59846c..e3d1b1323cf 100644 --- a/CSharpDriver.sln +++ b/CSharpDriver.sln @@ -10,7 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D2012971-32B EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{E472BDF5-61F1-461D-872B-9F53BB3ACA80}" ProjectSection(SolutionItems) = preProject - tests\Directory.Build.props = tests\Directory.Build.props + tests\BuildProps\Tests.Build.props = tests\BuildProps\Tests.Build.props EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoDB.Bson", "src\MongoDB.Bson\MongoDB.Bson.csproj", "{9FCB42A5-3BC6-492B-8EA0-53EF32E9F8CD}" @@ -54,8 +54,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution MongoDBTest.ruleset = MongoDBTest.ruleset EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkippableTests", "tests\SkippableTests\SkippableTests.csproj", "{D198833A-6AC3-4327-8B02-5095455192D0}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoDB.Driver.TestConsoleApplication", "tests\MongoDB.Driver.TestConsoleApplication\MongoDB.Driver.TestConsoleApplication.csproj", "{2E5780D2-29A5-483C-9CA2-844F45A66D0C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AstrolabeWorkloadExecutor", "tests\AstrolabeWorkloadExecutor\AstrolabeWorkloadExecutor.csproj", "{B90F025F-89D3-436A-AD78-6AA304A6E240}" @@ -64,6 +62,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoDB.Driver.SmokeTests.S EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SmokeTests", "SmokeTests", "{F64BF86A-1EF1-4596-84A6-6B4AB766CD77}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoDB.TestHelpers", "tests\MongoDB.TestHelpers\MongoDB.TestHelpers.csproj", "{DF888021-744F-4A8B-9324-831DEFC48AB8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -134,10 +134,6 @@ Global {7A015030-6329-4FAD-B6E3-CED5ED53019C}.Debug|Any CPU.Build.0 = Debug|Any CPU {7A015030-6329-4FAD-B6E3-CED5ED53019C}.Release|Any CPU.ActiveCfg = Release|Any CPU {7A015030-6329-4FAD-B6E3-CED5ED53019C}.Release|Any CPU.Build.0 = Release|Any CPU - {D198833A-6AC3-4327-8B02-5095455192D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D198833A-6AC3-4327-8B02-5095455192D0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D198833A-6AC3-4327-8B02-5095455192D0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D198833A-6AC3-4327-8B02-5095455192D0}.Release|Any CPU.Build.0 = Release|Any CPU {2E5780D2-29A5-483C-9CA2-844F45A66D0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E5780D2-29A5-483C-9CA2-844F45A66D0C}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E5780D2-29A5-483C-9CA2-844F45A66D0C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -150,6 +146,10 @@ Global {B711A69F-A337-452C-95E1-A6B15C727CBA}.Debug|Any CPU.Build.0 = Debug|Any CPU {B711A69F-A337-452C-95E1-A6B15C727CBA}.Release|Any CPU.ActiveCfg = Release|Any CPU {B711A69F-A337-452C-95E1-A6B15C727CBA}.Release|Any CPU.Build.0 = Release|Any CPU + {DF888021-744F-4A8B-9324-831DEFC48AB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF888021-744F-4A8B-9324-831DEFC48AB8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF888021-744F-4A8B-9324-831DEFC48AB8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF888021-744F-4A8B-9324-831DEFC48AB8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -171,11 +171,11 @@ Global {C50D554C-2771-4CC1-9B2C-BB17FB27F935} = {E472BDF5-61F1-461D-872B-9F53BB3ACA80} {DAB8DFFD-0020-43B3-9C08-7723F5D68E90} = {E472BDF5-61F1-461D-872B-9F53BB3ACA80} {7A015030-6329-4FAD-B6E3-CED5ED53019C} = {E472BDF5-61F1-461D-872B-9F53BB3ACA80} - {D198833A-6AC3-4327-8B02-5095455192D0} = {E472BDF5-61F1-461D-872B-9F53BB3ACA80} {2E5780D2-29A5-483C-9CA2-844F45A66D0C} = {E472BDF5-61F1-461D-872B-9F53BB3ACA80} {B90F025F-89D3-436A-AD78-6AA304A6E240} = {E472BDF5-61F1-461D-872B-9F53BB3ACA80} {B711A69F-A337-452C-95E1-A6B15C727CBA} = {F64BF86A-1EF1-4596-84A6-6B4AB766CD77} {F64BF86A-1EF1-4596-84A6-6B4AB766CD77} = {E472BDF5-61F1-461D-872B-9F53BB3ACA80} + {DF888021-744F-4A8B-9324-831DEFC48AB8} = {E472BDF5-61F1-461D-872B-9F53BB3ACA80} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {24BEC44B-92B0-43AA-9B15-163459D0C098} diff --git a/tests/BuildProps/Tests.Build.props b/tests/BuildProps/Tests.Build.props index e1e65742b58..ca5a8480127 100644 --- a/tests/BuildProps/Tests.Build.props +++ b/tests/BuildProps/Tests.Build.props @@ -12,7 +12,7 @@ $(StandardTargetFrameworks);net472 false - + 10 true @@ -40,13 +40,11 @@ $(DefineConstants);MACOS - - - + diff --git a/tests/MongoDB.Bson.TestHelpers/GuidModeValues.cs b/tests/MongoDB.Bson.TestHelpers/GuidModeValues.cs index 1dd17246ef2..78692150aee 100644 --- a/tests/MongoDB.Bson.TestHelpers/GuidModeValues.cs +++ b/tests/MongoDB.Bson.TestHelpers/GuidModeValues.cs @@ -13,8 +13,8 @@ * limitations under the License. */ -using MongoDB.Bson.TestHelpers.XunitExtensions; using System.Linq; +using MongoDB.TestHelpers.XunitExtensions; namespace MongoDB.Bson.TestHelpers { diff --git a/tests/MongoDB.Bson.TestHelpers/MongoDB.Bson.TestHelpers.csproj b/tests/MongoDB.Bson.TestHelpers/MongoDB.Bson.TestHelpers.csproj index c7e737d0b8b..868cf275e19 100644 --- a/tests/MongoDB.Bson.TestHelpers/MongoDB.Bson.TestHelpers.csproj +++ b/tests/MongoDB.Bson.TestHelpers/MongoDB.Bson.TestHelpers.csproj @@ -18,6 +18,7 @@ + diff --git a/tests/MongoDB.Bson.Tests/IO/ArrayElementNameAcceleratorTests.cs b/tests/MongoDB.Bson.Tests/IO/ArrayElementNameAcceleratorTests.cs index d3e3fb15652..90458f44a1f 100644 --- a/tests/MongoDB.Bson.Tests/IO/ArrayElementNameAcceleratorTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/ArrayElementNameAcceleratorTests.cs @@ -15,7 +15,7 @@ using System; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO diff --git a/tests/MongoDB.Bson.Tests/IO/BsonBinaryReaderTests.cs b/tests/MongoDB.Bson.Tests/IO/BsonBinaryReaderTests.cs index 4adc967349e..1dcec7b925c 100644 --- a/tests/MongoDB.Bson.Tests/IO/BsonBinaryReaderTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/BsonBinaryReaderTests.cs @@ -21,14 +21,14 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO { public class BsonBinaryReaderTests { - [SkippableFact] + [Fact] public void BsonBinaryReader_should_support_reading_more_than_2GB() { RequireEnvironment.Check().EnvironmentVariable("EXPLICIT"); diff --git a/tests/MongoDB.Bson.Tests/IO/BsonBinaryWriterTests.cs b/tests/MongoDB.Bson.Tests/IO/BsonBinaryWriterTests.cs index ed569cc5d45..82203c21fde 100644 --- a/tests/MongoDB.Bson.Tests/IO/BsonBinaryWriterTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/BsonBinaryWriterTests.cs @@ -18,9 +18,8 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers; using MongoDB.Bson.TestHelpers.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO @@ -53,7 +52,7 @@ public class BsonBinaryWriterTests } } - [SkippableFact] + [Fact] public void BsonBinaryWriter_should_support_writing_more_than_2GB() { RequireProcess.Check().Bits(64); @@ -78,7 +77,7 @@ public void BsonBinaryWriter_should_support_writing_more_than_2GB() } } - [SkippableFact] + [Fact] public void BackpatchSize_should_throw_when_size_is_larger_than_2GB() { RequireProcess.Check().Bits(64); diff --git a/tests/MongoDB.Bson.Tests/IO/BsonChunkPoolTests.cs b/tests/MongoDB.Bson.Tests/IO/BsonChunkPoolTests.cs index 2defe775b33..bfe39a7d557 100644 --- a/tests/MongoDB.Bson.Tests/IO/BsonChunkPoolTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/BsonChunkPoolTests.cs @@ -21,7 +21,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO diff --git a/tests/MongoDB.Bson.Tests/IO/BsonDocumentReaderTests.cs b/tests/MongoDB.Bson.Tests/IO/BsonDocumentReaderTests.cs index 07bef0a3fbf..7dca4f29c63 100644 --- a/tests/MongoDB.Bson.Tests/IO/BsonDocumentReaderTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/BsonDocumentReaderTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO diff --git a/tests/MongoDB.Bson.Tests/IO/BsonStreamAdapterTests.cs b/tests/MongoDB.Bson.Tests/IO/BsonStreamAdapterTests.cs index 34dcfeabfb2..0f752c6f5b6 100644 --- a/tests/MongoDB.Bson.Tests/IO/BsonStreamAdapterTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/BsonStreamAdapterTests.cs @@ -21,7 +21,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Bson.Tests/IO/BsonStreamExtensionsTests.cs b/tests/MongoDB.Bson.Tests/IO/BsonStreamExtensionsTests.cs index dcf6d272f4f..1a17564d5c2 100644 --- a/tests/MongoDB.Bson.Tests/IO/BsonStreamExtensionsTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/BsonStreamExtensionsTests.cs @@ -19,7 +19,7 @@ using System.Reflection; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Bson.Tests/IO/BsonWriterTests.cs b/tests/MongoDB.Bson.Tests/IO/BsonWriterTests.cs index 3f2f149394f..643f7321f6b 100644 --- a/tests/MongoDB.Bson.Tests/IO/BsonWriterTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/BsonWriterTests.cs @@ -18,7 +18,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Bson.Tests/IO/ByteArrayBufferTests.cs b/tests/MongoDB.Bson.Tests/IO/ByteArrayBufferTests.cs index bc81535a860..af5208910e4 100644 --- a/tests/MongoDB.Bson.Tests/IO/ByteArrayBufferTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/ByteArrayBufferTests.cs @@ -18,7 +18,7 @@ using System.Reflection; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO diff --git a/tests/MongoDB.Bson.Tests/IO/ByteArrayChunkTests.cs b/tests/MongoDB.Bson.Tests/IO/ByteArrayChunkTests.cs index 9160aa48120..4e45b31c18e 100644 --- a/tests/MongoDB.Bson.Tests/IO/ByteArrayChunkTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/ByteArrayChunkTests.cs @@ -17,7 +17,7 @@ using System.Reflection; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO diff --git a/tests/MongoDB.Bson.Tests/IO/ByteBufferFactoryTests.cs b/tests/MongoDB.Bson.Tests/IO/ByteBufferFactoryTests.cs index dca061b1663..7af07ae9267 100644 --- a/tests/MongoDB.Bson.Tests/IO/ByteBufferFactoryTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/ByteBufferFactoryTests.cs @@ -20,7 +20,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Bson.Tests/IO/ByteBufferSliceTests.cs b/tests/MongoDB.Bson.Tests/IO/ByteBufferSliceTests.cs index 308ae40d1af..d0d42b6c608 100644 --- a/tests/MongoDB.Bson.Tests/IO/ByteBufferSliceTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/ByteBufferSliceTests.cs @@ -21,7 +21,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Bson.Tests/IO/ByteBufferStreamTests.cs b/tests/MongoDB.Bson.Tests/IO/ByteBufferStreamTests.cs index 4acadc1173f..b9d2e1d61b0 100644 --- a/tests/MongoDB.Bson.Tests/IO/ByteBufferStreamTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/ByteBufferStreamTests.cs @@ -20,7 +20,7 @@ using System.Reflection; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; @@ -272,7 +272,7 @@ public void Position_set_should_throw_when_subject_is_disposed() action.ShouldThrow().And.ObjectName.Should().Be("ByteBufferStream"); } - [SkippableFact] + [Fact] public void PrepareToWrite_should_throw_when_stream_would_exceed_2GB() { RequireProcess.Check().Bits(64); diff --git a/tests/MongoDB.Bson.Tests/IO/CStringUtf8EncodingTests.cs b/tests/MongoDB.Bson.Tests/IO/CStringUtf8EncodingTests.cs index 1c984cb3a8b..c0c95d9046b 100644 --- a/tests/MongoDB.Bson.Tests/IO/CStringUtf8EncodingTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/CStringUtf8EncodingTests.cs @@ -18,7 +18,7 @@ using FluentAssertions; using MongoDB.Bson.IO; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO diff --git a/tests/MongoDB.Bson.Tests/IO/EncodingHelperTests.cs b/tests/MongoDB.Bson.Tests/IO/EncodingHelperTests.cs index 93996067d63..45eb62034c8 100644 --- a/tests/MongoDB.Bson.Tests/IO/EncodingHelperTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/EncodingHelperTests.cs @@ -19,7 +19,7 @@ using FluentAssertions; using MongoDB.Bson.IO; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO diff --git a/tests/MongoDB.Bson.Tests/IO/InputBufferChunkSourceTests.cs b/tests/MongoDB.Bson.Tests/IO/InputBufferChunkSourceTests.cs index fd1e1d4362a..1d9db95f058 100644 --- a/tests/MongoDB.Bson.Tests/IO/InputBufferChunkSourceTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/InputBufferChunkSourceTests.cs @@ -17,7 +17,7 @@ using System.Reflection; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Bson.Tests/IO/JsonReaderTests.cs b/tests/MongoDB.Bson.Tests/IO/JsonReaderTests.cs index 50ec4fbf87a..76c31fa01cd 100644 --- a/tests/MongoDB.Bson.Tests/IO/JsonReaderTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/JsonReaderTests.cs @@ -22,7 +22,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO diff --git a/tests/MongoDB.Bson.Tests/IO/JsonWriterTests.cs b/tests/MongoDB.Bson.Tests/IO/JsonWriterTests.cs index e0b5337f8bd..b40c21b84b2 100644 --- a/tests/MongoDB.Bson.Tests/IO/JsonWriterTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/JsonWriterTests.cs @@ -22,7 +22,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO @@ -213,7 +213,7 @@ public void TestDouble() } } - [SkippableFact] + [Fact] public void TestDoubleRoundTripOn64BitProcess() { RequireProcess.Check().Bits(64); diff --git a/tests/MongoDB.Bson.Tests/IO/MultiChunkBufferTests.cs b/tests/MongoDB.Bson.Tests/IO/MultiChunkBufferTests.cs index 0f1e0569f73..e28e95acf32 100644 --- a/tests/MongoDB.Bson.Tests/IO/MultiChunkBufferTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/MultiChunkBufferTests.cs @@ -20,7 +20,7 @@ using FluentAssertions; using MongoDB.Bson.IO; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; @@ -432,7 +432,7 @@ public void EnsureCapacity_should_throw_when_subject_is_read_only() action.ShouldThrow(); } - [SkippableFact] + [Fact] public void ExpandCapacity_should_throw_when_expanded_capacity_exceeds_2GB() { RequireProcess.Check().Bits(64); diff --git a/tests/MongoDB.Bson.Tests/IO/OutputBufferChunkSourceTests.cs b/tests/MongoDB.Bson.Tests/IO/OutputBufferChunkSourceTests.cs index f96e1df5fde..843f7ec6201 100644 --- a/tests/MongoDB.Bson.Tests/IO/OutputBufferChunkSourceTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/OutputBufferChunkSourceTests.cs @@ -21,7 +21,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Bson.Tests/IO/SingleChunkBufferTests.cs b/tests/MongoDB.Bson.Tests/IO/SingleChunkBufferTests.cs index 322feb46fff..5c9ef93fd0a 100644 --- a/tests/MongoDB.Bson.Tests/IO/SingleChunkBufferTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/SingleChunkBufferTests.cs @@ -21,7 +21,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Bson.Tests/IO/ThreadStaticBufferTests.cs b/tests/MongoDB.Bson.Tests/IO/ThreadStaticBufferTests.cs index 1d16372e099..38f6bd2dbf7 100644 --- a/tests/MongoDB.Bson.Tests/IO/ThreadStaticBufferTests.cs +++ b/tests/MongoDB.Bson.Tests/IO/ThreadStaticBufferTests.cs @@ -20,7 +20,7 @@ using FluentAssertions; using MongoDB.Bson.IO; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.IO diff --git a/tests/MongoDB.Bson.Tests/Jira/CSharp147Tests.cs b/tests/MongoDB.Bson.Tests/Jira/CSharp147Tests.cs index 690dd80cb71..87274e4bdbb 100644 --- a/tests/MongoDB.Bson.Tests/Jira/CSharp147Tests.cs +++ b/tests/MongoDB.Bson.Tests/Jira/CSharp147Tests.cs @@ -18,7 +18,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Jira.CSharp147 diff --git a/tests/MongoDB.Bson.Tests/Jira/CSharp275Tests.cs b/tests/MongoDB.Bson.Tests/Jira/CSharp275Tests.cs index 1b371e85314..64566845177 100644 --- a/tests/MongoDB.Bson.Tests/Jira/CSharp275Tests.cs +++ b/tests/MongoDB.Bson.Tests/Jira/CSharp275Tests.cs @@ -15,7 +15,7 @@ using System; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Jira diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/BsonArrayTests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/BsonArrayTests.cs index 73e3aaab53f..206687cb210 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/BsonArrayTests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/BsonArrayTests.cs @@ -17,6 +17,7 @@ using System.Linq; using MongoDB.Bson; using Xunit; +using Xunit.Sdk; namespace MongoDB.Bson.Tests { diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/BsonBinaryDataTests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/BsonBinaryDataTests.cs index 62f28d71991..8e73f9c1039 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/BsonBinaryDataTests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/BsonBinaryDataTests.cs @@ -17,7 +17,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/BsonBooleanTests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/BsonBooleanTests.cs index a760bdd1036..c7bf1a680c1 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/BsonBooleanTests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/BsonBooleanTests.cs @@ -19,7 +19,7 @@ using System.Text; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.ObjectModel diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/BsonDocumentTests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/BsonDocumentTests.cs index 5469025d738..9489c93a7e6 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/BsonDocumentTests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/BsonDocumentTests.cs @@ -25,7 +25,7 @@ using MongoDB.Bson.Serialization.IdGenerators; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/BsonDoubleTests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/BsonDoubleTests.cs index 067468a8364..da4f828f528 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/BsonDoubleTests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/BsonDoubleTests.cs @@ -14,12 +14,8 @@ */ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.ObjectModel diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/BsonInt32Tests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/BsonInt32Tests.cs index cc2c7f17c5a..269daef31f3 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/BsonInt32Tests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/BsonInt32Tests.cs @@ -14,12 +14,8 @@ */ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.ObjectModel diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/BsonInt64Tests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/BsonInt64Tests.cs index c7ad86422c9..5f13a6294af 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/BsonInt64Tests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/BsonInt64Tests.cs @@ -14,12 +14,8 @@ */ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.ObjectModel diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/BsonStringTests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/BsonStringTests.cs index 5fc230732bf..c21faa2de10 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/BsonStringTests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/BsonStringTests.cs @@ -19,7 +19,7 @@ using System.Text; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.ObjectModel diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/BsonTypeMapperTests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/BsonTypeMapperTests.cs index f6d9d66a081..bc9d3711efe 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/BsonTypeMapperTests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/BsonTypeMapperTests.cs @@ -18,7 +18,7 @@ using System.Text.RegularExpressions; using FluentAssertions; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/BsonValueTests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/BsonValueTests.cs index eb7b347a093..43788b12a7e 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/BsonValueTests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/BsonValueTests.cs @@ -18,7 +18,7 @@ using System.Text.RegularExpressions; using FluentAssertions; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/LazyBsonDocumentTests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/LazyBsonDocumentTests.cs index 97a2b08b257..9d81840ae3b 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/LazyBsonDocumentTests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/LazyBsonDocumentTests.cs @@ -19,7 +19,7 @@ using System.Linq; using MongoDB.Bson; using MongoDB.Bson.Serialization; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests @@ -853,7 +853,7 @@ public void TestValues() } } - [SkippableFact] + [Fact] public void TestLargeDocumentDeserialization() { RequireProcess.Check().Bits(64); diff --git a/tests/MongoDB.Bson.Tests/ObjectModel/RawBsonArrayTests.cs b/tests/MongoDB.Bson.Tests/ObjectModel/RawBsonArrayTests.cs index 67b5714b7c2..b748bd57cf5 100644 --- a/tests/MongoDB.Bson.Tests/ObjectModel/RawBsonArrayTests.cs +++ b/tests/MongoDB.Bson.Tests/ObjectModel/RawBsonArrayTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson; using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests diff --git a/tests/MongoDB.Bson.Tests/PowerOf2Tests.cs b/tests/MongoDB.Bson.Tests/PowerOf2Tests.cs index 55992fbec77..1c8fa00a027 100644 --- a/tests/MongoDB.Bson.Tests/PowerOf2Tests.cs +++ b/tests/MongoDB.Bson.Tests/PowerOf2Tests.cs @@ -19,7 +19,7 @@ using System.Text; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests diff --git a/tests/MongoDB.Bson.Tests/Properties/AssemblyInfo.cs b/tests/MongoDB.Bson.Tests/Properties/AssemblyInfo.cs index cc39fd111c9..de81526bc77 100644 --- a/tests/MongoDB.Bson.Tests/Properties/AssemblyInfo.cs +++ b/tests/MongoDB.Bson.Tests/Properties/AssemblyInfo.cs @@ -14,5 +14,9 @@ */ using System.Runtime.InteropServices; +using MongoDB.TestHelpers.XunitExtensions; +using Xunit; [assembly: ComVisible(false)] + +[assembly: TestFramework(XunitExtensionsConstants.TimeoutEnforcingXunitFramework, XunitExtensionsConstants.TimeoutEnforcingFrameworkAssembly)] diff --git a/tests/MongoDB.Bson.Tests/Serialization/Conventions/ConventionRunnerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Conventions/ConventionRunnerTests.cs index 913b74e2555..f86afe3836a 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Conventions/ConventionRunnerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Conventions/ConventionRunnerTests.cs @@ -18,7 +18,7 @@ using System.Threading; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Conventions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization.Conventions diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonBinaryDataSerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonBinaryDataSerializerTests.cs index 1bc319213ba..e970e7e3c33 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonBinaryDataSerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonBinaryDataSerializerTests.cs @@ -18,7 +18,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonPrimitiveSerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonPrimitiveSerializerTests.cs index c2a6ff4a22f..75c18bfbf9d 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonPrimitiveSerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonPrimitiveSerializerTests.cs @@ -21,7 +21,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization.Serializers diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonValueSerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonValueSerializerTests.cs index 3e8fafcd97a..1278d851aa6 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonValueSerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/BsonValueSerializerTests.cs @@ -23,7 +23,7 @@ using MongoDB.Bson.Serialization.IdGenerators; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/CollectionSerializerGenericTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/CollectionSerializerGenericTests.cs index 42d1cacc9f0..ff17df7b79f 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/CollectionSerializerGenericTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/CollectionSerializerGenericTests.cs @@ -21,7 +21,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization.CollectionSerializersGeneric diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/CollectionSerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/CollectionSerializerTests.cs index 4e0dd270cc1..ab5a2a99954 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/CollectionSerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/CollectionSerializerTests.cs @@ -21,7 +21,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization.CollectionSerializers diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/DateTimeOffsetSerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/DateTimeOffsetSerializerTests.cs index 5da703412a8..ac91c84c25b 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/DateTimeOffsetSerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/DateTimeOffsetSerializerTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization.Serializers diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/DictionaryGenericSerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/DictionaryGenericSerializerTests.cs index 191fa8484a3..e7646e5a181 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/DictionaryGenericSerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/DictionaryGenericSerializerTests.cs @@ -23,7 +23,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization.DictionaryGenericSerializers diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/DictionarySerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/DictionarySerializerTests.cs index 877d14fbed6..5f8a493abc4 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/DictionarySerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/DictionarySerializerTests.cs @@ -24,7 +24,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization.DictionarySerializers diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/ElementAppendingSerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/ElementAppendingSerializerTests.cs index 7314e09713f..d99e1422699 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/ElementAppendingSerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/ElementAppendingSerializerTests.cs @@ -22,8 +22,8 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Bson.Tests.IO; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/EnumSerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/EnumSerializerTests.cs index 870837ad841..e18902601bf 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/EnumSerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/EnumSerializerTests.cs @@ -20,7 +20,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization.Serializers diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsTests.cs index 4dccbae5319..2b299ba3ae2 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsTests.cs @@ -20,7 +20,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsWithImmutableClassTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsWithImmutableClassTests.cs index 5ba59182f00..6b039feb85c 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsWithImmutableClassTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsWithImmutableClassTests.cs @@ -20,7 +20,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsWithPartiallyImmutableClassTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsWithPartiallyImmutableClassTests.cs index eb85b68e6d3..bf24e6df7e4 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsWithPartiallyImmutableClassTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/ExtraElementsWithPartiallyImmutableClassTests.cs @@ -20,7 +20,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/GuidSerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/GuidSerializerTests.cs index 6fe7536bc53..c90a0ab3ddb 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/GuidSerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/GuidSerializerTests.cs @@ -21,7 +21,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization.Serializers diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/NullableTypeSerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/NullableTypeSerializerTests.cs index 3ee1b8c4d26..5e6317fc67e 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/NullableTypeSerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/NullableTypeSerializerTests.cs @@ -21,7 +21,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Bson.Tests.Serialization diff --git a/tests/MongoDB.Bson.Tests/Serialization/Serializers/ObjectSerializerTests.cs b/tests/MongoDB.Bson.Tests/Serialization/Serializers/ObjectSerializerTests.cs index 4dbd44412db..a7da6c543fd 100644 --- a/tests/MongoDB.Bson.Tests/Serialization/Serializers/ObjectSerializerTests.cs +++ b/tests/MongoDB.Bson.Tests/Serialization/Serializers/ObjectSerializerTests.cs @@ -23,9 +23,11 @@ using MongoDB.Bson.Serialization.Conventions; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; +using Xunit.Sdk; +using Reflector = MongoDB.Bson.TestHelpers.Reflector; namespace MongoDB.Bson.Tests.Serialization { @@ -320,7 +322,7 @@ public void constructor_with_discriminator_convention_and_guid_representation_sh e.ParamName.Should().Be("discriminatorConvention"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] [ResetGuidModeAfterTest] public void Deserialize_binary_data_should_return_expected_result_when_guid_representation_is_unspecified_and_mode_is_v2( @@ -462,7 +464,7 @@ public void Deserialize_binary_data_should_throw_when_guid_representation_is_uns #pragma warning restore 618 } - [SkippableTheory] + [Theory] [ParameterAttributeData] [ResetGuidModeAfterTest] public void Serialize_guid_should_have_expected_result_when_guid_representation_is_unspecified_and_mode_is_v2( diff --git a/tests/MongoDB.Driver.Core.TestHelpers/Logging/LoggableTestClass.cs b/tests/MongoDB.Driver.Core.TestHelpers/Logging/LoggableTestClass.cs index 7a8067e9b3b..56ba6b4e1ee 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/Logging/LoggableTestClass.cs +++ b/tests/MongoDB.Driver.Core.TestHelpers/Logging/LoggableTestClass.cs @@ -18,6 +18,7 @@ using System.Linq; using Microsoft.Diagnostics.Runtime; using Microsoft.Extensions.Logging; +using MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing; using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Events; using MongoDB.Driver.Core.Logging; @@ -28,7 +29,7 @@ namespace MongoDB.Driver.Core.TestHelpers.Logging { [DebuggerStepThrough] - public abstract class LoggableTestClass : IDisposable, ILoggingService + public abstract class LoggableTestClass : IDisposable, ILoggingService, ITestExceptionHandler { public LoggableTestClass(ITestOutputHelper output, bool includeAllCategories = false) { @@ -63,28 +64,6 @@ public LoggableTestClass(ITestOutputHelper output, bool includeAllCategories = f protected virtual void DisposeInternal() { } - public void OnException(Exception ex) - { - TestOutput.WriteLine("Formatted exception: {0}", FormatException(ex)); - - if (ex is TestTimeoutException) - { - try - { - LogStackTrace(); - } - catch - { - // fail silently - } - } - - if (MinLogLevel > LogLevel.Debug) - { - MinLogLevel = LogLevel.Debug; - } - } - public void Dispose() { DisposeInternal(); @@ -124,6 +103,28 @@ private string FormatException(Exception exception) return result; } + public void HandleException(Exception ex) + { + TestOutput.WriteLine("Formatted exception: {0}", FormatException(ex)); + + if (ex is TestTimeoutException) + { + try + { + LogStackTrace(); + } + catch + { + // fail silently + } + } + + if (MinLogLevel > LogLevel.Debug) + { + MinLogLevel = LogLevel.Debug; + } + } + private void LogStackTrace() { var pid = Process.GetCurrentProcess().Id; diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/RequirePlatform.cs b/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/RequirePlatform.cs index 12b93101a89..a9cd9082e5f 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/RequirePlatform.cs +++ b/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/RequirePlatform.cs @@ -16,6 +16,7 @@ using System; using System.Linq; using Xunit; +using Xunit.Sdk; namespace MongoDB.Driver.TestHelpers { diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/RequireServer.cs b/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/RequireServer.cs index 86298bcd651..b90c4c25f18 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/RequireServer.cs +++ b/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/RequireServer.cs @@ -19,6 +19,7 @@ using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using Xunit; +using Xunit.Sdk; namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions { diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/XunitExtensionsConsts.cs b/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/XunitExtensionsConsts.cs deleted file mode 100644 index 518dd19a459..00000000000 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/XunitExtensionsConsts.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions -{ - public static class XunitExtensionsConsts - { - public const string TimeoutEnforcingXunitFramework = "MongoDB.Driver.Core.TestHelpers.XunitExtensions.TimeoutEnforcing.TimeoutEnforcingXunitTestFramework"; - public const string TimeoutEnforcingFrameworkAssembly = "MongoDB.Driver.Core.TestHelpers"; - } -} diff --git a/tests/MongoDB.Driver.Core.Tests/BatchTransformingAsyncCursorTests.cs b/tests/MongoDB.Driver.Core.Tests/BatchTransformingAsyncCursorTests.cs index b6118bfb4b0..894b156e2a2 100644 --- a/tests/MongoDB.Driver.Core.Tests/BatchTransformingAsyncCursorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/BatchTransformingAsyncCursorTests.cs @@ -21,7 +21,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver diff --git a/tests/MongoDB.Driver.Core.Tests/CollationTests.cs b/tests/MongoDB.Driver.Core.Tests/CollationTests.cs index 2d8cdc6ea7a..aecade5d9ae 100644 --- a/tests/MongoDB.Driver.Core.Tests/CollationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/CollationTests.cs @@ -21,7 +21,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/AuthenticationHelperTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/AuthenticationHelperTests.cs index 67b9e450cf6..1d5d4ff401e 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/AuthenticationHelperTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/AuthenticationHelperTests.cs @@ -19,7 +19,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Connections; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/CacheableCredentialsProviderTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/CacheableCredentialsProviderTests.cs index e899cdbbae2..2feec20a532 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/CacheableCredentialsProviderTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/CacheableCredentialsProviderTests.cs @@ -18,7 +18,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Authentication.External; using MongoDB.Driver.Core.Misc; using Moq; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/Libgssapi/GssapiSecurityCredentialTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/Libgssapi/GssapiSecurityCredentialTests.cs index a7cc1f0f3a9..85fe729cdce 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/Libgssapi/GssapiSecurityCredentialTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/Libgssapi/GssapiSecurityCredentialTests.cs @@ -15,7 +15,7 @@ using System; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Authentication.Libgssapi; using MongoDB.Driver.Core.Misc; using Xunit; @@ -40,7 +40,7 @@ public GssapiSecurityCredentialTests() } } - [SkippableFact] + [Fact] public void Should_acquire_gssapi_security_credential_with_username_and_password() { RequireEnvironment.Check().EnvironmentVariable("GSSAPI_TESTS_ENABLED"); @@ -50,7 +50,7 @@ public void Should_acquire_gssapi_security_credential_with_username_and_password credential.Should().NotBeNull(); } - [SkippableFact] + [Fact] public void Should_acquire_gssapi_security_credential_with_username_only() { RequireEnvironment.Check().EnvironmentVariable("GSSAPI_TESTS_ENABLED"); @@ -59,7 +59,7 @@ public void Should_acquire_gssapi_security_credential_with_username_only() credential.Should().NotBeNull(); } - [SkippableFact] + [Fact] public void Should_fail_to_acquire_gssapi_security_credential_with_username_and_bad_password() { RequireEnvironment.Check().EnvironmentVariable("GSSAPI_TESTS_ENABLED"); diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoAWSAuthenticatorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoAWSAuthenticatorTests.cs index ff05c2d3e17..bc98cfe7d25 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoAWSAuthenticatorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoAWSAuthenticatorTests.cs @@ -19,7 +19,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Authentication; using MongoDB.Driver.Core.Authentication.External; using MongoDB.Driver.Core.Clusters; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBCRAuthenticatorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBCRAuthenticatorTests.cs index 0f0c22cdd48..123e9ee099f 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBCRAuthenticatorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBCRAuthenticatorTests.cs @@ -18,7 +18,6 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Helpers; @@ -26,6 +25,7 @@ using MongoDB.Driver.Core.Servers; using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.WireProtocol.Messages; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Authentication diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBX509AuthenticatorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBX509AuthenticatorTests.cs index 3dbef36d372..8590e42987c 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBX509AuthenticatorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/MongoDBX509AuthenticatorTests.cs @@ -18,7 +18,6 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Helpers; @@ -26,6 +25,7 @@ using MongoDB.Driver.Core.Servers; using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.WireProtocol.Messages; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Authentication diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/PlainAuthenticatorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/PlainAuthenticatorTests.cs index 680c68ae38d..481ac1e05a5 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/PlainAuthenticatorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/PlainAuthenticatorTests.cs @@ -18,7 +18,6 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Helpers; @@ -26,6 +25,7 @@ using MongoDB.Driver.Core.Servers; using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.WireProtocol.Messages; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Authentication diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/SaslPrepHelperTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/SaslPrepHelperTests.cs index a719fdf2742..d5c9781e8b0 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/SaslPrepHelperTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/SaslPrepHelperTests.cs @@ -15,7 +15,7 @@ using FluentAssertions; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using System; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/ScramSha1AuthenticatorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/ScramSha1AuthenticatorTests.cs index f8205860cb5..0ab870448e6 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/ScramSha1AuthenticatorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/ScramSha1AuthenticatorTests.cs @@ -25,7 +25,7 @@ using MongoDB.Driver.Core.Misc; using Xunit; using MongoDB.Driver.Core.Connections; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using System.Linq; using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.WireProtocol.Messages; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/ScramSha256AuthenticatorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/ScramSha256AuthenticatorTests.cs index b14a14319e6..813da638541 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Authentication/ScramSha256AuthenticatorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Authentication/ScramSha256AuthenticatorTests.cs @@ -27,7 +27,7 @@ using MongoDB.Driver.Core.WireProtocol.Messages; using Xunit; using MongoDB.Driver.Core.Connections; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using System.Linq; using MongoDB.Driver.Core.TestHelpers; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelChannelSourceTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelChannelSourceTests.cs index a3fdc367a5c..76a12582048 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelChannelSourceTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelChannelSourceTests.cs @@ -17,7 +17,7 @@ using System.Reflection; using System.Threading; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Servers; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelReadBindingTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelReadBindingTests.cs index b28f7a525bf..9d5e6b99131 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelReadBindingTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelReadBindingTests.cs @@ -21,7 +21,7 @@ using System.Threading; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Servers; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelReadWriteBindingTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelReadWriteBindingTests.cs index 3f5bbde5905..9d39d692f18 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelReadWriteBindingTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelReadWriteBindingTests.cs @@ -21,7 +21,7 @@ using System.Threading; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Servers; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelSourceHandleTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelSourceHandleTests.cs index 9021c838836..212ca5f46d9 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelSourceHandleTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelSourceHandleTests.cs @@ -17,7 +17,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelSourceReadWriteBindingTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelSourceReadWriteBindingTests.cs index 08a98eab850..d00f0151e47 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelSourceReadWriteBindingTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ChannelSourceReadWriteBindingTests.cs @@ -16,7 +16,7 @@ using System; using System.Threading; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using Moq; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreSessionOptionsTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreSessionOptionsTests.cs index 44d32ced977..e9662a4b536 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreSessionOptionsTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreSessionOptionsTests.cs @@ -14,7 +14,7 @@ */ using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Bindings diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreSessionTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreSessionTests.cs index 5d187e9c382..4df1c661b3b 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreSessionTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreSessionTests.cs @@ -21,7 +21,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; @@ -226,7 +226,7 @@ public void AdvanceOperationTime_should_have_expected_result() Mock.Get(subject.ServerSession).Verify(m => m.Dispose(), Times.Once); } - [SkippableFact] + [Fact] public void StartTransaction_should_throw_when_write_concern_is_unacknowledged() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet).Supports(Feature.Transactions); diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreTransactionTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreTransactionTests.cs index 0776dbdc19a..d43abf48d2c 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreTransactionTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/CoreTransactionTests.cs @@ -19,7 +19,7 @@ using System.Text; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Bindings diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/NoCoreServerSessionTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/NoCoreServerSessionTests.cs index a8bb074f07f..d04ae632cd4 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/NoCoreServerSessionTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/NoCoreServerSessionTests.cs @@ -14,7 +14,7 @@ */ using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Bindings diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/NoCoreSessionTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/NoCoreSessionTests.cs index e223a7df144..ddfdf2e8946 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/NoCoreSessionTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/NoCoreSessionTests.cs @@ -17,7 +17,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Bindings diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadBindingHandleTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadBindingHandleTests.cs index 06096798231..d26b05ff749 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadBindingHandleTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadBindingHandleTests.cs @@ -16,7 +16,7 @@ using System; using System.Threading; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadPreferenceBindingTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadPreferenceBindingTests.cs index dc4dd76fce0..6f6468e5dbc 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadPreferenceBindingTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadPreferenceBindingTests.cs @@ -19,7 +19,7 @@ using System.Threading; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Clusters.ServerSelectors; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadWriteBindingHandleTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadWriteBindingHandleTests.cs index 0f1345975d8..33f36397c1b 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadWriteBindingHandleTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ReadWriteBindingHandleTests.cs @@ -16,7 +16,7 @@ using System; using System.Threading; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ServerChannelSourceTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ServerChannelSourceTests.cs index 1adddd53453..9b20a631e7b 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ServerChannelSourceTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/ServerChannelSourceTests.cs @@ -26,7 +26,7 @@ using MongoDB.Driver.Core.Helpers; using Moq; using Xunit; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; namespace MongoDB.Driver.Core.Bindings { diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/SingleServerReadBindingTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/SingleServerReadBindingTests.cs index 9aee543a620..d731608be10 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/SingleServerReadBindingTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/SingleServerReadBindingTests.cs @@ -18,7 +18,7 @@ using System.Reflection; using System.Threading; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Servers; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/SingleServerReadWriteBindingTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/SingleServerReadWriteBindingTests.cs index 4bfd753457c..5260dfb8cee 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/SingleServerReadWriteBindingTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/SingleServerReadWriteBindingTests.cs @@ -21,7 +21,7 @@ using System.Threading; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Servers; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/WritableServerBindingTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/WritableServerBindingTests.cs index 5f2dcd0b8d6..9ee482c2f6a 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Bindings/WritableServerBindingTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Bindings/WritableServerBindingTests.cs @@ -20,7 +20,7 @@ using System.Threading; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Clusters.ServerSelectors; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/ClusterDescriptionTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/ClusterDescriptionTests.cs index 321733d4a47..0419ca12cc1 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/ClusterDescriptionTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/ClusterDescriptionTests.cs @@ -16,7 +16,7 @@ using System; using System.Net; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Helpers; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/ClusterTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/ClusterTests.cs index b846811eb85..58dc3b23afd 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/ClusterTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/ClusterTests.cs @@ -23,7 +23,7 @@ using FluentAssertions; using Microsoft.Extensions.Logging; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters.ServerSelectors; using MongoDB.Driver.Core.Configuration; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/LoadBalancedClusterTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/LoadBalancedClusterTests.cs index 2615d08fa64..a5d0e6d6f2a 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/LoadBalancedClusterTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/LoadBalancedClusterTests.cs @@ -19,7 +19,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Clusters.ServerSelectors; using MongoDB.Driver.Core.Configuration; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/SingleServerClusterTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/SingleServerClusterTests.cs index 8a4768cfcca..09b9ee76a3e 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Clusters/SingleServerClusterTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Clusters/SingleServerClusterTests.cs @@ -17,7 +17,7 @@ using System.Linq; using System.Net; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Events; using MongoDB.Driver.Core.Servers; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Compression/CompressorsTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Compression/CompressorsTests.cs index bfe22209431..9f5e0529750 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Compression/CompressorsTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Compression/CompressorsTests.cs @@ -19,7 +19,7 @@ using System.Text; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Compression; using SharpCompress.IO; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ClusterSettingsTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ClusterSettingsTests.cs index 7295d6f9a58..5cb824910ac 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ClusterSettingsTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ClusterSettingsTests.cs @@ -18,7 +18,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson.TestHelpers.EqualityComparers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionPoolSettingsTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionPoolSettingsTests.cs index 426c08c3d20..c5ba1d37e99 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionPoolSettingsTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionPoolSettingsTests.cs @@ -15,7 +15,7 @@ using System; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Configuration diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionSettingsTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionSettingsTests.cs index 19919b77599..764674b1504 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionSettingsTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionSettingsTests.cs @@ -15,7 +15,7 @@ using System; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Authentication; using MongoDB.Driver.Core.Compression; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionStringTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionStringTests.cs index 3581b1793fb..4b6055d1705 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionStringTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Configuration/ConnectionStringTests.cs @@ -23,7 +23,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Compression; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Configuration/TcpStreamSettingsTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Configuration/TcpStreamSettingsTests.cs index 8b791d0378d..d913c4ee2eb 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Configuration/TcpStreamSettingsTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Configuration/TcpStreamSettingsTests.cs @@ -17,7 +17,7 @@ using System.Net.Sockets; using System.Threading; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Configuration diff --git a/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/ExclusiveConnectionPoolTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/ExclusiveConnectionPoolTests.cs index 8efb66633f9..56570e094f9 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/ExclusiveConnectionPoolTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/ExclusiveConnectionPoolTests.cs @@ -22,7 +22,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Connections; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/MaintenanceHelperTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/MaintenanceHelperTests.cs index f7480b74d29..f8b7346b63f 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/MaintenanceHelperTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/ConnectionPools/MaintenanceHelperTests.cs @@ -20,7 +20,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.ConnectionPools; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Connections/BinaryConnectionTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Connections/BinaryConnectionTests.cs index 5375fdd7511..03481e8a2b1 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Connections/BinaryConnectionTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Connections/BinaryConnectionTests.cs @@ -22,7 +22,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Events; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Connections/ClientDocumentHelperTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Connections/ClientDocumentHelperTests.cs index d25a824553a..69c84c4b1ff 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Connections/ClientDocumentHelperTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Connections/ClientDocumentHelperTests.cs @@ -20,7 +20,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Connections diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Connections/CommandEventHelperTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Connections/CommandEventHelperTests.cs index 06dcc3eae6b..cfbfbeaf262 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Connections/CommandEventHelperTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Connections/CommandEventHelperTests.cs @@ -17,7 +17,7 @@ using Microsoft.Extensions.Logging; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Events; using MongoDB.Driver.Core.Logging; using MongoDB.Driver.Core.Misc; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Connections/ConnectionInitializerTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Connections/ConnectionInitializerTests.cs index 2ab40463732..d4c8ffcdde5 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Connections/ConnectionInitializerTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Connections/ConnectionInitializerTests.cs @@ -20,7 +20,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Authentication; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Compression; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Connections/HelloHelperTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Connections/HelloHelperTests.cs index 0e2d28a8e07..8a9755cfcca 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Connections/HelloHelperTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Connections/HelloHelperTests.cs @@ -18,7 +18,7 @@ using MongoDB.Bson; using MongoDB.Bson.TestHelpers; using Xunit; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Compression; using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Misc; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Connections/HelloResultTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Connections/HelloResultTests.cs index 25f33d73411..0d0ac28af79 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Connections/HelloResultTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Connections/HelloResultTests.cs @@ -17,7 +17,7 @@ using System.Net; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Compression; using MongoDB.Driver.Core.Misc; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Connections/TcpStreamFactoryTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Connections/TcpStreamFactoryTests.cs index 28545089ed7..014f1b6a523 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Connections/TcpStreamFactoryTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Connections/TcpStreamFactoryTests.cs @@ -23,7 +23,7 @@ using System.Threading.Tasks; using System.Reflection; using System.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using MongoDB.Bson.TestHelpers; @@ -137,7 +137,7 @@ public void Constructor_should_throw_an_ArgumentNullException_when_tcpStreamSett action.ShouldThrow(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void CreateStream_should_call_the_socketConfigurator( [Values(false, true)] @@ -162,7 +162,7 @@ public void Constructor_should_throw_an_ArgumentNullException_when_tcpStreamSett socketConfiguratorWasCalled.Should().BeTrue(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void CreateStream_should_connect_to_a_running_server_and_return_a_non_null_stream( [Values(false, true)] @@ -185,7 +185,7 @@ public void Constructor_should_throw_an_ArgumentNullException_when_tcpStreamSett stream.Should().NotBeNull(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void SocketConfigurator_can_be_used_to_set_keepAlive( [Values(false, true)] diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Events/EventPublisherTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Events/EventPublisherTests.cs index 46131ed396d..c54f41023d5 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Events/EventPublisherTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Events/EventPublisherTests.cs @@ -16,7 +16,7 @@ using System; using System.Collections.Generic; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Misc/BatchableSourceTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Misc/BatchableSourceTests.cs index f12a391f800..68a51d4acb9 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Misc/BatchableSourceTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Misc/BatchableSourceTests.cs @@ -17,7 +17,7 @@ using System.Collections.Generic; using System.Linq; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Misc diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Misc/SemaphoreSlimSignalableTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Misc/SemaphoreSlimSignalableTests.cs index 7dff7723e8a..74397ba133b 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Misc/SemaphoreSlimSignalableTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Misc/SemaphoreSlimSignalableTests.cs @@ -19,7 +19,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Misc diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Misc/StreamExtensionMethodsTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Misc/StreamExtensionMethodsTests.cs index 7a507ef3ef9..bf17fa539c6 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Misc/StreamExtensionMethodsTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Misc/StreamExtensionMethodsTests.cs @@ -22,7 +22,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Misc/WireVersionTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Misc/WireVersionTests.cs index 9b41badcfa6..62ba6aeec8b 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Misc/WireVersionTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Misc/WireVersionTests.cs @@ -23,7 +23,7 @@ namespace MongoDB.Driver.Core.Tests.Core.Misc { public class WireVersionTests { - [SkippableFact] + [Fact] public void Server_maxWireVersion_should_be_in_supported_range() { RequireServer.Check().StableServer(stable: true); diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateExplainOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateExplainOperationTests.cs index 104028d760b..5dd0be14c98 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateExplainOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateExplainOperationTests.cs @@ -17,7 +17,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; @@ -162,7 +162,7 @@ public void CreateCommand_should_return_expected_result() result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void CreateCommand_should_return_expected_result_when_AllowDiskUse_is_set( [Values(false, true)] @@ -185,7 +185,7 @@ public void CreateCommand_should_return_expected_result() result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void CreateCommand_should_return_expected_result_when_Collation_is_set( [Values("en_US", "fr_CA")] @@ -283,7 +283,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result["maxTimeMS"].BsonType.Should().Be(BsonType.Int32); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -297,7 +297,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().NotBeNull(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_AllowDiskUse_is_set( [Values(false, true)] @@ -314,7 +314,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().NotBeNull(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] @@ -331,7 +331,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().NotBeNull(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -348,7 +348,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Comment_is_set( [Values(false, true)] @@ -372,7 +372,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Hint_is_set( [Values(false, true)] @@ -389,7 +389,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().NotBeNull(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_MaxTime_is_set( [Values(false, true)] @@ -406,7 +406,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().NotBeNull(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateOperationTests.cs index f18aeb17565..d7c4a3273fb 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateOperationTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using Xunit; @@ -566,7 +566,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -605,7 +605,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long argumentNullException.ParamName.Should().Be("binding"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -639,7 +639,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long argumentException.ParamName.Should().Be("pipeline"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_AllowDiskUse_is_set( [Values(null, false, true)] @@ -661,7 +661,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_BatchSize_is_set( [Values(null, 1, 10)] @@ -685,7 +685,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] @@ -708,7 +708,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().HaveCount(caseSensitive ? 1 : 2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Comment_is_set( [Values(false, true)] @@ -735,7 +735,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Hint_is_set( [Values(false, true)] @@ -754,7 +754,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().NotBeNull(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Let_is_set_with_match_expression( [Values(false, true)] @@ -777,7 +777,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Let_is_set_with_project( [Values(false, true)] @@ -801,7 +801,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_MaxAwaitTime_is_set( [Values(null, 1000)] @@ -825,7 +825,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long cursorMaxTime.Should().Be(maxAwaitTime); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_MaxTime_is_set( [Values(null, 1000)] @@ -848,7 +848,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_ReadConcern_is_set( [Values(null, ReadConcernLevel.Local)] @@ -871,7 +871,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_UseCursor_is_set( [Values(null, false, true)] @@ -895,7 +895,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateToCollectionOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateToCollectionOperationTests.cs index a5e49047b0f..535243d003d 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateToCollectionOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/AggregateToCollectionOperationTests.cs @@ -19,7 +19,7 @@ using System.Net; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Servers; @@ -550,7 +550,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values("$out", "$merge")] string lastStageName, @@ -606,7 +606,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_AllowDiskUse_is_set( [Values(null, false, true)] @@ -628,7 +628,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_BypassDocumentValidation_is_set( [Values(null, false, true)] @@ -650,7 +650,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] @@ -678,7 +678,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().HaveCount(caseSensitive ? 1 : 2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -702,7 +702,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Comment_is_set( [Values(false, true)] @@ -728,7 +728,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Hint_is_set( [Values(false, true)] @@ -747,7 +747,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().NotBeNull(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Let_is_set_with_match_expression( [Values(false, true)] @@ -774,7 +774,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Let_is_set_with_project( [Values(false, true)] @@ -802,7 +802,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_MaxTime_is_set( [Values(null, 1000)] @@ -825,7 +825,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_a_write_concern_error_occurs( [Values(false, true)] @@ -843,7 +843,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long exception.Should().BeOfType(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/AsyncCursorSourceEnumerableAdapterTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/AsyncCursorSourceEnumerableAdapterTests.cs index 08325787bce..7cf809b3a0a 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/AsyncCursorSourceEnumerableAdapterTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/AsyncCursorSourceEnumerableAdapterTests.cs @@ -17,7 +17,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/AsyncCursorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/AsyncCursorTests.cs index 469a8f7c530..72b038c09e7 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/AsyncCursorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/AsyncCursorTests.cs @@ -25,7 +25,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkDeleteOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkDeleteOperationTests.cs index 0c5919d7744..86c6c110e9b 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkDeleteOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkDeleteOperationTests.cs @@ -17,7 +17,7 @@ using System.Collections.Generic; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkMixedWriteOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkMixedWriteOperationTests.cs index b23a7e58713..22911a37c02 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkMixedWriteOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkMixedWriteOperationTests.cs @@ -20,7 +20,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Events; using MongoDB.Driver.Core.Misc; @@ -281,7 +281,7 @@ public void WriteConcern_should_work() exception.Should().BeNull(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_one_delete_and_let([Values(false, true)] bool async) { @@ -310,7 +310,7 @@ public void Execute_with_one_delete_and_let([Values(false, true)] bool async) list.Should().HaveCount(5); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_one_delete_against_a_matching_document( [Values(false, true)] @@ -338,7 +338,7 @@ public void Execute_with_one_delete_and_let([Values(false, true)] bool async) list.Should().HaveCount(5); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_one_delete_against_a_matching_document_with_multi( [Values(false, true)] @@ -366,7 +366,7 @@ public void Execute_with_one_delete_and_let([Values(false, true)] bool async) list.Should().HaveCount(3); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_one_delete_without_matching_a_document( [Values(false, true)] @@ -394,7 +394,7 @@ public void Execute_with_one_delete_and_let([Values(false, true)] bool async) list.Should().HaveCount(6); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_multiple_deletes( [Values(false, true)] @@ -426,7 +426,7 @@ public void Execute_with_one_delete_and_let([Values(false, true)] bool async) list.Should().HaveCount(4); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool async) { @@ -463,7 +463,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(4); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_fewer_deletes_than_maxBatchCount( [Values(false, true)] @@ -499,7 +499,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(3); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_more_deletes_than_maxBatchCount( [Values(false, true)] @@ -535,7 +535,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(3); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_one_insert( [Values(false, true)] @@ -563,7 +563,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_fewer_inserts_than_maxBatchCount( [Values(false, true)] @@ -598,7 +598,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_more_inserts_than_maxBatchCount( [Values(false, true)] @@ -635,7 +635,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(4); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_one_update_against_a_matching_document( [Values(false, true)] @@ -666,7 +666,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(6); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_one_update_and_let( [Values(false, true)] bool async) @@ -703,7 +703,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(6); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_one_update_against_a_matching_document_with_multi( [Values(false, true)] @@ -731,7 +731,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(6); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_one_update_without_matching_a_document( [Values(false, true)] @@ -759,7 +759,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(6); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_fewer_updates_than_maxBatchCount( [Values(false, true)] @@ -794,7 +794,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(6); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_more_updates_than_maxBatchCount( [Values(false, true)] @@ -831,7 +831,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(6); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_a_very_large_upsert( [Values(false, true)] @@ -865,7 +865,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(7); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_an_upsert_matching_multiple_documents( [Values(false, true)] @@ -896,7 +896,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(6); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_an_upsert_matching_no_documents( [Values(false, true)] @@ -927,7 +927,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(7); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_an_upsert_matching_one_document( [Values(false, true)] @@ -958,7 +958,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(6); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_mixed_requests_and_ordered_is_false( [Values(false, true)] @@ -995,7 +995,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(6); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_mixed_requests_and_let( [Values(false, true)] bool async) @@ -1041,7 +1041,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list[4].Should().Be("{ _id : 6, x : 3 }"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_mixed_requests_and_ordered_is_true( [Values(false, true)] @@ -1078,7 +1078,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(6); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_mixed_upserts_and_ordered_is_false( [Values(false, true)] @@ -1115,7 +1115,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(8); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_mixed_upserts_and_ordered_is_true( [Values(false, true)] @@ -1152,7 +1152,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(8); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_an_error_in_the_first_batch_and_ordered_is_false( [Values(false, true)] @@ -1193,7 +1193,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(3); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_an_error_in_the_first_batch_and_ordered_is_true( [Values(false, true)] @@ -1240,7 +1240,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_an_error_in_the_second_batch_and_ordered_is_false( [Values(false, true)] @@ -1282,7 +1282,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(4); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_an_error_in_the_second_batch_and_ordered_is_true( [Values(false, true)] @@ -1324,7 +1324,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy list.Should().HaveCount(3); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_unacknowledged_with_an_error_in_the_first_batch_and_ordered_is_false( [Values(false, true)] @@ -1365,7 +1365,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_unacknowledged_with_an_error_in_the_first_batch_and_ordered_is_true( [Values(false, true)] @@ -1411,7 +1411,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_unacknowledged_with_an_error_in_the_second_batch_and_ordered_is_false( [Values(false, true)] @@ -1452,7 +1452,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_unacknowledged_with_an_error_in_the_second_batch_and_ordered_is_true( [Values(false, true)] @@ -1493,7 +1493,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_delete_should_not_send_session_id_when_unacknowledged_writes( [Values(false, true)] bool retryRequested, @@ -1514,7 +1514,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy VerifySessionIdWasNotSentIfUnacknowledgedWrite(subject, "delete", async, useImplicitSession); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_delete_should_send_session_id_when_supported( [Values(false, true)] bool async) @@ -1527,7 +1527,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_insert_should_not_send_session_id_when_unacknowledged_writes( [Values(false, true)] bool retryRequested, @@ -1548,7 +1548,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy VerifySessionIdWasNotSentIfUnacknowledgedWrite(subject, "insert", async, useImplicitSession); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_insert_should_send_session_id_when_supported( [Values(false, true)] bool async) @@ -1561,7 +1561,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy VerifySessionIdWasSentWhenSupported(subject, "insert", async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_update_should_not_send_session_id_when_unacknowledged_writes( [Values(false, true)] bool retryRequested, @@ -1582,7 +1582,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy VerifySessionIdWasNotSentIfUnacknowledgedWrite(subject, "update", async, useImplicitSession); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_update_should_send_session_id_when_supported( [Values(false, true)] bool async) @@ -1594,7 +1594,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy VerifySessionIdWasSentWhenSupported(subject, "update", async); } - [SkippableTheory] + [Theory] [InlineData(new[] { 1 }, new[] { 1 }, false)] [InlineData(new[] { 1, 1 }, new[] { 2 }, false)] [InlineData(new[] { 10000000, 10000000, 10000000, 10000000 }, new[] { 4 }, false)] @@ -1632,7 +1632,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy } } - [SkippableTheory] + [Theory] [InlineData(new[] { 1 }, new[] { 1 }, false)] [InlineData(new[] { 1, 1 }, new[] { 2 }, false)] [InlineData(new[] { 10000000, 10000000, 10000000, 10000000 }, new[] { 4 }, false)] @@ -1672,7 +1672,7 @@ public void Execute_with_multiple_deletes_and_let([Values(false, true)] bool asy } } - [SkippableTheory] + [Theory] [InlineData(new[] { 1 }, new[] { 1 }, false)] [InlineData(new[] { 1, 1 }, new[] { 2 }, false)] [InlineData(new[] { 10000000, 10000000, 10000000, 10000000 }, new[] { 4 }, false)] diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkUpdateOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkUpdateOperationTests.cs index f8e03922e52..2f2e95fc935 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkUpdateOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/BulkUpdateOperationTests.cs @@ -17,7 +17,7 @@ using System.Collections.Generic; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ChangeStreamCursorTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ChangeStreamCursorTests.cs index 517f8a217a2..f2661693749 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ChangeStreamCursorTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ChangeStreamCursorTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; @@ -272,7 +272,7 @@ public void Dispose_can_be_called_more_than_once() subject.GetResumeToken().Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void GetResumeToken_should_return_expected_results_when_batch_is_empty_or_fully_iterated( [Values(false, true)] bool async, @@ -336,7 +336,7 @@ public void Dispose_can_be_called_more_than_once() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void GetResumeToken_should_return_expected_results_when_batch_is_not_empty_and_has_not_been_iterated( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ChangeStreamOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ChangeStreamOperationTests.cs index 68ac25aa2e1..b368fdea6a2 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ChangeStreamOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ChangeStreamOperationTests.cs @@ -22,7 +22,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; @@ -375,7 +375,7 @@ public void ResultSerializer_get_should_work() result.Should().Be(value); } - [SkippableTheory] + [Theory] [InlineData(null)] [InlineData("{ '_data' : 'testValue' }")] public void StartAfter_get_and_set_should_work(string startAfter) @@ -402,7 +402,7 @@ public void StartAtOperationTime_get_and_set_should_work(int? t, int? i) result.Should().Be(value); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_for_drop_collection( [Values(false, true)] bool async) @@ -434,7 +434,7 @@ public void StartAtOperationTime_get_and_set_should_work(int? t, int? i) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_for_deletes( [Values(false, true)] bool async) @@ -466,7 +466,7 @@ public void StartAtOperationTime_get_and_set_should_work(int? t, int? i) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_for_inserts( [Values(false, true)] bool async) @@ -499,7 +499,7 @@ public void StartAtOperationTime_get_and_set_should_work(int? t, int? i) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_for_pre_post_images( [Values(false, true)] bool async, @@ -547,7 +547,7 @@ public void StartAtOperationTime_get_and_set_should_work(int? t, int? i) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_for_large_batch( [Values(1, 2, 3)] int numberOfChunks, @@ -591,7 +591,7 @@ public void StartAtOperationTime_get_and_set_should_work(int? t, int? i) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_for_updates( [Values(ChangeStreamFullDocumentOption.Default, ChangeStreamFullDocumentOption.UpdateLookup)] ChangeStreamFullDocumentOption fullDocument, diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CommandOperationBaseTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CommandOperationBaseTests.cs index d0546bcde94..9a0faaff797 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CommandOperationBaseTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CommandOperationBaseTests.cs @@ -20,7 +20,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Servers; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CompositeWriteOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CompositeWriteOperationTests.cs index 01fd85affd5..18c67618a5c 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CompositeWriteOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CompositeWriteOperationTests.cs @@ -19,7 +19,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Operations; using Moq; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CountDocumentsOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CountDocumentsOperationTests.cs index adfd1999a1f..50b575806c7 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CountDocumentsOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CountDocumentsOperationTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; @@ -195,7 +195,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().Be(value); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -210,7 +210,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().Be(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_no_documents_match( [Values(false, true)] @@ -228,7 +228,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().Be(0); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] @@ -249,7 +249,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().Be(caseSensitive ? 1 : 2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -265,7 +265,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Filter_is_set( [Values(false, true)] @@ -283,7 +283,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().Be(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Hint_is_set( [Values(false, true)] @@ -301,7 +301,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().Be(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Limit_is_set( [Values(null, 1L, 2L)] @@ -321,7 +321,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().Be(limit ?? 2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_MaxTime_is_set( [Values(null, 1000L)] @@ -342,7 +342,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().Be(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_ReadConcern_is_set( [Values(null, ReadConcernLevel.Local)] @@ -363,7 +363,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().Be(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Skip_is_set( [Values(null, 1L, 2L)] @@ -383,7 +383,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().Be(2 - (skip ?? 0)); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CountOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CountOperationTests.cs index 47c6df019a1..07e21d944a7 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CountOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CountOperationTests.cs @@ -16,7 +16,7 @@ using System; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.TestHelpers; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -437,7 +437,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -452,7 +452,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] @@ -473,7 +473,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(caseSensitive ? 1 : 2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -489,7 +489,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Filter_is_set( [Values(false, true)] @@ -507,7 +507,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Hint_is_set( [Values(false, true)] @@ -525,7 +525,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Limit_is_set( [Values(null, 1L, 2L)] @@ -545,7 +545,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(limit ?? 2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_MaxTime_is_set( [Values(null, 1000L)] @@ -566,7 +566,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_ReadConcern_is_set( [Values(null, ReadConcernLevel.Local)] @@ -587,7 +587,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Skip_is_set( [Values(null, 1L, 2L)] @@ -607,7 +607,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(2 - (skip ?? 0)); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateCollectionOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateCollectionOperationTests.cs index 295c4fdc39f..e5fdf203572 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateCollectionOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateCollectionOperationTests.cs @@ -18,7 +18,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -594,7 +594,7 @@ string GetExpectedCollectionName(string[] array) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_collection( [Values(false, true)] @@ -614,7 +614,7 @@ string GetExpectedCollectionName(string[] array) info["name"].AsString.Should().Be(_collectionNamespace.CollectionName); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_collection_when_AutoIndexId_is_set( [Values(false, true)] @@ -641,7 +641,7 @@ string GetExpectedCollectionName(string[] array) info["options"]["autoIndexId"].ToBoolean().Should().Be(autoIndexId); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_collection_when_Capped_is_set( [Values(false, true)] @@ -672,7 +672,7 @@ string GetExpectedCollectionName(string[] array) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_collection_when_Collation_is_set( [Values(false, true)] @@ -695,7 +695,7 @@ string GetExpectedCollectionName(string[] array) info["options"]["collation"]["locale"].AsString.Should().Be("en_US"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_collection_when_IndexOptionDefaults_is_set( [Values(false, true)] @@ -723,7 +723,7 @@ string GetExpectedCollectionName(string[] array) info["options"]["indexOptionDefaults"].Should().Be(indexOptionDefaults); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_collection_when_MaxDocuments_is_set( [Values(1L, 2L)] @@ -750,7 +750,7 @@ string GetExpectedCollectionName(string[] array) info["options"]["max"].ToInt64().Should().Be(maxDocuments); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_collection_when_MaxSize_is_set( [Values(10000L, 20000L)] @@ -776,7 +776,7 @@ string GetExpectedCollectionName(string[] array) info["options"]["size"].ToInt64().Should().BeGreaterOrEqualTo(maxSize); // server rounds maxSize up } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_collection_when_NoPadding_is_set( [Values(false, true)] @@ -801,7 +801,7 @@ string GetExpectedCollectionName(string[] array) info["options"]["flags"].Should().Be(noPadding ? 2 : 0); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_collection_when_StorageEngine_is_set( [Values("abc", "def")] @@ -830,7 +830,7 @@ string GetExpectedCollectionName(string[] array) info["options"]["storageEngine"].Should().Be(storageEngine); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_collection_when_UsePowerOf2Sizes_is_set( [Values(false, true)] @@ -855,7 +855,7 @@ string GetExpectedCollectionName(string[] array) info["options"]["flags"].Should().Be(usePowerOf2Sizes ? 1 : 0); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_collection_when_Validator_is_set( [Values(false, true)] @@ -883,7 +883,7 @@ string GetExpectedCollectionName(string[] array) info["options"]["validationAction"].AsString.Should().Be("error"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_a_write_concern_error_occurs( [Values(false, true)] @@ -907,7 +907,7 @@ string GetExpectedCollectionName(string[] array) exception.Should().BeOfType(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateIndexRequestTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateIndexRequestTests.cs index 5714eb88d8e..94b72ed0e35 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateIndexRequestTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateIndexRequestTests.cs @@ -16,7 +16,7 @@ using System; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateIndexesOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateIndexesOperationTests.cs index cf38de58d75..55e5f4fa61d 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateIndexesOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateIndexesOperationTests.cs @@ -18,7 +18,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; @@ -69,7 +69,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() argumentNullException.ParamName.Should().Be("messageEncoderSettings"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void CommitQuorum_get_and_set_should_work( [Values(null, 1, 2)] int? w) @@ -245,7 +245,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su exception.Should().BeOfType(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -262,7 +262,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_work_when_background_is_true( [Values(false, true)] @@ -280,7 +280,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su index["background"].ToBoolean().Should().BeTrue(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_work_when_commitQuorum_is_specified( [Values(1, "majority", "votingMembers")] object commitQuorumCase, @@ -315,7 +315,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su indexes.Select(index => index["name"].AsString).Should().BeEquivalentTo(new[] { "_id_", "x_1" }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_work_when_creating_one_index( [Values(false, true)] @@ -332,7 +332,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su indexes.Select(index => index["name"].AsString).Should().BeEquivalentTo(new[] { "_id_", "x_1" }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_work_when_creating_two_indexes( [Values(false, true)] @@ -353,7 +353,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su indexes.Select(index => index["name"].AsString).Should().BeEquivalentTo(new[] { "_id_", "x_1", "y_1" }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_work_when_partialFilterExpression_has_value( [Values(false, true)] @@ -371,7 +371,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su index["partialFilterExpression"].AsBsonDocument.Should().Be(requests[0].PartialFilterExpression); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_work_when_sparse_is_true( [Values(false, true)] @@ -389,7 +389,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su index["sparse"].ToBoolean().Should().BeTrue(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_work_when_Collation_has_value( [Values("en_US", "fr_CA")] @@ -410,7 +410,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su index["collation"]["locale"].AsString.Should().Be(locale); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_work_when_expireAfter_has_value( [Values(false, true)] @@ -429,7 +429,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su index["expireAfterSeconds"].ToDouble().Should().Be(expireAfter.TotalSeconds); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_work_when_hidden_has_value( [Values(null, false, true)] bool? hidden, @@ -454,7 +454,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_work_when_unique_is_true( [Values(false, true)] @@ -472,7 +472,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su index["unique"].ToBoolean().Should().BeTrue(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_a_write_concern_error_occurs( [Values(false, true)] @@ -491,7 +491,7 @@ public void CreateCommand_should_throw_when_commitQuorum_is_specified_and_not_su exception.Should().BeOfType(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateViewOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateViewOperationTests.cs index a600ae0b3e2..ef72d20e5fa 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateViewOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/CreateViewOperationTests.cs @@ -21,7 +21,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; @@ -128,7 +128,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().BeSameAs(value); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_view( [Values("a", "b")] @@ -152,7 +152,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() options["pipeline"].AsBsonArray.Cast().Should().Equal(_pipeline); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_view_when_Collation_is_set( [Values(null, "en_US")] @@ -188,7 +188,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_create_view_when_WriteConcern_is_set( [Values("a", "b")] @@ -215,7 +215,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() options["pipeline"].AsBsonArray.Cast().Should().Equal(_pipeline); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_a_write_concern_error_occurs( [Values(false, true)] @@ -233,7 +233,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() exception.Should().BeOfType(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/DatabaseExistsOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/DatabaseExistsOperationTests.cs index 82c11374b98..9b57d46dd17 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/DatabaseExistsOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/DatabaseExistsOperationTests.cs @@ -17,7 +17,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using Xunit; @@ -58,7 +58,7 @@ public void Constructor_should_initialize_subject() subject.RetryRequested.Should().BeFalse(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_true_when_database_exists( [Values(false, true)] @@ -81,7 +81,7 @@ public void Constructor_should_initialize_subject() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_false_when_database_does_not_exist( [Values(false, true)] diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/DistinctOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/DistinctOperationTests.cs index 1c134276458..2771d516b83 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/DistinctOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/DistinctOperationTests.cs @@ -18,7 +18,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; @@ -332,7 +332,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -350,7 +350,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Contain(new[] { 1, 2, 3 }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] @@ -372,7 +372,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Contain(new[] { 2, 3 }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Filter_is_set( [Values(false, true)] @@ -393,7 +393,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Contain(new[] { 2, 3 }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_MaxTime_is_set( [Values(false, true)] @@ -414,7 +414,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Contain(new[] { 1, 2, 3 }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_ReadConcern_is_set( [Values(false, true)] @@ -435,7 +435,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Contain(new[] { 1, 2, 3 }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -451,7 +451,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropCollectionOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropCollectionOperationTests.cs index 429b2dd375d..cde5d1f0f60 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropCollectionOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropCollectionOperationTests.cs @@ -17,7 +17,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Tests.Core.Operations; @@ -196,7 +196,7 @@ string GetExpectedCollectionName(string[] array) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_not_throw_when_collection_does_not_exist( [Values(false, true)] @@ -209,7 +209,7 @@ string GetExpectedCollectionName(string[] array) ExecuteOperation(subject, async); // this will throw if we have a problem... } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -228,7 +228,7 @@ string GetExpectedCollectionName(string[] array) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_a_write_concern_error_occurs( [Values(false, true)] @@ -246,7 +246,7 @@ string GetExpectedCollectionName(string[] array) exception.Should().BeOfType(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropDatabaseOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropDatabaseOperationTests.cs index 864a71781cf..7839d217a1e 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropDatabaseOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropDatabaseOperationTests.cs @@ -18,7 +18,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; @@ -86,7 +86,7 @@ public void CreateCommand_should_return_expected_result() result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -118,7 +118,7 @@ public void CreateCommand_should_return_expected_result() action.ShouldThrow().And.ParamName.Should().Be("binding"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_a_write_concern_error_occurs( [Values(false, true)] @@ -141,7 +141,7 @@ public void CreateCommand_should_return_expected_result() exception.Should().BeOfType(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropIndexOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropIndexOperationTests.cs index 27c04d992b2..b2071cfa907 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropIndexOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/DropIndexOperationTests.cs @@ -19,7 +19,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; @@ -197,7 +197,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_Set(long result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_not_throw_when_collection_does_not_exist( [Values(false, true)] @@ -215,7 +215,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_Set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -246,7 +246,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_Set(long ex.ParamName.Should().Be("binding"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -263,7 +263,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_Set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_a_write_concern_error_occurs( [Values(false, true)] @@ -282,7 +282,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_Set(long exception.Should().BeOfType(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/EndTransactionOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/EndTransactionOperationTests.cs index 673ce134fe9..ab50605e5f9 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/EndTransactionOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/EndTransactionOperationTests.cs @@ -18,7 +18,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/EstimatedDocumentCountOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/EstimatedDocumentCountOperationTests.cs index ba47034319b..9208df77be6 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/EstimatedDocumentCountOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/EstimatedDocumentCountOperationTests.cs @@ -17,7 +17,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; @@ -143,7 +143,7 @@ public void RetryRequested_get_and_set_should_work([Values(false, true)] bool va result.Should().Be(value); } - [SkippableFact] + [Fact] public void CreateCommand_should_return_expected_result() { var subject = new EstimatedDocumentCountOperation(_collectionNamespace, _messageEncoderSettings); @@ -217,7 +217,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long AssertCommandDocument(result, readConcern: expectedReadConcernDocument); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result([Values(false, true)] bool async) { @@ -231,7 +231,7 @@ public void Execute_should_return_expected_result([Values(false, true)] bool asy result.Should().Be(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded([Values(false, true)] bool async) { @@ -247,7 +247,7 @@ public void Execute_should_throw_when_maxTime_is_exceeded([Values(false, true)] } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_MaxTime_is_set( [Values(null, 1000L)] long? milliseconds, @@ -266,7 +266,7 @@ public void Execute_should_throw_when_maxTime_is_exceeded([Values(false, true)] result.Should().Be(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_ReadConcern_is_set( [Values(null, ReadConcernLevel.Local)] ReadConcernLevel? level, @@ -286,7 +286,7 @@ public void Execute_should_throw_when_maxTime_is_exceeded([Values(false, true)] result.Should().Be(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported([Values(false, true)] bool async) { diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/EvalOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/EvalOperationTests.cs index ba90a67780a..64080a96efa 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/EvalOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/EvalOperationTests.cs @@ -18,7 +18,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; @@ -160,7 +160,7 @@ public void CreateCommand_should_return_expected_result_when_noLock_is_provided( result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -175,7 +175,7 @@ public void CreateCommand_should_return_expected_result_when_noLock_is_provided( result.Should().Be(1.0); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_args_are_provided( [Values(false, true)] @@ -200,7 +200,7 @@ public void CreateCommand_should_return_expected_result_when_noLock_is_provided( // TODO: implement EvalOperation MaxTime test } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_noLock_is_provided( [Values(false, true)] @@ -230,7 +230,7 @@ public void CreateCommand_should_return_expected_result_when_noLock_is_provided( action.ShouldThrow(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ExplainOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ExplainOperationTests.cs index a93f1279d2f..3ca20744825 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ExplainOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ExplainOperationTests.cs @@ -19,7 +19,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; @@ -108,7 +108,7 @@ public void CreateCommand_should_return_expected_result(ExplainVerbosity verbosi result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_not_throw_when_collection_does_not_exist( [Values(false, true)] diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndDeleteOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndDeleteOperationTests.cs index 6c42624e79c..7e87965a88d 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndDeleteOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndDeleteOperationTests.cs @@ -18,7 +18,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; @@ -132,7 +132,7 @@ public void Constructor_should_initialize_object() result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_hint_should_throw_when_hint_is_not_supported( [Values(0, 1)] int w, @@ -427,7 +427,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -445,7 +445,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -462,7 +462,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long ReadAllFromCollection().Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] @@ -483,7 +483,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long ReadAllFromCollection().Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Let_is_set( [Values(false, true)] bool async) @@ -503,7 +503,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long ReadAllFromCollection().Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_there_is_a_write_concern_error( [Values(false, true)] bool async) @@ -526,7 +526,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long ReadAllFromCollection().Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_when_document_does_not_exist( [Values(false, true)] diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndReplaceOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndReplaceOperationTests.cs index 7bf1169c745..4eb8534848e 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndReplaceOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndReplaceOperationTests.cs @@ -18,7 +18,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; @@ -525,7 +525,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_an_existing_document_returning_the_original( [Values(false, true)] @@ -547,7 +547,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long ); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_an_existing_document_returning_the_replacement( [Values(false, true)] @@ -569,7 +569,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long ); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_a_non_existing_document_returning_the_original( [Values(false, true)] @@ -592,7 +592,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long ); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_a_non_existing_document_returning_the_replacement( [Values(false, true)] @@ -615,7 +615,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long ); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_a_non_existing_document_returning_the_original_with_upsert( [Values(false, true)] @@ -641,7 +641,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long ); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_a_non_existing_document_returning_the_replacement_with_upsert( [Values(false, true)] @@ -667,7 +667,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long ); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -685,7 +685,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_there_is_a_write_concern_error( [Values(false, true)] @@ -710,7 +710,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long ); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_hint_should_throw_when_hint_is_not_supported( [Values(0, 1)] int w, @@ -744,7 +744,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_let_should_return_correct_results( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndUpdateOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndUpdateOperationTests.cs index e7185115867..715abe1a344 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndUpdateOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOneAndUpdateOperationTests.cs @@ -18,7 +18,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; @@ -519,7 +519,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_an_existing_document_returning_the_original( [Values(false, true)] @@ -540,7 +540,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ _id : 11, x : 2, y : 'A' }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_an_existing_document_returning_the_updated( [Values(false, true)] @@ -561,7 +561,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ _id : 11, x : 2, y : 'A' }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_a_non_existing_document_returning_the_original( [Values(false, true)] @@ -583,7 +583,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ _id : 11, x : 2, y : 'A' }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_a_non_existing_document_returning_the_updated( [Values(false, true)] @@ -605,7 +605,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ _id : 11, x : 2, y : 'A' }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_a_non_existing_document_returning_the_original_with_upsert( [Values(false, true)] @@ -629,7 +629,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ _id : 12, x : 0 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_against_a_non_existing_document_returning_the_updated_with_upsert( [Values(false, true)] @@ -653,7 +653,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ _id : 12, x : 0 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] @@ -677,7 +677,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ _id : 11, x : 0, y : 'A' }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -697,7 +697,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_there_is_a_write_concern_error( [Values(false, true)] @@ -722,7 +722,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ _id : 11, x : 2, y : 'A' }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_with_hint_should_throw_when_hint_is_not_supported( [Values(0, 1)] int w, @@ -756,7 +756,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Let_is_set( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOperationTests.cs index 8370bb844ae..42a4d960b01 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/FindOperationTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Servers; @@ -788,7 +788,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(expectedResult); } - [SkippableFact] + [Fact] public void CreateCursor_should_use_ns_field_instead_of_namespace_passed_in_constructor() { var subject = new FindOperation(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings); @@ -832,7 +832,7 @@ public void CreateCursor_should_use_ns_field_instead_of_namespace_passed_in_cons result.Should().Be(value); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_find_all_the_documents_matching_the_query( [Values(false, true)] @@ -848,7 +848,7 @@ public void CreateCursor_should_use_ns_field_instead_of_namespace_passed_in_cons result.Should().HaveCount(5); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_find_all_the_documents_matching_the_query_when_split_across_batches( [Values(false, true)] @@ -869,7 +869,7 @@ public void CreateCursor_should_use_ns_field_instead_of_namespace_passed_in_cons } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_find_documents_matching_options( [Values(false, true)] bool withLet, @@ -906,7 +906,7 @@ public void CreateCursor_should_use_ns_field_instead_of_namespace_passed_in_cons result.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] @@ -926,7 +926,7 @@ public void CreateCursor_should_use_ns_field_instead_of_namespace_passed_in_cons result.Should().HaveCount(2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_binding_is_null( [Values(false, true)] @@ -940,7 +940,7 @@ public void CreateCursor_should_use_ns_field_instead_of_namespace_passed_in_cons argumentNullException.ParamName.Should().Be("binding"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -956,7 +956,7 @@ public void CreateCursor_should_use_ns_field_instead_of_namespace_passed_in_cons } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/GeoNearOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/GeoNearOperationTests.cs index b1b598c526b..341fa47e97b 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/GeoNearOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/GeoNearOperationTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; @@ -563,7 +563,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -579,7 +579,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result["results"].AsBsonArray.Select(i => i["dis"].ToDouble()).Should().BeInAscendingOrder(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] @@ -603,7 +603,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result["results"].AsBsonArray.Select(i => i["dis"].ToDouble()).Should().BeInAscendingOrder(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) @@ -615,7 +615,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long VerifySessionIdWasSentWhenSupported(subject, "geoNear", async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/GeoSearchOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/GeoSearchOperationTests.cs index a8eb1cc828c..bbc1ee3dec3 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/GeoSearchOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/GeoSearchOperationTests.cs @@ -18,7 +18,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; @@ -159,7 +159,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result["maxTimeMS"].BsonType.Should().Be(BsonType.Int32); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -182,7 +182,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result["results"].Should().NotBeNull(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) @@ -202,7 +202,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long VerifySessionIdWasSentWhenSupported(subject, "geoSearch", async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/GroupOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/GroupOperationTests.cs index 9290baaad15..4a7d7d4de0a 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/GroupOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/GroupOperationTests.cs @@ -18,7 +18,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; @@ -361,7 +361,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result["maxTimeMS"].BsonType.Should().Be(BsonType.Int32); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_key_is_used( [Values(false, true)] @@ -379,7 +379,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ x : 3, count : 3 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_keyFunction_is_used( [Values(false, true)] @@ -397,7 +397,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ x : 3, count : 3 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_Collation_is_set( [Values(false, true)] @@ -437,7 +437,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Equal(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_FinalizeFunction_is_set( [Values(false, true)] @@ -458,7 +458,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ x : 3, count : -3 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_MaxTime_is_used( [Values(null, 1000)] @@ -483,7 +483,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long BsonDocument.Parse("{ x : 3, count : 3 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_ResultSerializer_is_used( [Values(false, true)] @@ -502,7 +502,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long result.Should().Equal(1, 2, 3); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_binding_is_null( [Values(false, true)] @@ -526,7 +526,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long argumentNullException.ParamName.Should().Be("binding"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) @@ -538,7 +538,7 @@ public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(long VerifySessionIdWasSentWhenSupported(subject, "group", async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/IndexNameHelperTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/IndexNameHelperTests.cs index 9408e62064f..e1de914f99a 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/IndexNameHelperTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/IndexNameHelperTests.cs @@ -15,7 +15,7 @@ using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Operations diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/InsertOpcodeOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/InsertOpcodeOperationTests.cs index 56c66ed2bd9..6a1ecf438b3 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/InsertOpcodeOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/InsertOpcodeOperationTests.cs @@ -18,7 +18,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using Xunit; @@ -142,7 +142,7 @@ public void WriteConcern_should_work() subject.WriteConcern.Should().Be(WriteConcern.W2); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_insert_a_single_document( [Values(false, true)] @@ -159,7 +159,7 @@ public void WriteConcern_should_work() list.Should().HaveCount(1); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_insert_multiple_documents( [Values(false, true)] diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListCollectionsOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListCollectionsOperationTests.cs index f0a8be4bb0c..aed03af9ff9 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListCollectionsOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListCollectionsOperationTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using Xunit; @@ -123,7 +123,7 @@ public void Filter_get_and_set_should_work() result.Should().Be(value); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_the_expected_result( [Values(false, true)] @@ -141,7 +141,7 @@ public void Filter_get_and_set_should_work() list.Select(c => c["name"].AsString).Where(n => n != "system.indexes").Should().BeEquivalentTo(expectedNames); } - [SkippableTheory] + [Theory] [InlineData("{ name : \"regular\" }", "regular", false)] [InlineData("{ name : \"regular\" }", "regular", true)] [InlineData("{ \"options.capped\" : true }", "capped", false)] @@ -163,7 +163,7 @@ public void Execute_should_return_the_expected_result_when_filter_is_used(string list[0]["name"].AsString.Should().Be(expectedName); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_the_expected_result_when_batchSize_is_used([Values(false, true)] bool async) { @@ -181,7 +181,7 @@ public void Execute_should_return_the_expected_result_when_batchSize_is_used([Va } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_the_expected_result_when_the_database_does_not_exist( [Values(false, true)] @@ -197,7 +197,7 @@ public void Execute_should_return_the_expected_result_when_batchSize_is_used([Va list.Should().HaveCount(0); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListDatabasesOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListDatabasesOperationTests.cs index 2b426e332de..4767339e37e 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListDatabasesOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListDatabasesOperationTests.cs @@ -16,7 +16,7 @@ using System; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -128,7 +128,7 @@ public void Filter_get_and_set_should_work() result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] bool async) @@ -143,7 +143,7 @@ public void Filter_get_and_set_should_work() list.Should().Contain(x => x["name"] == _databaseNamespace.DatabaseName); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_the_expected_result_when_filter_is_used( [Values(false, true)] bool async) @@ -162,7 +162,7 @@ public void Filter_get_and_set_should_work() databases[0]["name"].AsString.Should().Be(_databaseNamespace.DatabaseName); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_the_expected_result_when_nameOnly_is_used( [Values(false, true)] bool nameOnly, diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListIndexesOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListIndexesOperationTests.cs index 1c9f6f2ad20..d90ec1d86c3 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListIndexesOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListIndexesOperationTests.cs @@ -17,7 +17,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -81,7 +81,7 @@ public void BatchSize_get_and_set_should_work() result.Should().Be(value); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -97,7 +97,7 @@ public void BatchSize_get_and_set_should_work() list.Select(index => index["name"].AsString).Should().BeEquivalentTo("_id_"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_the_expected_result_when_batchSize_is_used([Values(false, true)] bool async) { @@ -115,7 +115,7 @@ public void Execute_should_return_the_expected_result_when_batchSize_is_used([Va } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_collection_does_not_exist( [Values(false, true)] @@ -131,7 +131,7 @@ public void Execute_should_return_the_expected_result_when_batchSize_is_used([Va list.Count.Should().Be(0); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_database_does_not_exist( [Values(false, true)] @@ -161,7 +161,7 @@ public void Execute_should_return_the_expected_result_when_batchSize_is_used([Va action.ShouldThrow().And.ParamName.Should().Be("binding"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListIndexesUsingCommandOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListIndexesUsingCommandOperationTests.cs index 3c5650dbff3..48384169736 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListIndexesUsingCommandOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ListIndexesUsingCommandOperationTests.cs @@ -17,7 +17,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -68,7 +68,7 @@ public void BatchSize_get_and_set_should_work() result.Should().Be(batchSize); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -84,7 +84,7 @@ public void BatchSize_get_and_set_should_work() list.Select(index => index["name"].AsString).Should().BeEquivalentTo("_id_"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_the_expected_result_when_batchSize_is_used([Values(false, true)] bool async) { @@ -102,7 +102,7 @@ public void Execute_should_return_the_expected_result_when_batchSize_is_used([Va } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_collection_does_not_exist( [Values(false, true)] @@ -118,7 +118,7 @@ public void Execute_should_return_the_expected_result_when_batchSize_is_used([Va list.Count.Should().Be(0); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_database_does_not_exist( [Values(false, true)] @@ -148,7 +148,7 @@ public void Execute_should_return_the_expected_result_when_batchSize_is_used([Va action.ShouldThrow().And.ParamName.Should().Be("binding"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceLegacyOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceLegacyOperationTests.cs index f07b034479a..8c29e308409 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceLegacyOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceLegacyOperationTests.cs @@ -20,7 +20,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -64,7 +64,7 @@ public void CreateOutputOptions_should_return_expected_result() result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results( [Values(false, true)] @@ -90,7 +90,7 @@ public void CreateOutputOptions_should_return_expected_result() results.Should().BeEquivalentTo(new BsonArray(expectedResults)); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOperationBaseTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOperationBaseTests.cs index 5e4b6dd13ae..4213fdeffb4 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOperationBaseTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOperationBaseTests.cs @@ -16,7 +16,7 @@ using System; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOperationTests.cs index dfc8e0f7076..153bee61319 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOperationTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; @@ -138,7 +138,7 @@ public void CreateOutputOptions_should_return_expected_result() result.Should().Be("{ inline : 1 }"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results( [Values(false, true)] @@ -158,7 +158,7 @@ public void CreateOutputOptions_should_return_expected_result() BsonDocument.Parse("{ _id : 2, value : 4 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_Collation_is_set( [Values(false, true)] @@ -201,7 +201,7 @@ public void CreateOutputOptions_should_return_expected_result() results.Should().BeEquivalentTo(expectedResults); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_Filter_is_set( [Values(false, true)] @@ -225,7 +225,7 @@ public void CreateOutputOptions_should_return_expected_result() BsonDocument.Parse("{ _id : 2, value : 4 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_FinalizeFunction_is_set( [Values(false, true)] @@ -251,7 +251,7 @@ public void CreateOutputOptions_should_return_expected_result() // TODO: figure out why test fails when JavaScriptMode = true (server bug?) - //[SkippableTheory] + //[Theory] //[ParameterAttributeData] //public void Execute_should_return_expected_results_when_JavaScriptMode_is_set( // [Values(null, false, true)] @@ -275,7 +275,7 @@ public void CreateOutputOptions_should_return_expected_result() // BsonDocument.Parse("{ _id : 2, value : 4 }")); //} - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_Limit_is_set( [Values(1, 2)] @@ -302,7 +302,7 @@ public void CreateOutputOptions_should_return_expected_result() results.Should().Equal(expectedResults); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_MaxTime_is_set( [Values(null, 1000)] @@ -329,7 +329,7 @@ public void CreateOutputOptions_should_return_expected_result() BsonDocument.Parse("{ _id : 2, value : 4 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_ReadConcern_is_set( [Values(null, ReadConcernLevel.Local)] // only use values that are valid on StandAlone servers @@ -356,7 +356,7 @@ public void CreateOutputOptions_should_return_expected_result() BsonDocument.Parse("{ _id : 2, value : 4 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_ResultSerializer_is_set( [Values(false, true)] @@ -376,7 +376,7 @@ public void CreateOutputOptions_should_return_expected_result() results.Should().Equal(3, 4); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_Scope_is_set( [Values(false, true)] @@ -402,7 +402,7 @@ public void CreateOutputOptions_should_return_expected_result() BsonDocument.Parse("{ _id : 2, value : 4 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_Sort_is_set( [Values(1, -1)] @@ -459,7 +459,7 @@ public void CreateOutputOptions_should_return_expected_result() argumentNullException.ParamName.Should().Be("binding"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_maxTime_is_exceeded( [Values(false, true)] bool async) @@ -478,7 +478,7 @@ public void CreateOutputOptions_should_return_expected_result() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) @@ -492,7 +492,7 @@ public void CreateOutputOptions_should_return_expected_result() VerifySessionIdWasSentWhenSupported(subject, "mapReduce", async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void CreateCommand_should_return_expected_result_when_ReadConcern_is_set( [Values(null, ReadConcernLevel.Linearizable, ReadConcernLevel.Local)] @@ -521,7 +521,7 @@ public void CreateOutputOptions_should_return_expected_result() result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void CreateCommand_should_return_the_expected_result_when_using_causal_consistency( [Values(null, ReadConcernLevel.Linearizable, ReadConcernLevel.Local)] diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOutputToCollectionOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOutputToCollectionOperationTests.cs index 2c72232cd52..571b743bee2 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOutputToCollectionOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/MapReduceOutputToCollectionOperationTests.cs @@ -17,7 +17,7 @@ using System.Reflection; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; @@ -328,7 +328,7 @@ public void CreateOutputOptions_should_return_expected_result() result.Should().Be(expectedResult); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -347,7 +347,7 @@ public void CreateOutputOptions_should_return_expected_result() BsonDocument.Parse("{ _id : 2, value : 4 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_Collation_is_set( [Values(false, true)] @@ -389,7 +389,7 @@ public void CreateOutputOptions_should_return_expected_result() ReadAllFromCollection(_outputCollectionNamespace).Should().BeEquivalentTo(expectedResults); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_Filter_is_set( [Values(false, true)] @@ -412,7 +412,7 @@ public void CreateOutputOptions_should_return_expected_result() BsonDocument.Parse("{ _id : 2, value : 4 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_FinalizeFunction_is_set( [Values(false, true)] @@ -437,7 +437,7 @@ public void CreateOutputOptions_should_return_expected_result() // TODO: figure out why test fails when JavaScriptMode = true (server bug?) - //[SkippableTheory] + //[Theory] //[ParameterAttributeData] //public void Execute_should_return_expected_results_when_JavaScriptMode_is_set( // [Values(null, false, true)] @@ -460,7 +460,7 @@ public void CreateOutputOptions_should_return_expected_result() // BsonDocument.Parse("{ _id : 2, value : 4 }")); //} - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_Limit_is_set( [Values(1, 2)] @@ -486,7 +486,7 @@ public void CreateOutputOptions_should_return_expected_result() ReadAllFromCollection(_outputCollectionNamespace).Should().Equal(expectedResults); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_MaxTime_is_set( [Values(null, 1000)] @@ -512,7 +512,7 @@ public void CreateOutputOptions_should_return_expected_result() BsonDocument.Parse("{ _id : 2, value : 4 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_Scope_is_set( [Values(false, true)] @@ -537,7 +537,7 @@ public void CreateOutputOptions_should_return_expected_result() BsonDocument.Parse("{ _id : 2, value : 4 }")); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_results_when_Sort_is_set( [Values(1, -1)] @@ -593,7 +593,7 @@ public void CreateOutputOptions_should_return_expected_result() argumentNullException.ParamName.Should().Be("binding"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_a_write_concern_error_occurs( [Values(false, true)] @@ -612,7 +612,7 @@ public void CreateOutputOptions_should_return_expected_result() exception.Should().BeOfType(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/MaxTimeHelperTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/MaxTimeHelperTests.cs index 9583d341b80..9187c83d198 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/MaxTimeHelperTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/MaxTimeHelperTests.cs @@ -15,7 +15,7 @@ using System; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ReIndexOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ReIndexOperationTests.cs index fcfb046228d..0f508037d9d 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ReIndexOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ReIndexOperationTests.cs @@ -17,7 +17,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -71,7 +71,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() result.Should().BeSameAs(value); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -107,7 +107,7 @@ public void constructor_should_throw_when_messageEncoderSettings_is_null() }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ReadCommandOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ReadCommandOperationTests.cs index 9ecb6ad267e..e66a2fa67d1 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/ReadCommandOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/ReadCommandOperationTests.cs @@ -22,7 +22,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Servers; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/RenameCollectionOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/RenameCollectionOperationTests.cs index af0363bfff7..ce97884bfed 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/RenameCollectionOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/RenameCollectionOperationTests.cs @@ -18,7 +18,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; @@ -160,7 +160,7 @@ public void CreateCommand_should_return_expected_result() result.Should().Be(dropTarget); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result( [Values(false, true)] @@ -176,7 +176,7 @@ public void CreateCommand_should_return_expected_result() result["ok"].ToBoolean().Should().BeTrue(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_expected_result_when_dropTarget_is_true_and_newCollectionNamespace_exists( [Values(false, true)] @@ -195,7 +195,7 @@ public void CreateCommand_should_return_expected_result() result["ok"].ToBoolean().Should().BeTrue(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_dropTarget_is_false_and_newCollectionNamespace_exists( [Values(false, true)] @@ -227,7 +227,7 @@ public void CreateCommand_should_return_expected_result() action.ShouldThrow().And.ParamName.Should().Be("binding"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_throw_when_a_write_concern_error_occurs( [Values(false, true)] @@ -246,7 +246,7 @@ public void CreateCommand_should_return_expected_result() exception.Should().BeOfType(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryabilityHelperTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryabilityHelperTests.cs index 1ffea68d12a..779c694e354 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryabilityHelperTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryabilityHelperTests.cs @@ -17,7 +17,7 @@ using System.IO; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryableDeleteCommandOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryableDeleteCommandOperationTests.cs index ce7babac785..e77602db114 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryableDeleteCommandOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryableDeleteCommandOperationTests.cs @@ -17,7 +17,7 @@ using System.Collections.Generic; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryableUpdateCommandOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryableUpdateCommandOperationTests.cs index f8d07ec8498..44f0eb9ae20 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryableUpdateCommandOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/RetryableUpdateCommandOperationTests.cs @@ -17,7 +17,7 @@ using System.Collections.Generic; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/UpdateOpcodeOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/UpdateOpcodeOperationTests.cs index 27a82145366..150eaa56d90 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/UpdateOpcodeOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/UpdateOpcodeOperationTests.cs @@ -16,7 +16,7 @@ using System; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Operations/WriteCommandOperationTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Operations/WriteCommandOperationTests.cs index 8cbb3a60b09..6da9926706f 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Operations/WriteCommandOperationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Operations/WriteCommandOperationTests.cs @@ -22,7 +22,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Servers; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Servers/HeartbeatDelayTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Servers/HeartbeatDelayTests.cs index de8709375b7..8c2e9014e08 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Servers/HeartbeatDelayTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Servers/HeartbeatDelayTests.cs @@ -18,7 +18,7 @@ using System.Threading; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Servers diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Servers/LoadBalancedServerTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Servers/LoadBalancedServerTests.cs index 81b7ed339f9..6a663956ebe 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Servers/LoadBalancedServerTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Servers/LoadBalancedServerTests.cs @@ -22,7 +22,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Configuration; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/Servers/ServerTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/Servers/ServerTests.cs index f9a60a07243..73a1f2d8957 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/Servers/ServerTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/Servers/ServerTests.cs @@ -25,7 +25,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Clusters.ServerSelectors; @@ -897,7 +897,7 @@ private Server SetupServer(bool exceptionOnConnectionOpen, bool exceptionOnConne public class ServerChannelTests { - [SkippableTheory] + [Theory] [InlineData(1, 2, 2)] [InlineData(2, 1, 2)] public void Command_should_send_the_greater_of_the_session_and_cluster_cluster_times(long sessionTimestamp, long clusterTimestamp, long expectedTimestamp) @@ -950,7 +950,7 @@ public void Command_should_send_the_greater_of_the_session_and_cluster_cluster_t actualClusterTime.Should().Be(expectedClusterTime); } - [SkippableFact] + [Fact] public void Command_should_update_the_session_and_cluster_cluster_times() { RequireServer.Check().ClusterTypes(ClusterType.ReplicaSet, ClusterType.Sharded); @@ -987,7 +987,7 @@ public void Command_should_update_the_session_and_cluster_cluster_times() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Command_should_use_serverApi([Values(false, true)] bool async) { diff --git a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/CommandWriteProtocolTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/CommandWriteProtocolTests.cs index e57a78f19e8..7e5c993b307 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/CommandWriteProtocolTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/CommandWriteProtocolTests.cs @@ -24,7 +24,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/CommandMessageSectionTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/CommandMessageSectionTests.cs index 5bf94888178..c73ee5cea79 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/CommandMessageSectionTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/CommandMessageSectionTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/CommandMessageTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/CommandMessageTests.cs index b912af970f4..beeda5ee40a 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/CommandMessageTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/CommandMessageTests.cs @@ -21,7 +21,7 @@ using MongoDB.Bson; using MongoDB.Bson.IO; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/CommandMessageBinaryEncoderTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/CommandMessageBinaryEncoderTests.cs index 91b2b520bcb..2c99282dbd1 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/CommandMessageBinaryEncoderTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/CommandMessageBinaryEncoderTests.cs @@ -22,7 +22,7 @@ using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/MessageBinaryEncoderBaseTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/MessageBinaryEncoderBaseTests.cs index 49d464dd409..88cbf532c46 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/MessageBinaryEncoderBaseTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/MessageBinaryEncoderBaseTests.cs @@ -16,7 +16,7 @@ using System.IO; using System.Reflection; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders diff --git a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/QueryMessageBinaryEncoderTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/QueryMessageBinaryEncoderTests.cs index abd83d75469..5f9196472d1 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/QueryMessageBinaryEncoderTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/BinaryEncoders/QueryMessageBinaryEncoderTests.cs @@ -18,7 +18,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders diff --git a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/JsonEncoders/CommandMessageJsonEncoderTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/JsonEncoders/CommandMessageJsonEncoderTests.cs index 34fa0b32c53..c4dae987fa4 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/JsonEncoders/CommandMessageJsonEncoderTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/Encoders/JsonEncoders/CommandMessageJsonEncoderTests.cs @@ -22,7 +22,7 @@ using MongoDB.Bson; using MongoDB.Bson.IO; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/QueryMessageTests.cs b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/QueryMessageTests.cs index 67591281745..8beb8be06b3 100644 --- a/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/QueryMessageTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Core/WireProtocol/Messages/QueryMessageTests.cs @@ -17,7 +17,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/CreateIndexCommitQuorumTests.cs b/tests/MongoDB.Driver.Core.Tests/CreateIndexCommitQuorumTests.cs index 91a0ca0d051..1742fe8282a 100644 --- a/tests/MongoDB.Driver.Core.Tests/CreateIndexCommitQuorumTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/CreateIndexCommitQuorumTests.cs @@ -16,7 +16,7 @@ using System; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Tests diff --git a/tests/MongoDB.Driver.Core.Tests/IAsyncCursorExtensionsTests.cs b/tests/MongoDB.Driver.Core.Tests/IAsyncCursorExtensionsTests.cs index f6d90885bf5..aff630021b5 100644 --- a/tests/MongoDB.Driver.Core.Tests/IAsyncCursorExtensionsTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/IAsyncCursorExtensionsTests.cs @@ -19,7 +19,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Operations; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; diff --git a/tests/MongoDB.Driver.Core.Tests/IAsyncCursorSourceExtensionsTests.cs b/tests/MongoDB.Driver.Core.Tests/IAsyncCursorSourceExtensionsTests.cs index 1e0b081cc9b..e2b8188ce43 100644 --- a/tests/MongoDB.Driver.Core.Tests/IAsyncCursorSourceExtensionsTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/IAsyncCursorSourceExtensionsTests.cs @@ -21,7 +21,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Operations; using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; diff --git a/tests/MongoDB.Driver.Core.Tests/Jira/CSharp3173Tests.cs b/tests/MongoDB.Driver.Core.Tests/Jira/CSharp3173Tests.cs index 2b20aefee98..8d5c405ea23 100644 --- a/tests/MongoDB.Driver.Core.Tests/Jira/CSharp3173Tests.cs +++ b/tests/MongoDB.Driver.Core.Tests/Jira/CSharp3173Tests.cs @@ -22,7 +22,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Clusters.ServerSelectors; using MongoDB.Driver.Core.Configuration; diff --git a/tests/MongoDB.Driver.Core.Tests/LoadBalancingIntergationTests.cs b/tests/MongoDB.Driver.Core.Tests/LoadBalancingIntergationTests.cs index 79fd6560372..64edef3bb35 100644 --- a/tests/MongoDB.Driver.Core.Tests/LoadBalancingIntergationTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/LoadBalancingIntergationTests.cs @@ -20,7 +20,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; @@ -43,7 +43,7 @@ public LoadBalancingIntergationTests() _collectionNamespace = CollectionNamespace.FromFullName("db.coll"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void BulkWrite_should_pin_connection_as_expected( [Values(1, 3)] int attempts, @@ -91,7 +91,7 @@ public LoadBalancingIntergationTests() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void BulkWrite_and_cursor_should_share_pinned_connection_under_the_same_transaction_2( [Values(false, true)] bool async) @@ -163,7 +163,7 @@ public LoadBalancingIntergationTests() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void BulkWrite_and_cursor_should_share_pinned_connection_under_the_same_transaction( [Values(1, 3)] int attempts, @@ -229,7 +229,7 @@ public LoadBalancingIntergationTests() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Cursor_should_pin_connection_as_expected( [Values(1, 3)] int attempts, @@ -300,7 +300,7 @@ public LoadBalancingIntergationTests() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Cursor_should_pin_connection_in_transaction_with_new_sessions_as_expected( [Values(1, 3)] int attempts, @@ -374,7 +374,7 @@ public LoadBalancingIntergationTests() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Cursor_should_pin_connection_in_transaction_with_the_same_session_as_expected( [Values(1, 4)] int attempts, @@ -451,7 +451,7 @@ public LoadBalancingIntergationTests() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Cursor_should_unpin_connection_for_operations_under_the_same_transaction_after_abortTransaction_and_cursor_dispose( [Values(1, 3)] int attempts, diff --git a/tests/MongoDB.Driver.Core.Tests/MongoExceptionTests.cs b/tests/MongoDB.Driver.Core.Tests/MongoExceptionTests.cs index 3668bac3563..4425ec13bb9 100644 --- a/tests/MongoDB.Driver.Core.Tests/MongoExceptionTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/MongoExceptionTests.cs @@ -19,7 +19,7 @@ using System.Linq; using System.Runtime.Serialization.Formatters.Binary; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver diff --git a/tests/MongoDB.Driver.Core.Tests/Properties/AssemblyInfo.cs b/tests/MongoDB.Driver.Core.Tests/Properties/AssemblyInfo.cs index c98f691b42d..5ccb2904469 100644 --- a/tests/MongoDB.Driver.Core.Tests/Properties/AssemblyInfo.cs +++ b/tests/MongoDB.Driver.Core.Tests/Properties/AssemblyInfo.cs @@ -14,11 +14,11 @@ */ using System.Runtime.InteropServices; -using MongoDB.Driver.Core.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; [assembly: ComVisible(false)] [assembly: CollectionBehavior(DisableTestParallelization = true)] -[assembly: TestFramework(XunitExtensionsConsts.TimeoutEnforcingXunitFramework, XunitExtensionsConsts.TimeoutEnforcingFrameworkAssembly)] +[assembly: TestFramework(XunitExtensionsConstants.TimeoutEnforcingXunitFramework, XunitExtensionsConstants.TimeoutEnforcingFrameworkAssembly)] diff --git a/tests/MongoDB.Driver.Core.Tests/ReadConcernTests.cs b/tests/MongoDB.Driver.Core.Tests/ReadConcernTests.cs index c594865f310..db0c5284b11 100644 --- a/tests/MongoDB.Driver.Core.Tests/ReadConcernTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/ReadConcernTests.cs @@ -20,7 +20,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/ReadPreferenceHedgeTests.cs b/tests/MongoDB.Driver.Core.Tests/ReadPreferenceHedgeTests.cs index 6cf46ed5a65..9b6f36e6b7e 100644 --- a/tests/MongoDB.Driver.Core.Tests/ReadPreferenceHedgeTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/ReadPreferenceHedgeTests.cs @@ -14,7 +14,7 @@ */ using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Core.Tests diff --git a/tests/MongoDB.Driver.Core.Tests/ReadPreferenceTests.cs b/tests/MongoDB.Driver.Core.Tests/ReadPreferenceTests.cs index 22535318a7e..602d018ed55 100644 --- a/tests/MongoDB.Driver.Core.Tests/ReadPreferenceTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/ReadPreferenceTests.cs @@ -21,7 +21,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Tests; using Xunit; diff --git a/tests/MongoDB.Driver.Core.Tests/TransactionOptionsTests.cs b/tests/MongoDB.Driver.Core.Tests/TransactionOptionsTests.cs index dc2d18100e7..d9257362bed 100644 --- a/tests/MongoDB.Driver.Core.Tests/TransactionOptionsTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/TransactionOptionsTests.cs @@ -14,7 +14,7 @@ */ using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver diff --git a/tests/MongoDB.Driver.Core.Tests/WriteConcernTests.cs b/tests/MongoDB.Driver.Core.Tests/WriteConcernTests.cs index a44f75e0e05..690b8d61657 100644 --- a/tests/MongoDB.Driver.Core.Tests/WriteConcernTests.cs +++ b/tests/MongoDB.Driver.Core.Tests/WriteConcernTests.cs @@ -20,7 +20,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver diff --git a/tests/MongoDB.Driver.Examples/ClientSideEncryption2Examples.cs b/tests/MongoDB.Driver.Examples/ClientSideEncryption2Examples.cs index 536c478eae2..6c6b4dde152 100644 --- a/tests/MongoDB.Driver.Examples/ClientSideEncryption2Examples.cs +++ b/tests/MongoDB.Driver.Examples/ClientSideEncryption2Examples.cs @@ -33,7 +33,7 @@ public class ClientSideEncryption2Examples private readonly static CollectionNamespace CollectionNamespace = CollectionNamespace.FromFullName("docsExamples.encrypted"); private readonly static CollectionNamespace KeyVaultNamespace = CollectionNamespace.FromFullName("keyvault.datakeys"); - [SkippableFact] + [Fact] public void FLE2AutomaticEncryption() { RequireServer.Check().Supports(Feature.Csfle2).ClusterTypes(ClusterType.ReplicaSet, ClusterType.Sharded, ClusterType.LoadBalanced); diff --git a/tests/MongoDB.Driver.Examples/Properties/AssemblyInfo.cs b/tests/MongoDB.Driver.Examples/Properties/AssemblyInfo.cs index fbbd5774143..35a2ab489b9 100644 --- a/tests/MongoDB.Driver.Examples/Properties/AssemblyInfo.cs +++ b/tests/MongoDB.Driver.Examples/Properties/AssemblyInfo.cs @@ -14,8 +14,11 @@ */ using System.Runtime.InteropServices; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; [assembly: ComVisible(false)] [assembly: CollectionBehavior(DisableTestParallelization = true)] + +[assembly: TestFramework(XunitExtensionsConstants.TimeoutEnforcingXunitFramework, XunitExtensionsConstants.TimeoutEnforcingFrameworkAssembly)] diff --git a/tests/MongoDB.Driver.Examples/TransactionExamplesForDocs/WithTransactionExample1.cs b/tests/MongoDB.Driver.Examples/TransactionExamplesForDocs/WithTransactionExample1.cs index 6c4ab87e324..2a384355165 100644 --- a/tests/MongoDB.Driver.Examples/TransactionExamplesForDocs/WithTransactionExample1.cs +++ b/tests/MongoDB.Driver.Examples/TransactionExamplesForDocs/WithTransactionExample1.cs @@ -25,7 +25,7 @@ namespace MongoDB.Driver.Examples.TransactionExamplesForDocs { public class WithTransactionExample1 { - [SkippableFact] + [Fact] public void Example1() { RequireServer.Check().ClusterTypes(ClusterType.ReplicaSet, ClusterType.Sharded).Supports(Feature.Transactions); diff --git a/tests/MongoDB.Driver.Examples/UpdatePrimer.cs b/tests/MongoDB.Driver.Examples/UpdatePrimer.cs index 3fe3778115e..af423307167 100644 --- a/tests/MongoDB.Driver.Examples/UpdatePrimer.cs +++ b/tests/MongoDB.Driver.Examples/UpdatePrimer.cs @@ -23,7 +23,7 @@ namespace MongoDB.Driver.Examples { public class UpdatePrimer : PrimerTestFixture { - [SkippableFact] + [Fact] public async Task UpdateTopLevelFields() { RequireServer.Check(); @@ -74,7 +74,7 @@ public async Task UpdateEmbeddedField() // @end: update-embedded-field } - [SkippableFact] + [Fact] public async Task UpdateMultipleDocuments() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.GridFS.Tests/DelegatingStreamTests.cs b/tests/MongoDB.Driver.GridFS.Tests/DelegatingStreamTests.cs index dcd02487a56..2656fbb44c2 100644 --- a/tests/MongoDB.Driver.GridFS.Tests/DelegatingStreamTests.cs +++ b/tests/MongoDB.Driver.GridFS.Tests/DelegatingStreamTests.cs @@ -18,7 +18,7 @@ using System.Threading; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.GridFS.Tests/GridFSBucketOptionsTests.cs b/tests/MongoDB.Driver.GridFS.Tests/GridFSBucketOptionsTests.cs index 74d80659d7c..f8b68630834 100644 --- a/tests/MongoDB.Driver.GridFS.Tests/GridFSBucketOptionsTests.cs +++ b/tests/MongoDB.Driver.GridFS.Tests/GridFSBucketOptionsTests.cs @@ -19,7 +19,7 @@ using System.Text; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.GridFS.Tests diff --git a/tests/MongoDB.Driver.GridFS.Tests/GridFSBucketTests.cs b/tests/MongoDB.Driver.GridFS.Tests/GridFSBucketTests.cs index cad743c9580..36d0690b019 100644 --- a/tests/MongoDB.Driver.GridFS.Tests/GridFSBucketTests.cs +++ b/tests/MongoDB.Driver.GridFS.Tests/GridFSBucketTests.cs @@ -21,7 +21,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -327,7 +327,7 @@ public void Database_get_should_return_the_expected_result() action.ShouldThrow().And.ParamName.Should().Be("filename"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Drop_should_drop_the_files_and_chunks_collections( [Values(false, true)] bool async) @@ -352,7 +352,7 @@ public void Database_get_should_return_the_expected_result() collectionNames.Should().NotContain("fs.chunks"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Drop_should_throw_when_a_write_concern_error_occurss( [Values(false, true)] diff --git a/tests/MongoDB.Driver.GridFS.Tests/GridFSDownloadStreamBaseTests.cs b/tests/MongoDB.Driver.GridFS.Tests/GridFSDownloadStreamBaseTests.cs index 9f031c1796b..efce1a67b53 100644 --- a/tests/MongoDB.Driver.GridFS.Tests/GridFSDownloadStreamBaseTests.cs +++ b/tests/MongoDB.Driver.GridFS.Tests/GridFSDownloadStreamBaseTests.cs @@ -20,7 +20,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; diff --git a/tests/MongoDB.Driver.GridFS.Tests/GridFSFileInfoTests.cs b/tests/MongoDB.Driver.GridFS.Tests/GridFSFileInfoTests.cs index b09c32d921f..b8a28b31b51 100644 --- a/tests/MongoDB.Driver.GridFS.Tests/GridFSFileInfoTests.cs +++ b/tests/MongoDB.Driver.GridFS.Tests/GridFSFileInfoTests.cs @@ -22,7 +22,7 @@ using MongoDB.Bson; using MongoDB.Bson.IO; using MongoDB.Bson.Serialization; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.GridFS.Tests diff --git a/tests/MongoDB.Driver.GridFS.Tests/GridFSFindOptionsTests.cs b/tests/MongoDB.Driver.GridFS.Tests/GridFSFindOptionsTests.cs index b8e3d3efe79..6532d091905 100644 --- a/tests/MongoDB.Driver.GridFS.Tests/GridFSFindOptionsTests.cs +++ b/tests/MongoDB.Driver.GridFS.Tests/GridFSFindOptionsTests.cs @@ -19,7 +19,7 @@ using System.Text; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.GridFS.Tests diff --git a/tests/MongoDB.Driver.GridFS.Tests/GridFSSeekableDownloadStreamTests.cs b/tests/MongoDB.Driver.GridFS.Tests/GridFSSeekableDownloadStreamTests.cs index cd6cd2e878e..379a4dfd955 100644 --- a/tests/MongoDB.Driver.GridFS.Tests/GridFSSeekableDownloadStreamTests.cs +++ b/tests/MongoDB.Driver.GridFS.Tests/GridFSSeekableDownloadStreamTests.cs @@ -20,7 +20,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; diff --git a/tests/MongoDB.Driver.GridFS.Tests/GridFSUploadOptionsTests.cs b/tests/MongoDB.Driver.GridFS.Tests/GridFSUploadOptionsTests.cs index 485819ed9e7..4a6fa3d46d2 100644 --- a/tests/MongoDB.Driver.GridFS.Tests/GridFSUploadOptionsTests.cs +++ b/tests/MongoDB.Driver.GridFS.Tests/GridFSUploadOptionsTests.cs @@ -20,7 +20,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.GridFS.Tests diff --git a/tests/MongoDB.Driver.GridFS.Tests/GridFSUploadStreamTests.cs b/tests/MongoDB.Driver.GridFS.Tests/GridFSUploadStreamTests.cs index 1f3cbca7e46..ce063af2048 100644 --- a/tests/MongoDB.Driver.GridFS.Tests/GridFSUploadStreamTests.cs +++ b/tests/MongoDB.Driver.GridFS.Tests/GridFSUploadStreamTests.cs @@ -17,7 +17,7 @@ using System.IO; using System.Threading; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Tests; using Xunit; diff --git a/tests/MongoDB.Driver.GridFS.Tests/Properties/AssemblyInfo.cs b/tests/MongoDB.Driver.GridFS.Tests/Properties/AssemblyInfo.cs index b9c458de29c..35a2ab489b9 100644 --- a/tests/MongoDB.Driver.GridFS.Tests/Properties/AssemblyInfo.cs +++ b/tests/MongoDB.Driver.GridFS.Tests/Properties/AssemblyInfo.cs @@ -14,11 +14,11 @@ */ using System.Runtime.InteropServices; -using MongoDB.Driver.Core.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; [assembly: ComVisible(false)] [assembly: CollectionBehavior(DisableTestParallelization = true)] -[assembly: TestFramework(XunitExtensionsConsts.TimeoutEnforcingXunitFramework, XunitExtensionsConsts.TimeoutEnforcingFrameworkAssembly)] +[assembly: TestFramework(XunitExtensionsConstants.TimeoutEnforcingXunitFramework, XunitExtensionsConstants.TimeoutEnforcingFrameworkAssembly)] diff --git a/tests/MongoDB.Driver.GridFS.Tests/Specifications/gridfs/GridFSTestRunner.cs b/tests/MongoDB.Driver.GridFS.Tests/Specifications/gridfs/GridFSTestRunner.cs index ff25181e5d7..481259cc4ca 100644 --- a/tests/MongoDB.Driver.GridFS.Tests/Specifications/gridfs/GridFSTestRunner.cs +++ b/tests/MongoDB.Driver.GridFS.Tests/Specifications/gridfs/GridFSTestRunner.cs @@ -18,17 +18,16 @@ using System.IO; using System.Linq; using System.Reflection; -using System.Threading.Tasks; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Tests; using Xunit; +using Xunit.Sdk; namespace MongoDB.Driver.GridFS.Tests.Specifications.gridfs { public class GridFSTestRunner { - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseSource))] [Trait("Category", "Specifications_gridfs")] public void RunTest(BsonDocument data, BsonDocument testDefinition) diff --git a/tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTests.cs b/tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTests.cs index 82e28798e05..78c2385e92a 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTests.cs @@ -37,7 +37,7 @@ public IndexKeysBuilderTests() _primary = _server.Primary; } - [SkippableFact] + [Fact] public void CreateIndex_with_wildcard_index_should_create_expected_index() { RequireServer.Check().Supports(Feature.WildcardIndexes); @@ -54,7 +54,7 @@ public void CreateIndex_with_wildcard_index_should_create_expected_index() index["key"]["a.$**"].AsInt32.Should().Be(1); } - [SkippableFact] + [Fact] public void CreateIndex_with_wildcardProjection_should_create_expected_index() { RequireServer.Check().Supports(Feature.WildcardIndexes); @@ -248,7 +248,7 @@ public void TestTextCombination() Assert.Equal(expected, key.ToJson()); } - [SkippableFact] + [Fact] public void TestTextIndexCreation() { RequireServer.Check().VersionGreaterThanOrEqualTo("2.6.0").ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet); diff --git a/tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTypedTests.cs b/tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTypedTests.cs index 0e8b3af14ee..de82af9eead 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTypedTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Builders/IndexKeysBuilderTypedTests.cs @@ -60,7 +60,7 @@ private class Test public int Id { get; set; } } - [SkippableFact] + [Fact] public void CreateIndex_with_wildcard_index_should_create_expected_index() { RequireServer.Check().Supports(Feature.WildcardIndexes); @@ -74,7 +74,7 @@ public void CreateIndex_with_wildcard_index_should_create_expected_index() index["key"]["a.$**"].AsInt32.Should().Be(1); } - [SkippableFact] + [Fact] public void CreateIndex_with_wildcardProjection_should_create_expected_index() { RequireServer.Check().Supports(Feature.WildcardIndexes); @@ -298,7 +298,7 @@ public void TestTextArrayNonArrayFields2() Assert.Equal(expected, keys.ToJson()); } - [SkippableFact] + [Fact] public void TestTextIndexCreation() { RequireServer.Check().VersionGreaterThanOrEqualTo("2.6.0").ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet); diff --git a/tests/MongoDB.Driver.Legacy.Tests/ClientDocumentHelperTests.cs b/tests/MongoDB.Driver.Legacy.Tests/ClientDocumentHelperTests.cs index 13399a73803..36ac58c16e2 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/ClientDocumentHelperTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/ClientDocumentHelperTests.cs @@ -16,7 +16,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Connections; using Xunit; diff --git a/tests/MongoDB.Driver.Legacy.Tests/CommandResults/CollectionStatsResultTests.cs b/tests/MongoDB.Driver.Legacy.Tests/CommandResults/CollectionStatsResultTests.cs index 9aa38a69fb6..f5b81dada13 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/CommandResults/CollectionStatsResultTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/CommandResults/CollectionStatsResultTests.cs @@ -34,7 +34,7 @@ public CollectionStatsResultTests() _collection = LegacyTestConfiguration.Collection; } - [SkippableFact] + [Fact] public void Test() { RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet).StorageEngine("mmapv1"); diff --git a/tests/MongoDB.Driver.Legacy.Tests/CommandResults/DatabaseStatsResultTests.cs b/tests/MongoDB.Driver.Legacy.Tests/CommandResults/DatabaseStatsResultTests.cs index e0dfa1afddd..efc8a588e79 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/CommandResults/DatabaseStatsResultTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/CommandResults/DatabaseStatsResultTests.cs @@ -14,7 +14,7 @@ */ using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver; using MongoDB.Driver.Core; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -35,7 +35,7 @@ public DatabaseStatsResultTests() _collection = LegacyTestConfiguration.Collection; } - [SkippableFact] + [Fact] public void Test() { RequireServer.Check().StorageEngine("mmapv1"); diff --git a/tests/MongoDB.Driver.Legacy.Tests/DefaultLegacyOperationExecutorTests.cs b/tests/MongoDB.Driver.Legacy.Tests/DefaultLegacyOperationExecutorTests.cs index ba7b6c94fe8..27a6335c258 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/DefaultLegacyOperationExecutorTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/DefaultLegacyOperationExecutorTests.cs @@ -16,7 +16,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Operations; using Moq; diff --git a/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp216Tests.cs b/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp216Tests.cs index 2f6bb0a325b..ebd20190675 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp216Tests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp216Tests.cs @@ -15,7 +15,7 @@ using System.Linq; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -32,7 +32,7 @@ public CSharp216Tests() _adminDatabase = LegacyTestConfiguration.Server.GetDatabase("admin"); } - [SkippableFact] + [Fact] public void TestAmbiguousEvalArguments() { RequireServer.Check().Supports(Feature.Eval); @@ -51,7 +51,7 @@ public void TestAmbiguousEvalArguments() #pragma warning restore } - [SkippableFact] + [Fact] public void TestNoLock() { RequireServer.Check().Supports(Feature.Eval); diff --git a/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp269Tests.cs b/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp269Tests.cs index af706f43e90..89ceac2f059 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp269Tests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp269Tests.cs @@ -43,7 +43,7 @@ public CSharp269Tests() _database.GridFS.Chunks.Drop(); } - [SkippableFact] + [Fact] public void TestUploadAndDownload() { RequireServer.Check().ClusterTypes(Core.Clusters.ClusterType.Standalone, Core.Clusters.ClusterType.ReplicaSet); diff --git a/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp365Tests.cs b/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp365Tests.cs index 01d4b1eb0c2..031b3f95cd9 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp365Tests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Jira/CSharp365Tests.cs @@ -23,7 +23,7 @@ namespace MongoDB.Driver.Tests.Jira.CSharp365 { public class CSharp365Tests { - [SkippableFact] + [Fact] public void TestExplainWithFieldsAndCoveredIndex() { RequireServer.Check().Supports(Feature.LegacyWireProtocol); diff --git a/tests/MongoDB.Driver.Legacy.Tests/Linq/BsonDocumentBackedClassSerializerTests.cs b/tests/MongoDB.Driver.Legacy.Tests/Linq/BsonDocumentBackedClassSerializerTests.cs index 386d84dbb3c..9ffc6e09498 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Linq/BsonDocumentBackedClassSerializerTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Linq/BsonDocumentBackedClassSerializerTests.cs @@ -21,7 +21,7 @@ using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.Serialization.Options; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Builders; using Xunit; diff --git a/tests/MongoDB.Driver.Legacy.Tests/Linq/ExplainTests.cs b/tests/MongoDB.Driver.Legacy.Tests/Linq/ExplainTests.cs index 062ddced971..9f4287b11cd 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Linq/ExplainTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Linq/ExplainTests.cs @@ -42,7 +42,7 @@ public ExplainTests() _collection = LegacyTestConfiguration.Collection; } - [SkippableFact] + [Fact] public void TestExplainFromLinqQueryEqualsExplainFromCursor() { RequireServer.Check().Supports(Feature.LegacyWireProtocol); @@ -64,7 +64,7 @@ public void TestExplainFromLinqQueryEqualsExplainFromCursor() } } - [SkippableFact] + [Fact] public void TestVerboseExplainFromLinqQueryEqualsVerboseExplainFromCursor() { RequireServer.Check().Supports(Feature.LegacyWireProtocol); diff --git a/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectNullableTests.cs b/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectNullableTests.cs index 6911aea7b69..611e1e0b96a 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectNullableTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectNullableTests.cs @@ -17,7 +17,7 @@ using System.Linq; using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver; using MongoDB.Driver.Linq; using Xunit; @@ -61,7 +61,7 @@ private static bool OneTimeSetup() return true; } - [SkippableFact] + [Fact] public void TestWhereEEqualsA() { RequireEnvironment.Check().EnvironmentVariable("MONO"); // Does not pass on Mono 3.2.5. Excluding for now. diff --git a/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectOfTypeHierarchicalTests.cs b/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectOfTypeHierarchicalTests.cs index 10947efab8d..e225d24fde7 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectOfTypeHierarchicalTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectOfTypeHierarchicalTests.cs @@ -250,7 +250,7 @@ public void TestWhereBIsD() Assert.Equal(1, Consume(query)); } - [SkippableFact] + [Fact] public void TestWhereBTypeEqualsB() { RequireServer.Check().VersionGreaterThanOrEqualTo("2.0.0"); diff --git a/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectQueryTests.cs b/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectQueryTests.cs index 59c31a82aec..eb865b5dc0b 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectQueryTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Linq/SelectQueryTests.cs @@ -4456,7 +4456,7 @@ public void TestWhereSASub0ContainsO() Assert.Equal(1, Consume(query)); } - [SkippableFact] + [Fact] public void TestWhereSASub0ContainsONot() { var query = from c in __collection.AsQueryable() @@ -4502,7 +4502,7 @@ public void TestWhereSASub0EndsWithM() Assert.Equal(1, Consume(query)); } - [SkippableFact] + [Fact] public void TestWhereSASub0EndsWithMNot() { var query = from c in __collection.AsQueryable() @@ -4549,7 +4549,7 @@ where regex.IsMatch(c.SA[0]) Assert.Equal(1, Consume(query)); } - [SkippableFact] + [Fact] public void TestWhereSASub0IsMatchNot() { var regex = new Regex(@"^T"); @@ -4596,7 +4596,7 @@ where Regex.IsMatch(c.SA[0], "^T") Assert.Equal(1, Consume(query)); } - [SkippableFact] + [Fact] public void TestWhereSASub0IsMatchStaticNot() { var query = from c in __collection.AsQueryable() @@ -4665,7 +4665,7 @@ public void TestWhereSASub0StartsWithT() Assert.Equal(1, Consume(query)); } - [SkippableFact] + [Fact] public void TestWhereSASub0StartsWithTNot() { var query = from c in __collection.AsQueryable() diff --git a/tests/MongoDB.Driver.Legacy.Tests/Linq/WithIndexTests.cs b/tests/MongoDB.Driver.Legacy.Tests/Linq/WithIndexTests.cs index eed0c3c4b9d..8aafe399ff5 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Linq/WithIndexTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Linq/WithIndexTests.cs @@ -106,7 +106,7 @@ public void TestQueryWithIndexBeforeConditionHasIndexNameHint() Assert.Equal("{ \"a\" : 1, \"b\" : 3 }", selectQuery.BuildQuery().ToJson()); } - [SkippableFact] + [Fact] public void TestIndexNameHintIsUsedInQuery() { RequireServer.Check().Supports(Feature.LegacyWireProtocol); @@ -184,7 +184,7 @@ public void TestQueryWithIndexBeforeConditionHasIndexDocumentHint() Assert.Equal("{ \"a\" : 1, \"b\" : 3 }", selectQuery.BuildQuery().ToJson()); } - [SkippableFact] + [Fact] public void TestIndexDocumentHintIsUsedInQuery() { RequireServer.Check().Supports(Feature.LegacyWireProtocol); diff --git a/tests/MongoDB.Driver.Legacy.Tests/MongoCollectionTests.cs b/tests/MongoDB.Driver.Legacy.Tests/MongoCollectionTests.cs index 9830a72b8b0..fb2dde4aad7 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/MongoCollectionTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/MongoCollectionTests.cs @@ -26,7 +26,7 @@ using MongoDB.Driver.GeoJsonObjectModel; using FluentAssertions; using Xunit; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; @@ -140,7 +140,7 @@ public void TestAggregateCursor() Assert.Equal(2, dictionary[3]); } - [SkippableFact] + [Fact] public void TestAggregateExplain() { RequireServer.Check().Supports(Feature.LegacyWireProtocol); @@ -184,7 +184,7 @@ public void TestAggregateMaxTime() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void TestAggregateOutputToCollection( [Values("$out", "$merge")] string lastStageName, @@ -259,7 +259,7 @@ public void TestAggregateMaxTime() Assert.Equal(2, dictionary[3]); } - [SkippableFact] + [Fact] public void TestAggregateWriteConcern() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -441,7 +441,7 @@ public void TestCountZero() Assert.Equal(0, count); } - [SkippableFact] + [Fact] public void TestCountUsesImplicitSession() { RequireServer.Check(); @@ -484,7 +484,7 @@ public void TestCountWithMaxTime() } } - [SkippableFact] + [Fact] public void TestCountWithMaxTimeFromFind() { RequireServer.Check(); @@ -509,7 +509,7 @@ public void TestCountWithQuery() Assert.Equal(1, count); } - [SkippableFact] + [Fact] public void TestCountWithReadPreferenceFromFind() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -525,7 +525,7 @@ public void TestCountWithReadPreferenceFromFind() } } - [SkippableFact] + [Fact] public void TestCountWithHint() { RequireServer.Check(); @@ -542,7 +542,7 @@ public void TestCountWithHint() Assert.Equal(1, count); } - [SkippableFact] + [Fact] public void TestCountWithHintFromFind() { RequireServer.Check(); @@ -554,7 +554,7 @@ public void TestCountWithHintFromFind() Assert.Equal(1, count); } - [SkippableFact] + [Fact] public void TestCountWithHintAndLimitFromFind() { RequireServer.Check(); @@ -576,7 +576,7 @@ public void TestCreateCollection() Assert.True(collection.Exists()); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void TestCreateCollectionSetAutoIndexId( [Values(false, true)] @@ -596,7 +596,7 @@ public void TestCreateCollection() Assert.Equal(expectedIndexCount, indexCount); } - [SkippableFact] + [Fact] public void TestCreateCollectionSetCappedSetMaxDocuments() { RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet).StorageEngine("mmapv1"); @@ -612,7 +612,7 @@ public void TestCreateCollectionSetCappedSetMaxDocuments() Assert.True(stats.MaxDocuments == 1000); } - [SkippableFact] + [Fact] public void TestCreateCollectionSetCappedSetMaxSize() { RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet).StorageEngine("mmapv1"); @@ -627,7 +627,7 @@ public void TestCreateCollectionSetCappedSetMaxSize() Assert.True(stats.StorageSize >= 10000); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void TestCreateCollectionSetNoPadding( [Values(false, true)] @@ -648,7 +648,7 @@ public void TestCreateCollectionSetCappedSetMaxSize() Assert.Equal(userFlags, stats.UserFlags); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void TestCreateCollectionSetUsePowerOf2Sizes( [Values(false, true)] @@ -764,7 +764,7 @@ void AssertNamespace(IndexInfo indexInfo) Assert.True(indexes[1].Version >= 0); } - [SkippableFact] + [Fact] public void TestCreateIndexWithStorageEngine() { RequireServer.Check().StorageEngine("wiredTiger"); @@ -780,7 +780,7 @@ public void TestCreateIndexWithStorageEngine() Assert.Equal(2, result.Count); } - [SkippableFact] + [Fact] public void TestCreateIndexWriteConcern() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -917,7 +917,7 @@ public void TestDropIndex() _collection.IndexExistsByName("x_1").Should().BeFalse(); } - [SkippableFact] + [Fact] public void TestDropIndexWriteConcern() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -949,7 +949,7 @@ public void TestCreateIndexTimeToLive() Assert.Equal(TimeSpan.FromHours(1), indexes[1].TimeToLive); } - [SkippableFact] + [Fact] public void TestExplain() { RequireServer.Check().Supports(Feature.LegacyWireProtocol); @@ -1098,7 +1098,7 @@ public void TestFindAndModifyUpsert() Assert.Equal(1, result.ModifiedDocument["count"].AsInt32); } - [SkippableFact] + [Fact] public void TestFindAndModifyReplaceWithWriteConcernError() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -1125,7 +1125,7 @@ public void TestFindAndModifyReplaceWithWriteConcernError() modifiedDocument.Should().Be("{ _id : 1, x : 2 }"); } - [SkippableFact] + [Fact] public void TestFindAndModifyUpdateWithWriteConcernError() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -1248,7 +1248,7 @@ public void TestFindAndRemoveWithMaxTime() } } - [SkippableFact] + [Fact] public void TestFindAndRemoveWithWriteConcernError() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -1547,7 +1547,7 @@ public void TestFindWithinRectangle() // note: the hits are unordered } - [SkippableFact] + [Fact] public void TestFindWithMaxScan() { RequireServer.Check().VersionLessThan("4.1.0-"); @@ -1588,7 +1588,7 @@ private class Place } #pragma warning restore - [SkippableFact] + [Fact] public void TestGeoHaystackSearch() { RequireServer.Check().VersionLessThan("4.8.0"); @@ -1625,7 +1625,7 @@ public void TestGeoHaystackSearch() } } - [SkippableFact] + [Fact] public void TestGeoHaystackSearchWithMaxTime() { RequireServer.Check().VersionLessThan("4.8.0"); @@ -1659,7 +1659,7 @@ public void TestGeoHaystackSearchWithMaxTime() } } - [SkippableFact] + [Fact] public void TestGeoHaystackSearch_Typed() { RequireServer.Check().VersionLessThan("4.8.0"); @@ -1695,7 +1695,7 @@ public void TestGeoHaystackSearch_Typed() } } - [SkippableFact] + [Fact] public void TestGeoNear() { RequireServer.Check().Supports(Feature.GeoNearCommand); @@ -1742,7 +1742,7 @@ public void TestGeoNear() Assert.Equal("Coffee", place.Type); } - [SkippableFact] + [Fact] public void TestGeoNearGeneric() { RequireServer.Check().Supports(Feature.GeoNearCommand); @@ -1789,7 +1789,7 @@ public void TestGeoNearGeneric() Assert.Equal("Coffee", place.Type); } - [SkippableFact] + [Fact] public void TestGeoNearSphericalFalse() { RequireServer.Check().Supports(Feature.GeoNearCommand); @@ -1845,7 +1845,7 @@ public void TestGeoNearSphericalFalse() Assert.Equal("Coffee", hit2.RawDocument["Type"].AsString); } - [SkippableFact] + [Fact] public void TestGeoNearSphericalTrue() { RequireServer.Check().Supports(Feature.GeoNearCommand); @@ -1901,7 +1901,7 @@ public void TestGeoNearSphericalTrue() Assert.Equal("Coffee", hit2.RawDocument["Type"].AsString); } - [SkippableFact] + [Fact] public void TestGeoNearWithGeoJsonPoints() { RequireServer.Check().Supports(Feature.GeoNearCommand); @@ -1939,7 +1939,7 @@ public void TestGeoNearWithGeoJsonPoints() Assert.Equal("Coffee", hit2.Type); } - [SkippableFact] + [Fact] public void TestGeoNearWithMaxTime() { RequireServer.Check().Supports(Feature.GeoNearCommand); @@ -2032,7 +2032,7 @@ public void TestGetMore() _collection.FindAll().ToList(); } - [SkippableFact] + [Fact] public void TestGroupWithFinalizeFunction() { RequireServer.Check().Supports(Feature.GroupCommand); @@ -2062,7 +2062,7 @@ public void TestGroupWithFinalizeFunction() Assert.Equal(-3, results[2]["count"].ToInt32()); } - [SkippableFact] + [Fact] public void TestGroupWithKeyFields() { RequireServer.Check().Supports(Feature.GroupCommand); @@ -2091,7 +2091,7 @@ public void TestGroupWithKeyFields() Assert.Equal(3, results[2]["count"].ToInt32()); } - [SkippableFact] + [Fact] public void TestGroupWithKeyFunction() { RequireServer.Check().Supports(Feature.GroupCommand); @@ -2120,7 +2120,7 @@ public void TestGroupWithKeyFunction() Assert.Equal(3, results[2]["count"].ToInt32()); } - [SkippableFact] + [Fact] public void TestGroupWithMaxTime() { RequireServer.Check().Supports(Feature.GroupCommand); @@ -2147,7 +2147,7 @@ public void TestGroupWithMaxTime() } } - [SkippableFact] + [Fact] public void TestGroupWithQuery() { RequireServer.Check().Supports(Feature.GroupCommand); @@ -2256,7 +2256,7 @@ public void TestInsertBatchContinueOnError() Assert.Equal(3, collection.Count()); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void TestInsertBatchMultipleBatchesWriteConcernDisabledContinueOnErrorFalse( [Values(false, true)] bool retryWrites) @@ -2297,7 +2297,7 @@ public void TestInsertBatchContinueOnError() Assert.Equal(0, collection.Count(Query.EQ("_id", 5))); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void TestInsertBatchMultipleBatchesWriteConcernDisabledContinueOnErrorTrue( [Values(false, true)] bool retryWrites) @@ -2496,7 +2496,7 @@ public void TestInsertDuplicateKey() CheckExpectedResult(expectedResult, result); } - [SkippableFact] + [Fact] public void TestInsertWithWriteConcernError() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -2870,7 +2870,7 @@ public void TestMapReduceInlineWithQuery() } } - [SkippableFact] + [Fact] public void TestMapReduceWriteConcern() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -3023,7 +3023,7 @@ public void TestRemoveNoMatchingDocument() Assert.Equal(0, _collection.Count()); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void TestRemoveUnacknowledeged( [Values(false, true)] bool retryWrites) @@ -3044,7 +3044,7 @@ public void TestRemoveNoMatchingDocument() } } - [SkippableFact] + [Fact] public void TestRemoveWithWriteConcernError() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -3126,7 +3126,7 @@ public void TestGetStats() _collection.GetStats(); } - [SkippableFact] + [Fact] public void TestGetStatsNoPadding() { RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet).StorageEngine("mmapv1"); @@ -3144,7 +3144,7 @@ public void TestGetStatsNoPadding() Assert.True((stats.UserFlags & CollectionUserFlags.NoPadding) != 0); } - [SkippableFact] + [Fact] public void TestGetStatsUsePowerOf2Sizes() { RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet).StorageEngine("mmapv1"); @@ -3297,7 +3297,7 @@ public void TestUpdateNullQuery() Assert.Equal(2, _collection.Count()); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void TestUpdateUnacknowledged( [Values(false, true)] bool retryWrites) @@ -3321,7 +3321,7 @@ public void TestUpdateNullQuery() } } - [SkippableFact] + [Fact] public void TestUpdateWithWriteConcernError() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -3395,7 +3395,7 @@ public void TestUpsertDuplicateKey() }); } - [SkippableFact] + [Fact] public void TestValidate() { RequireServer.Check().StorageEngine("mmapv1"); diff --git a/tests/MongoDB.Driver.Legacy.Tests/MongoDatabaseTests.cs b/tests/MongoDB.Driver.Legacy.Tests/MongoDatabaseTests.cs index aee0bb74b94..1fe01451f27 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/MongoDatabaseTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/MongoDatabaseTests.cs @@ -18,7 +18,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver; using MongoDB.Driver.Builders; using MongoDB.Driver.Core; @@ -82,7 +82,7 @@ public void TestCreateCollection() Assert.True(_database.CollectionExists(collectionName)); } - [SkippableFact] + [Fact] public void TestCreateCollectionSetIndexOptionDefaults() { RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet); @@ -102,7 +102,7 @@ public void TestCreateCollectionSetIndexOptionDefaults() Assert.Equal(expectedIndexOptionDefaultsDocument, collectionInfo["options"]["indexOptionDefaults"]); } - [SkippableFact] + [Fact] public void TestCreateCollectionSetStorageEngine() { RequireServer.Check().VersionGreaterThanOrEqualTo("2.7.0"); @@ -125,7 +125,7 @@ public void TestCreateCollectionSetStorageEngine() Assert.Equal(storageEngineOptions, resultCollection["options"]["storageEngine"]); } - [SkippableFact] + [Fact] public void TestCreateCollectionSetValidator() { RequireServer.Check(); @@ -146,7 +146,7 @@ public void TestCreateCollectionSetValidator() Assert.Equal("strict", collectionInfo["options"]["validationLevel"].AsString); } - [SkippableFact] + [Fact] public void TestCreateCollectionWriteConcern() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -160,7 +160,7 @@ public void TestCreateCollectionWriteConcern() exception.Should().BeOfType(); } - [SkippableFact] + [Fact] public void TestCreateViewWriteConcern() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -189,7 +189,7 @@ public void TestDropCollection() Assert.False(_database.CollectionExists(collectionName)); } - [SkippableFact] + [Fact] public void TestDropCollectionWriteConcern() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -203,7 +203,7 @@ public void TestDropCollectionWriteConcern() exception.Should().BeOfType(); } - [SkippableFact] + [Fact] public void TestEvalNoArgs() { RequireServer.Check().Supports(Feature.Eval); @@ -217,7 +217,7 @@ public void TestEvalNoArgs() #pragma warning restore } - [SkippableFact] + [Fact] public void TestEvalNoArgsNoLock() { RequireServer.Check().Supports(Feature.Eval); @@ -231,7 +231,7 @@ public void TestEvalNoArgsNoLock() #pragma warning restore } - [SkippableFact] + [Fact] public void TestEvalWithMaxTime() { RequireServer.Check().Supports(Feature.Eval); @@ -255,7 +255,7 @@ public void TestEvalWithMaxTime() #pragma warning restore } - [SkippableFact] + [Fact] public void TestEvalWithOneArg() { RequireServer.Check().Supports(Feature.Eval); @@ -269,7 +269,7 @@ public void TestEvalWithOneArg() #pragma warning restore } - [SkippableFact] + [Fact] public void TestEvalWithOneArgNoLock() { RequireServer.Check().Supports(Feature.Eval); @@ -283,7 +283,7 @@ public void TestEvalWithOneArgNoLock() #pragma warning restore } - [SkippableFact] + [Fact] public void TestEvalWithTwoArgs() { RequireServer.Check().Supports(Feature.Eval); @@ -297,7 +297,7 @@ public void TestEvalWithTwoArgs() #pragma warning restore } - [SkippableFact] + [Fact] public void TestEvalWithTwoArgsNoLock() { RequireServer.Check().Supports(Feature.Eval); @@ -368,7 +368,7 @@ public void TestGetCollectionNames() Assert.Equal(new[] { "a", "b", "c" }, collectionNames.Where(n => n != "system.indexes")); } - [SkippableFact] + [Fact] public void TestGetCurrentOp() { RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet); @@ -452,7 +452,7 @@ public void TestRenameCollectionDropTarget() Assert.True(_database.CollectionExists(collectionName2)); } - [SkippableFact] + [Fact] public void TestRenameCollectionWriteConcern() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -505,7 +505,7 @@ public void TestSetProfilingLevel() } } - [SkippableTheory] + [Theory] [InlineData("user1", "pass1", true)] [InlineData("user2", "pass2", false)] public void TestUserMethods(string username, string password, bool isReadOnly) diff --git a/tests/MongoDB.Driver.Legacy.Tests/MongoServerTests.cs b/tests/MongoDB.Driver.Legacy.Tests/MongoServerTests.cs index 45d3053e446..42768187407 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/MongoServerTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/MongoServerTests.cs @@ -18,7 +18,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -109,7 +109,7 @@ public void TestDropDatabase() Assert.False(databaseNames.Contains(database.Name)); } - [SkippableFact] + [Fact] public void TestDropDatabaseWriteConcern() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); @@ -212,7 +212,7 @@ public void TestPrimary() Assert.True(instance.IsPrimary); } - [SkippableFact] + [Fact] public void TestReconnect() { RequireEnvironment.Check().EnvironmentVariable("EXPLICIT"); diff --git a/tests/MongoDB.Driver.Legacy.Tests/Operations/BulkWriteOperationTests.cs b/tests/MongoDB.Driver.Legacy.Tests/Operations/BulkWriteOperationTests.cs index 349730a6ae5..98f837697cc 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Operations/BulkWriteOperationTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Operations/BulkWriteOperationTests.cs @@ -17,7 +17,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Builders; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; @@ -40,7 +40,7 @@ public BulkWriteOperationTests() _collection = LegacyTestConfiguration.Database.GetCollection(GetType().Name); } - [SkippableFact] + [Fact] public void TestBatchSplittingBySizeWithErrorsOrdered() { RequirePlatform.Check().SkipWhen(SupportedOperatingSystem.MacOS); @@ -81,7 +81,7 @@ public void TestBatchSplittingBySizeWithErrorsOrdered() Assert.Equal(expectedDocuments, _collection.FindAll()); } - [SkippableFact] + [Fact] public void TestBatchSplittingBySizeWithErrorsUnordered() { RequirePlatform.Check().SkipWhen(SupportedOperatingSystem.MacOS); @@ -121,7 +121,7 @@ public void TestBatchSplittingBySizeWithErrorsUnordered() _collection.FindAll().Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(-1)] [InlineData(0)] [InlineData(1)] @@ -144,7 +144,7 @@ public void TestBatchSplittingDeletesNearMaxWriteBatchCount(int maxBatchCountDel Assert.Equal(0, _collection.Count()); } - [SkippableTheory] + [Theory] [InlineData(-1)] [InlineData(0)] [InlineData(1)] @@ -166,7 +166,7 @@ public void TestBatchSplittingInsertsNearMaxWriteBatchCount(int maxBatchCountDel Assert.Equal(count, _collection.Count()); } - [SkippableTheory] + [Theory] [InlineData(-1)] [InlineData(0)] [InlineData(1)] @@ -191,7 +191,7 @@ public void TestBatchSplittingUpdatesNearMaxWriteBatchCount(int maxBatchCountDel Assert.Equal(count, _collection.Count(Query.EQ("n", 1))); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestExecuteTwice(bool ordered) @@ -205,7 +205,7 @@ public void TestExecuteTwice(bool ordered) Assert.Throws(() => bulk.Execute()); } - [SkippableTheory] + [Theory] [InlineData(false, 0)] [InlineData(false, 1)] [InlineData(true, 0)] @@ -235,7 +235,7 @@ public void TestExecuteWithExplicitWriteConcern(bool ordered, int w) } } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestExecuteWithNoRequests(bool ordered) @@ -247,7 +247,7 @@ public void TestExecuteWithNoRequests(bool ordered) Assert.Throws(() => bulk.Execute()); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestFindAfterExecute(bool ordered) @@ -261,7 +261,7 @@ public void TestFindAfterExecute(bool ordered) Assert.Throws(() => bulk.Find(new QueryDocument())); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestFindWithNullQuery(bool ordered) @@ -273,7 +273,7 @@ public void TestFindWithNullQuery(bool ordered) Assert.Throws(() => bulk.Find(null)); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestInsertAfterExecute(bool ordered) @@ -287,7 +287,7 @@ public void TestInsertAfterExecute(bool ordered) Assert.Throws(() => bulk.Insert(new BsonDocument())); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestInsertDollarPrefixedKeyRejectedPre50(bool ordered) @@ -301,7 +301,7 @@ public void TestInsertDollarPrefixedKeyRejectedPre50(bool ordered) Assert.Throws>(() => bulk.Execute()); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestInsertDollarPrefixedKeyAcceptedPost50(bool ordered) @@ -322,7 +322,7 @@ public void TestInsertDollarPrefixedKeyAcceptedPost50(bool ordered) _collection.FindAll().Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestInsertMultipleDocuments(bool ordered) @@ -350,7 +350,7 @@ public void TestInsertMultipleDocuments(bool ordered) _collection.FindAll().Should().BeEquivalentTo(documents); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestInsertOneDocument(bool ordered) @@ -371,7 +371,7 @@ public void TestInsertOneDocument(bool ordered) _collection.FindAll().Should().BeEquivalentTo(new[] { document }); } - [SkippableFact] + [Fact] public void TestMixedOperationsOrdered() { RequirePlatform.Check().SkipWhen(SupportedOperatingSystem.MacOS); @@ -411,7 +411,7 @@ public void TestMixedOperationsOrdered() _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableFact] + [Fact] public void TestMixedOperationsUnordered() { RequirePlatform.Check().SkipWhen(SupportedOperatingSystem.MacOS); @@ -453,7 +453,7 @@ public void TestMixedOperationsUnordered() _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableFact] + [Fact] public void TestMixedUpsertsOrdered() { RequirePlatform.Check().SkipWhen(SupportedOperatingSystem.MacOS); @@ -482,7 +482,7 @@ public void TestMixedUpsertsOrdered() _collection.FindAll().Should().BeEquivalentTo(expectedDocuments); } - [SkippableFact] + [Fact] public void TestMixedUpsertsUnordered() { RequirePlatform.Check().SkipWhen(SupportedOperatingSystem.MacOS); @@ -511,7 +511,7 @@ public void TestMixedUpsertsUnordered() _collection.FindAll().Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestNonDefaultWriteConcern(bool ordered) @@ -534,7 +534,7 @@ public void TestNonDefaultWriteConcern(bool ordered) Assert.Equal(0, _collection.Count()); } - [SkippableFact] + [Fact] public void TestOrderedBatchWithErrors() { RequirePlatform.Check().SkipWhen(SupportedOperatingSystem.MacOS); @@ -579,7 +579,7 @@ public void TestOrderedBatchWithErrors() _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestRemoveMultiple(bool ordered) @@ -610,7 +610,7 @@ public void TestRemoveMultiple(bool ordered) _collection.FindAll().Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestRemoveOneOnlyRemovesOneDocument(bool ordered) @@ -632,7 +632,7 @@ public void TestRemoveOneOnlyRemovesOneDocument(bool ordered) _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestRemoveWithEmptyQueryRemovesAllDocuments(bool ordered) @@ -653,7 +653,7 @@ public void TestRemoveWithEmptyQueryRemovesAllDocuments(bool ordered) Assert.Equal(0, _collection.Count()); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestRemoveWithQueryRemovesOnlyMatchingDocuments(bool ordered) @@ -675,7 +675,7 @@ public void TestRemoveWithQueryRemovesOnlyMatchingDocuments(bool ordered) _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestReplaceOneKeyValidation(bool ordered) @@ -692,7 +692,7 @@ public void TestReplaceOneKeyValidation(bool ordered) Assert.Throws(() => bulk.Execute()); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestReplaceOneWithMultipleMatchingDocuments(bool ordered) @@ -724,7 +724,7 @@ public void TestReplaceOneWithMultipleMatchingDocuments(bool ordered) _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableFact] + [Fact] public void TestUnorderedBatchWithErrors() { RequirePlatform.Check().SkipWhen(SupportedOperatingSystem.MacOS); @@ -775,7 +775,7 @@ public void TestUnorderedBatchWithErrors() _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpdateChecksThatAllTopLevelFieldNamesAreOperators(bool ordered) @@ -790,7 +790,7 @@ public void TestUpdateChecksThatAllTopLevelFieldNamesAreOperators(bool ordered) Assert.Throws(() => bulk.Execute()); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpdateOneBasic(bool ordered) @@ -821,7 +821,7 @@ public void TestUpdateOneBasic(bool ordered) _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpdateOneKeyValidation(bool ordered) @@ -844,7 +844,7 @@ public void TestUpdateOneKeyValidation(bool ordered) } } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpdateOnlyAffectsDocumentsThatMatch(bool ordered) @@ -878,7 +878,7 @@ public void TestUpdateOnlyAffectsDocumentsThatMatch(bool ordered) _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpdateUpdatesAllMatchingDocuments(bool ordered) @@ -909,7 +909,7 @@ public void TestUpdateUpdatesAllMatchingDocuments(bool ordered) _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpsertOneVeryLargeDocument(bool ordered) @@ -937,7 +937,7 @@ public void TestUpsertOneVeryLargeDocument(bool ordered) _collection.FindAll().Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpsertReplaceOneDoesNotAffectNonUpsertsInTheSameOperation(bool ordered) @@ -963,7 +963,7 @@ public void TestUpsertReplaceOneDoesNotAffectNonUpsertsInTheSameOperation(bool o _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpsertReplaceOneOnlyReplacesOneMatchingDocument(bool ordered) @@ -995,7 +995,7 @@ public void TestUpsertReplaceOneOnlyReplacesOneMatchingDocument(bool ordered) _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpsertUpdateOneDoesNotAffectNonUpsertsInTheSameOperation(bool ordered) @@ -1036,7 +1036,7 @@ public void TestUpsertUpdateOneDoesNotAffectNonUpsertsInTheSameOperation(bool or _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpsertUpdateOneOnlyAffectsOneMatchingDocument(bool ordered) @@ -1067,7 +1067,7 @@ public void TestUpsertUpdateOneOnlyAffectsOneMatchingDocument(bool ordered) _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpsertUpdateUpsertsAndDoesNotAffectNonUpsertsInTheSameOperation(bool ordered) @@ -1108,7 +1108,7 @@ public void TestUpsertUpdateUpsertsAndDoesNotAffectNonUpsertsInTheSameOperation( _collection.FindAll().SetFields(Fields.Exclude("_id")).Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpsertWithMultipleMatchingDocuments(bool ordered) @@ -1141,7 +1141,7 @@ public void TestUpsertWithMultipleMatchingDocuments(bool ordered) _collection.FindAll().Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpsertWithNoMatchingDocument(bool ordered) @@ -1174,7 +1174,7 @@ public void TestUpsertWithNoMatchingDocument(bool ordered) _collection.FindAll().Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestUpsertWithOneMatchingDocument(bool ordered) @@ -1207,7 +1207,7 @@ public void TestUpsertWithOneMatchingDocument(bool ordered) _collection.FindAll().Should().BeEquivalentTo(expectedDocuments); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void TestW0DoesNotReportErrors( [Values(false, true)] bool retryWrites, @@ -1242,7 +1242,7 @@ public void TestUpsertWithOneMatchingDocument(bool ordered) } } - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void TestW2AgainstStandalone(bool ordered) @@ -1263,7 +1263,7 @@ public void TestW2AgainstStandalone(bool ordered) } } - [SkippableFact] + [Fact] public void TestWTimeoutPlusDuplicateKeyError() { RequireEnvironment.Check().EnvironmentVariable("EXPLICIT"); diff --git a/tests/MongoDB.Driver.Legacy.Tests/Operations/CurrentOpOperationTests.cs b/tests/MongoDB.Driver.Legacy.Tests/Operations/CurrentOpOperationTests.cs index 542494dc6d0..66a1b0ae6a5 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Operations/CurrentOpOperationTests.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Operations/CurrentOpOperationTests.cs @@ -16,7 +16,7 @@ using System; using System.Threading.Tasks; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Misc; @@ -57,7 +57,7 @@ public void constructor_should_throw_when_databaseNamespace_is_null() action.ShouldThrow().And.ParamName.Should().Be("databaseNamespace"); } - [SkippableFact] + [Fact] public void Execute_should_return_expected_result() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Legacy.Tests/Operations/CurrentOpUsingCommandOperation.cs b/tests/MongoDB.Driver.Legacy.Tests/Operations/CurrentOpUsingCommandOperation.cs index 769139d3ffe..715cce000cf 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Operations/CurrentOpUsingCommandOperation.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Operations/CurrentOpUsingCommandOperation.cs @@ -18,7 +18,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Misc; @@ -72,7 +72,7 @@ public void CreateOperation_should_return_expected_result() result.ResultSerializer.Should().BeSameAs(BsonDocumentSerializer.Instance); } - [SkippableFact] + [Fact] public void Execute_should_return_expected_result() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Legacy.Tests/Properties/AssemblyInfo.cs b/tests/MongoDB.Driver.Legacy.Tests/Properties/AssemblyInfo.cs index 3aba0e8f41b..d0af98a9d42 100644 --- a/tests/MongoDB.Driver.Legacy.Tests/Properties/AssemblyInfo.cs +++ b/tests/MongoDB.Driver.Legacy.Tests/Properties/AssemblyInfo.cs @@ -14,11 +14,11 @@ */ using System.Runtime.InteropServices; -using MongoDB.Driver.Core.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; [assembly: ComVisible(false)] [assembly: CollectionBehavior(DisableTestParallelization = true)] -[assembly: TestFramework(XunitExtensionsConsts.TimeoutEnforcingXunitFramework, XunitExtensionsConsts.TimeoutEnforcingFrameworkAssembly)] +[assembly: TestFramework(XunitExtensionsConstants.TimeoutEnforcingXunitFramework, XunitExtensionsConstants.TimeoutEnforcingFrameworkAssembly)] diff --git a/tests/MongoDB.Driver.Tests/AggregateFluentBucketAutoTests.cs b/tests/MongoDB.Driver.Tests/AggregateFluentBucketAutoTests.cs index d2e0755f75e..dbf467c6c42 100644 --- a/tests/MongoDB.Driver.Tests/AggregateFluentBucketAutoTests.cs +++ b/tests/MongoDB.Driver.Tests/AggregateFluentBucketAutoTests.cs @@ -84,7 +84,7 @@ public void BucketAuto_should_add_expected_stage() renderedStage.Document.Should().Be("{ $bucketAuto : { groupBy : \"$year\", buckets : 4 } }"); } - [SkippableFact] + [Fact] public void BucketAuto_should_return_expected_result() { RequireServer.Check(); @@ -120,7 +120,7 @@ public void BucketAuto_with_granularity_should_add_expected_stage() renderedStage.Document.Should().Be("{ $bucketAuto : { groupBy : \"$_id\", buckets : 4, granularity : 'POWERSOF2' } }"); } - [SkippableFact] + [Fact] public void BucketAuto_with_granularity_should_return_expected_result() { RequireServer.Check(); @@ -156,7 +156,7 @@ public void BucketAuto_with_output_should_add_expected_stage() renderedStage.Document.Should().Be("{ $bucketAuto : { groupBy : \"$year\", buckets : 4, output : { years : { $push : \"$year\" }, count : { $sum : 1 } } } }"); } - [SkippableFact] + [Fact] public void BucketAuto_with_output_should_return_expected_result() { RequireServer.Check(); @@ -192,7 +192,7 @@ public void BucketAuto_typed_should_add_expected_stage() renderedStage.Document.Should().Be("{ $bucketAuto : { groupBy : \"$year\", buckets : 4 } }"); } - [SkippableFact] + [Fact] public void BucketAuto_typed_should_return_expected_result() { RequireServer.Check(); @@ -230,7 +230,7 @@ public void BucketAuto_typed_with_output_should_add_expected_stage() renderedStage.Document.Should().Be("{ $bucketAuto : { groupBy : \"$year\", buckets : 4, output : { Years : { $push : \"$year\" }, Count : { $sum : 1 } } } }"); } - [SkippableFact] + [Fact] public void BucketAuto_typed_with_output_should_return_expected_result() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/AggregateFluentBucketTests.cs b/tests/MongoDB.Driver.Tests/AggregateFluentBucketTests.cs index 7e11b5594b2..f1c0c27205a 100644 --- a/tests/MongoDB.Driver.Tests/AggregateFluentBucketTests.cs +++ b/tests/MongoDB.Driver.Tests/AggregateFluentBucketTests.cs @@ -86,7 +86,7 @@ public void Bucket_should_add_expected_stage() renderedStage.Document.Should().Be("{ $bucket : { groupBy : \"$year\", boundaries : [ 1900, 1920, 1950 ], default : \"Unknown\" } }"); } - [SkippableFact] + [Fact] public void Bucket_should_return_expected_result() { RequireServer.Check(); @@ -123,7 +123,7 @@ public void Bucket_with_output_should_add_expected_stage() renderedStage.Document.Should().Be("{ $bucket : { groupBy : \"$year\", boundaries : [ 1900, 1920, 1950 ], default : \"Unknown\", output : { years : { $push : \"$year\" }, count : { $sum : 1 } } } }"); } - [SkippableFact] + [Fact] public void Bucket_with_output_should_return_expected_result() { RequireServer.Check(); @@ -160,7 +160,7 @@ public void Bucket_typed_should_add_expected_stage() renderedStage.Document.Should().Be("{ $bucket : { groupBy : \"$year\", boundaries : [ 1900, 1920, 1950 ], default : \"Unknown\" } }"); } - [SkippableFact] + [Fact] public void Bucket_typed_should_return_expected_result() { RequireServer.Check(); @@ -200,7 +200,7 @@ public void Bucket_typed_with_output_should_add_expected_stage() renderedStage.Document.Should().Be("{ $bucket : { groupBy : \"$year\", boundaries : [ 1900, 1920, 1950 ], default : \"Unknown\", output : { Years : { $push : \"$year\" }, Count : { $sum : 1 } } } }"); } - [SkippableFact] + [Fact] public void Bucket_typed_with_output_should_return_expected_result() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/AggregateFluentFacetTests.cs b/tests/MongoDB.Driver.Tests/AggregateFluentFacetTests.cs index f6898679aba..68b67c2c854 100644 --- a/tests/MongoDB.Driver.Tests/AggregateFluentFacetTests.cs +++ b/tests/MongoDB.Driver.Tests/AggregateFluentFacetTests.cs @@ -96,7 +96,7 @@ public void Facet_with_1_facet_should_add_the_expected_stage() }"); } - [SkippableFact] + [Fact] public void Facet_with_1_facet_should_return_expected_result() { RequireServer.Check(); @@ -159,7 +159,7 @@ public void Facet_with_2_facets_should_add_the_expected_stage() }"); } - [SkippableFact] + [Fact] public void Facet_with_2_facets_should_return_expected_result() { RequireServer.Check(); @@ -237,7 +237,7 @@ public void Facet_with_3_facets_should_add_the_expected_stage() }"); } - [SkippableFact] + [Fact] public void Facet_with_3_facets_should_return_expected_result() { RequireServer.Check(); @@ -310,7 +310,7 @@ public void Facet_typed_with_1_facet_should_add_the_expected_stage() }"); } - [SkippableFact] + [Fact] public void Facet_typed_with_1_facet_should_return_expected_result() { RequireServer.Check(); @@ -374,7 +374,7 @@ public void Facet_typed_with_2_facets_should_add_the_expected_stage() }"); } - [SkippableFact] + [Fact] public void Facet_typed_with_2_facets_should_return_expected_result() { RequireServer.Check(); @@ -453,7 +453,7 @@ public void Facet_typed_with_3_facets_should_add_the_expected_stage() }"); } - [SkippableFact] + [Fact] public void Facet_typed_with_3_facets_should_return_expected_result() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/AggregateFluentGraphLookupWithAirportsCollectionTests.cs b/tests/MongoDB.Driver.Tests/AggregateFluentGraphLookupWithAirportsCollectionTests.cs index 354ecbc9d42..e421cef7c7e 100644 --- a/tests/MongoDB.Driver.Tests/AggregateFluentGraphLookupWithAirportsCollectionTests.cs +++ b/tests/MongoDB.Driver.Tests/AggregateFluentGraphLookupWithAirportsCollectionTests.cs @@ -110,7 +110,7 @@ public void GraphLookup_should_add_expected_stage() }"); } - [SkippableFact] + [Fact] public void GraphLookup_should_return_expected_result() { RequireServer.Check(); @@ -190,7 +190,7 @@ public void GraphLookup_typed_should_add_expected_stage() }"); } - [SkippableFact] + [Fact] public void GraphLookup_typed_should_return_expected_result() { RequireServer.Check(); @@ -268,7 +268,7 @@ public void GraphLookup_typed_with_array_valued_start_with_should_add_expected_s }"); } - [SkippableFact] + [Fact] public void GraphLookup_typed_with_array_valued_start_with_should_return_expected_result() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/AggregateFluentGraphLookupWithEmployeeCollectionTests.cs b/tests/MongoDB.Driver.Tests/AggregateFluentGraphLookupWithEmployeeCollectionTests.cs index 2eaae36ef88..0a8885ca701 100644 --- a/tests/MongoDB.Driver.Tests/AggregateFluentGraphLookupWithEmployeeCollectionTests.cs +++ b/tests/MongoDB.Driver.Tests/AggregateFluentGraphLookupWithEmployeeCollectionTests.cs @@ -95,7 +95,7 @@ public void GraphLookup_should_add_expected_stage() }"); } - [SkippableFact] + [Fact] public void GraphLookup_should_return_expected_result() { RequireServer.Check(); @@ -150,7 +150,7 @@ public void GraphLookup_with_restrictSearchWithMatch_should_add_expected_stage() }"); } - [SkippableFact] + [Fact] public void GraphLookup_with_restrictSearchWithMatch_should_return_expected_result() { RequireServer.Check(); @@ -205,7 +205,7 @@ public void GraphLookup_with_expressions_should_add_expected_stage() }"); } - [SkippableFact] + [Fact] public void GraphLookup_with_expressions_should_return_expected_result() { RequireServer.Check(); @@ -252,7 +252,7 @@ public void GraphLookup_untyped_based_should_add_expected_stage() }"); } - [SkippableFact] + [Fact] public void GraphLookup_untyped_based_should_return_expected_result() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/AggregateFluentTests.cs b/tests/MongoDB.Driver.Tests/AggregateFluentTests.cs index b6bd0f88e0a..5f538d76e00 100644 --- a/tests/MongoDB.Driver.Tests/AggregateFluentTests.cs +++ b/tests/MongoDB.Driver.Tests/AggregateFluentTests.cs @@ -18,7 +18,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using Moq; @@ -165,7 +165,7 @@ public void ChangeStream_should_add_the_expected_stage_when_options_is_null() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Count_should_return_the_expected_result( [Values(false, true)] @@ -196,7 +196,7 @@ public void ChangeStream_should_add_the_expected_stage_when_options_is_null() result.Should().Be(1); } - [SkippableFact] + [Fact] public void Function_should_return_expected_result() { RequireServer.Check().Supports(Feature.AggregateFunction); @@ -262,7 +262,7 @@ public void Function_should_return_expected_result() result[2].Should().Be("{ _id : 3, name : 'Mrs. Eppie Delta', scores : [ 9, 8, 8 ], isFound : false, message : 'Hello Mrs. Eppie Delta. Your total score is 25.' }"); } - [SkippableFact] + [Fact] public void Group_with_accumulator_should_return_expected_result() { RequireServer.Check().Supports(Feature.AggregateAccumulator); @@ -315,7 +315,7 @@ public void Group_with_accumulator_should_return_expected_result() result[1].Should().Be("{ _id : 'Homer', minCopies : 10, avgCopies : 10.0, maxCopies : 10 }"); } - [SkippableFact] + [Fact] public void Lookup_with_let_and_bsondocuments_params_should_return_the_expected_result() { RequireServer.Check(); @@ -413,7 +413,7 @@ public class StockData public int Instock { get; set; } } - [SkippableFact] + [Fact] public void Lookup_with_let_should_return_the_expected_result() { RequireServer.Check(); @@ -481,7 +481,7 @@ public void Lookup_with_let_should_return_the_expected_result() result[2].Should().Be("{ 'item' : 'cookies', 'price' : 10, 'ordered' : 60, 'stockdata' : [{ 'instock' : 80 }] }"); } - [SkippableFact] + [Fact] public void Lookup_with_let_and_mismatched_pipeline_condition_should_return_the_expected_result() { RequireServer.Check(); @@ -548,7 +548,7 @@ public void Lookup_with_let_and_mismatched_pipeline_condition_should_return_the_ result[2].Should().Be("{ 'item' : 'cookies', 'price' : 10, 'ordered' : 60, 'stockdata' : [] }"); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Lookup_without_let_should_return_the_expected_result([Values(null, "{}")] string emptyLetValue) { @@ -1229,7 +1229,7 @@ public class ItemResult public string Name { get; set; } } - [SkippableFact] + [Fact] public void UnionWith_with_different_schemas_and_projection_should_return_the_expected_result() { RequireServer.Check().Supports(Feature.AggregateUnionWith); diff --git a/tests/MongoDB.Driver.Tests/AggregateGraphLookupEnumerableFromOrToTests.cs b/tests/MongoDB.Driver.Tests/AggregateGraphLookupEnumerableFromOrToTests.cs index 1af563945fe..fee02d81a62 100644 --- a/tests/MongoDB.Driver.Tests/AggregateGraphLookupEnumerableFromOrToTests.cs +++ b/tests/MongoDB.Driver.Tests/AggregateGraphLookupEnumerableFromOrToTests.cs @@ -25,7 +25,7 @@ namespace MongoDB.Driver.Tests public class AggregateGraphLookupEnumerableFromOrToTests { // public methods - [SkippableFact] + [Fact] public void GraphLookup_with_many_to_one_parameters_should_return_expected_result() { RequireServer.Check(); @@ -66,7 +66,7 @@ public void GraphLookup_with_many_to_one_parameters_should_return_expected_resul result[1].ToBsonDocument().Should().Be(expectedResult[1].ToBsonDocument()); } - [SkippableFact] + [Fact] public void GraphLookup_with_one_to_many_parameters_should_return_expected_result() { RequireServer.Check(); @@ -107,7 +107,7 @@ public void GraphLookup_with_one_to_many_parameters_should_return_expected_resul result[1].ToBsonDocument().Should().Be(expectedResult[1].ToBsonDocument()); } - [SkippableFact] + [Fact] public void GraphLookup_with_one_to_one_parameters_should_return_expected_result() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/AsyncCursorTests.cs b/tests/MongoDB.Driver.Tests/AsyncCursorTests.cs index de6c749b949..66600b03cf9 100644 --- a/tests/MongoDB.Driver.Tests/AsyncCursorTests.cs +++ b/tests/MongoDB.Driver.Tests/AsyncCursorTests.cs @@ -20,7 +20,7 @@ using FluentAssertions.Common; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Events; using MongoDB.Driver.Core.Misc; @@ -33,7 +33,7 @@ namespace MongoDB.Driver.Tests public class AsyncCursorTests { //public methods - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Cursor_should_not_throw_exception_after_double_close([Values(false, true)] bool async) { @@ -60,7 +60,7 @@ public void Cursor_should_not_throw_exception_after_double_close([Values(false, } } - [SkippableFact] + [Fact] public void KillCursor_should_actually_work() { RequireServer.Check(); @@ -91,7 +91,7 @@ public void KillCursor_should_actually_work() } } - [SkippableFact] + [Fact] public void Tailable_cursor_should_be_able_to_be_cancelled_from_a_different_thread_with_expected_result() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/AuthenticationTests.cs b/tests/MongoDB.Driver.Tests/AuthenticationTests.cs index e37b805fb41..f8ae926047e 100644 --- a/tests/MongoDB.Driver.Tests/AuthenticationTests.cs +++ b/tests/MongoDB.Driver.Tests/AuthenticationTests.cs @@ -19,7 +19,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters.ServerSelectors; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -32,7 +32,7 @@ namespace MongoDB.Driver.Tests /// public class AuthenticationTests { - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Authentication_fails_when_user_has_Scram_Sha_1_mechanism_and_mechanism_is_Scram_Sha_256( [Values(false, true)] bool async) @@ -51,7 +51,7 @@ public class AuthenticationTests AssertAuthenticationFails(settings, async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Authentication_fails_when_user_has_Scram_Sha_256_mechanism_and_mechanism_is_Scram_Sha_1( [Values(false, true)] bool async) @@ -69,7 +69,7 @@ public class AuthenticationTests AssertAuthenticationFails(settings, async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Authentication_fails_when_user_is_non_extant_and_mechanism_is_not_specified( [Values(false, true)] bool async) @@ -86,7 +86,7 @@ public class AuthenticationTests AssertAuthenticationFails(settings, async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Authentication_succeeds_when_user_has_both_Scram_Sha_mechanisms_and_mechanism_is_not_specified( [Values(false, true)] bool async) @@ -104,7 +104,7 @@ public class AuthenticationTests AssertAuthenticationSucceeds(settings, async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Authentication_succeeds_when_user_has_both_scram_sha_mechanisms_and_mechanism_is_Scram_Sha_256( [Values(false, true)] bool async) @@ -122,7 +122,7 @@ public class AuthenticationTests AssertAuthenticationSucceeds(settings, async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Authentication_succeeds_when_user_has_Scram_Sha_1_Mechanism_and_mechanism_is_not_specified( [Values(false, true)] bool async) @@ -141,7 +141,7 @@ public class AuthenticationTests AssertAuthenticationSucceeds(settings, async, speculativeAuthenticatationShouldSucceedIfPossible: false); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Authentication_succeeds_when_user_has_Scram_Sha_256_mechanism_and_mechanism_is_not_specified( [Values(false, true)] bool async) @@ -159,7 +159,7 @@ public class AuthenticationTests AssertAuthenticationSucceeds(settings, async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Authentication_succeeds_when_user_has_Scram_Sha_1_mechanism_and_mechanism_is_Scram_Sha_1( [Values(false, true)] bool async) @@ -178,7 +178,7 @@ public class AuthenticationTests AssertAuthenticationSucceeds(settings, async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Authentication_succeeds_when_user_has_Scram_Sha_256_mechanism_and_mechanism_is_Scram_Sha_256( [Values(false, true)] bool async) @@ -195,7 +195,7 @@ public class AuthenticationTests AssertAuthenticationSucceeds(settings, async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Authentication_succeeds_when_user_has_multiple_credentials_and_mechanism_is_not_specified( [Values(false, true)] bool async) @@ -222,7 +222,7 @@ public class AuthenticationTests AssertAuthenticationSucceeds(settings, async); } - [SkippableTheory] + [Theory] [InlineData("IX", "IX", "\u2168", "\u2163", false)] // "IX", "IX", Roman numeral nine, Roman numeral four [InlineData("IX", "IX", "\u2168", "\u2163", true)] // "IX", "IX", Roman numeral nine, Roman numeral four public void Authentication_succeeds_with_Ascii_username_and_Ascii_password_when_SaslPrep_equivalent_username_exists( @@ -245,7 +245,7 @@ public class AuthenticationTests AssertAuthenticationSucceeds(settings, async); } - [SkippableTheory] + [Theory] [InlineData("IX", "IX", "I\u00ADX", "\u2168", "\u2163", false)] // "IX", "IX", "I-X", Roman numeral nine, Roman numeral four [InlineData("IX", "IX", "I\u00ADX", "\u2168", "\u2163", true)] // "IX", "IX", "I-X", Roman numeral nine, Roman numeral four public void Authentication_succeeds_with_Ascii_username_and_nonSaslPrepped_password_when_SaslPrep_equivalent_username_exists( @@ -269,7 +269,7 @@ public class AuthenticationTests AssertAuthenticationSucceeds(settings, async); } - [SkippableTheory] + [Theory] [InlineData("IX", "IX", "\u2168", "\u2163", "I\u00ADV", false)] // "IX", "IX", Roman numeral nine, Roman numeral four, I-V [InlineData("IX", "IX", "\u2168", "\u2163", "I\u00ADV", true)] // "IX", "IX", Roman numeral nine, Roman numeral four, I-V public void Authentication_succeeds_with_Unicode_username_and_nonSaslPrepped_password_when_SaslPrep_equivalent_username_exists( @@ -293,7 +293,7 @@ public class AuthenticationTests AssertAuthenticationSucceeds(settings, async); } - [SkippableTheory] + [Theory] [InlineData("IX", "IX", "\u2168", "\u2163", false)] // "IX", "IX", Roman numeral nine, Roman numeral four [InlineData("IX", "IX", "\u2168", "\u2163", true)] // "IX", "IX", Roman numeral nine, Roman numeral four public void Authentication_succeeds_with_Unicode_username_and_Unicode_password_when_SaslPrep_equivalent_username_exists( @@ -316,7 +316,7 @@ public class AuthenticationTests AssertAuthenticationSucceeds(settings, async); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Authentication_succeeds_with_MONGODB_X509_mechanism( [Values(false, true)] bool async) diff --git a/tests/MongoDB.Driver.Tests/CausalConsistencyTests.cs b/tests/MongoDB.Driver.Tests/CausalConsistencyTests.cs index 6bf8e3a34af..d321e7a377e 100644 --- a/tests/MongoDB.Driver.Tests/CausalConsistencyTests.cs +++ b/tests/MongoDB.Driver.Tests/CausalConsistencyTests.cs @@ -19,7 +19,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Events; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -30,7 +30,7 @@ namespace MongoDB.Driver.Tests { public class CausalConsistencyTests { - [SkippableFact] + [Fact] public void OperationTime_should_have_no_value_on_a_newly_created_ClientSession() { RequireServer.Check().SupportsCausalConsistency(); @@ -42,7 +42,7 @@ public void OperationTime_should_have_no_value_on_a_newly_created_ClientSession( } } - [SkippableFact] + [Fact] public void AfterClusterTime_should_be_empty_on_the_first_operation() { RequireServer.Check().SupportsCausalConsistency(); @@ -62,7 +62,7 @@ public void AfterClusterTime_should_be_empty_on_the_first_operation() } } - [SkippableFact] + [Fact] public void Session_OperationTime_should_get_updated_after_an_operation() { RequireServer.Check().SupportsCausalConsistency(); @@ -87,7 +87,7 @@ public void Session_OperationTime_should_get_updated_after_an_operation() } } - [SkippableFact] + [Fact] public void AfterClusterTime_should_be_sent_after_the_first_read_operation() { RequireServer.Check().SupportsCausalConsistency(); @@ -117,7 +117,7 @@ public void AfterClusterTime_should_be_sent_after_the_first_read_operation() } } - [SkippableFact] + [Fact] public void AfterClusterTime_should_be_sent_after_the_first_write_operation() { RequireServer.Check().SupportsCausalConsistency(); @@ -147,7 +147,7 @@ public void AfterClusterTime_should_be_sent_after_the_first_write_operation() } } - [SkippableFact] + [Fact] public void AfterClusterTime_should_not_be_sent_when_the_session_is_not_causally_consistent() { RequireServer.Check().SupportsCausalConsistency(); @@ -168,7 +168,7 @@ public void AfterClusterTime_should_not_be_sent_when_the_session_is_not_causally } } - [SkippableFact] + [Fact] public void ReadConcern_should_not_include_level_when_using_the_server_default() { RequireServer.Check().SupportsCausalConsistency(); @@ -194,7 +194,7 @@ public void ReadConcern_should_not_include_level_when_using_the_server_default() } } - [SkippableFact] + [Fact] public void ReadConcern_should_include_level_when_not_using_the_server_default() { RequireServer.Check().SupportsCausalConsistency(); diff --git a/tests/MongoDB.Driver.Tests/ClientSessionHandleTests.cs b/tests/MongoDB.Driver.Tests/ClientSessionHandleTests.cs index 086587149fa..153d66eb3f2 100644 --- a/tests/MongoDB.Driver.Tests/ClientSessionHandleTests.cs +++ b/tests/MongoDB.Driver.Tests/ClientSessionHandleTests.cs @@ -20,7 +20,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; diff --git a/tests/MongoDB.Driver.Tests/ClientSessionOptionsTests.cs b/tests/MongoDB.Driver.Tests/ClientSessionOptionsTests.cs index ea13f0cddd9..b6282ba7932 100644 --- a/tests/MongoDB.Driver.Tests/ClientSessionOptionsTests.cs +++ b/tests/MongoDB.Driver.Tests/ClientSessionOptionsTests.cs @@ -14,7 +14,7 @@ */ using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests diff --git a/tests/MongoDB.Driver.Tests/ClusterKeyTests.cs b/tests/MongoDB.Driver.Tests/ClusterKeyTests.cs index c89db0ede76..69a124096f3 100644 --- a/tests/MongoDB.Driver.Tests/ClusterKeyTests.cs +++ b/tests/MongoDB.Driver.Tests/ClusterKeyTests.cs @@ -19,7 +19,7 @@ using System.Security.Authentication; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Compression; using MongoDB.Driver.Core.Configuration; diff --git a/tests/MongoDB.Driver.Tests/ClusterTests.cs b/tests/MongoDB.Driver.Tests/ClusterTests.cs index 2ea15f99abd..194e0219f0a 100644 --- a/tests/MongoDB.Driver.Tests/ClusterTests.cs +++ b/tests/MongoDB.Driver.Tests/ClusterTests.cs @@ -21,7 +21,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; @@ -62,7 +62,7 @@ public ClusterTests(ITestOutputHelper output) : base(output) /// Test that starting a new transaction on a pinned ClientSession unpins the /// session and normal server selection is performed for the next operation. /// - [SkippableTheory] + [Theory] [ParameterAttributeData] public void SelectServer_loadbalancing_prose_test([Values(false, true)] bool async) { diff --git a/tests/MongoDB.Driver.Tests/Communication/Security/AwsAuthenticationTests.cs b/tests/MongoDB.Driver.Tests/Communication/Security/AwsAuthenticationTests.cs index 4757e6c0d87..cde9bd5b544 100644 --- a/tests/MongoDB.Driver.Tests/Communication/Security/AwsAuthenticationTests.cs +++ b/tests/MongoDB.Driver.Tests/Communication/Security/AwsAuthenticationTests.cs @@ -18,7 +18,7 @@ using Amazon.Runtime.CredentialManagement; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests.Communication.Security @@ -38,7 +38,7 @@ namespace MongoDB.Driver.Tests.Communication.Security [Trait("Category", "AwsMechanism")] public class AwsAuthenticationTests { - [SkippableFact] + [Fact] public void Aws_authentication_should_should_have_expected_result() { RequireEnvironment.Check().EnvironmentVariable("AWS_TESTS_ENABLED"); @@ -65,7 +65,7 @@ public void Ecs_should_fill_AWS_CONTAINER_CREDENTIALS_RELATIVE_URI() (awsContainerUri != null).Should().Be(isEcs); } - [SkippableFact] + [Fact] public void AwsSdk_should_support_all_required_handlers() { var credentialsGeneratorsDelegatesEnumerator = FallbackCredentialsFactory.CredentialsGenerators.GetEnumerator(); diff --git a/tests/MongoDB.Driver.Tests/Communication/Security/GssapiAuthenticationTests.cs b/tests/MongoDB.Driver.Tests/Communication/Security/GssapiAuthenticationTests.cs index 54f34af7952..1781b522cd4 100644 --- a/tests/MongoDB.Driver.Tests/Communication/Security/GssapiAuthenticationTests.cs +++ b/tests/MongoDB.Driver.Tests/Communication/Security/GssapiAuthenticationTests.cs @@ -16,7 +16,7 @@ using System; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests.Communication.Security @@ -27,7 +27,7 @@ public class GssapiAuthenticationTests { private static readonly string __collectionName = "test"; - [SkippableFact] + [Fact] public void TestNoCredentials() { RequireEnvironment.Check().EnvironmentVariable("GSSAPI_TESTS_ENABLED"); @@ -44,7 +44,7 @@ public void TestNoCredentials() } - [SkippableFact] + [Fact] public void TestSuccessfulAuthentication() { RequireEnvironment.Check().EnvironmentVariable("GSSAPI_TESTS_ENABLED"); @@ -60,7 +60,7 @@ public void TestSuccessfulAuthentication() result.Should().NotBeNull(); } - [SkippableFact] + [Fact] public void TestBadPassword() { RequireEnvironment.Check().EnvironmentVariable("GSSAPI_TESTS_ENABLED"); diff --git a/tests/MongoDB.Driver.Tests/Communication/Security/PlainAuthenticationTests.cs b/tests/MongoDB.Driver.Tests/Communication/Security/PlainAuthenticationTests.cs index e309fc4ccfd..572191aebb8 100644 --- a/tests/MongoDB.Driver.Tests/Communication/Security/PlainAuthenticationTests.cs +++ b/tests/MongoDB.Driver.Tests/Communication/Security/PlainAuthenticationTests.cs @@ -16,7 +16,7 @@ using System; using System.Linq; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver; using Xunit; @@ -35,7 +35,7 @@ public PlainAuthenticationTests() _settings = MongoClientSettings.FromUrl(new MongoUrl(CoreTestConfiguration.ConnectionString.ToString())); } - [SkippableFact] + [Fact] public void TestNoCredentials() { RequireEnvironment.Check().EnvironmentVariable("PLAIN_AUTH_TESTS_ENABLED"); @@ -53,7 +53,7 @@ public void TestNoCredentials() }); } - [SkippableFact] + [Fact] public void TestSuccessfulAuthentication() { RequireEnvironment.Check().EnvironmentVariable("PLAIN_AUTH_TESTS_ENABLED"); @@ -68,7 +68,7 @@ public void TestSuccessfulAuthentication() Assert.NotNull(result); } - [SkippableFact] + [Fact] public void TestBadPassword() { RequireEnvironment.Check().EnvironmentVariable("PLAIN_AUTH_TESTS_ENABLED"); diff --git a/tests/MongoDB.Driver.Tests/ConnectionsSurvivePrimaryStepDownTests.cs b/tests/MongoDB.Driver.Tests/ConnectionsSurvivePrimaryStepDownTests.cs index 71c1f4a49b0..24b52988ea6 100644 --- a/tests/MongoDB.Driver.Tests/ConnectionsSurvivePrimaryStepDownTests.cs +++ b/tests/MongoDB.Driver.Tests/ConnectionsSurvivePrimaryStepDownTests.cs @@ -18,7 +18,7 @@ using System.Net; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; @@ -37,7 +37,7 @@ public class ConnectionsSurvivePrimaryStepDownTests private readonly string _collectionName = "step-down"; private readonly string _databaseName = "step-down"; - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Connection_pool_should_be_cleared_when_Shutdown_exceptions( [Values( @@ -74,7 +74,7 @@ public class ConnectionsSurvivePrimaryStepDownTests } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Connection_pool_should_not_be_cleared_when_replSetStepDown_and_GetMore([Values(false, true)] bool async) { @@ -143,7 +143,7 @@ void RunOnSecondary(IMongoClient primaryClient, EndPoint secondaryEndpoint, Bson } } - [SkippableFact] + [Fact] public void Connection_pool_should_work_as_expected_when_NonPrimary_exception() { RequireServer.Check().Supports(Feature.FailPointsFailCommand).ClusterType(ClusterType.ReplicaSet); diff --git a/tests/MongoDB.Driver.Tests/CreateManyIndexOptionsTest.cs b/tests/MongoDB.Driver.Tests/CreateManyIndexOptionsTest.cs index edcf3e7891d..5ed06f04ce7 100644 --- a/tests/MongoDB.Driver.Tests/CreateManyIndexOptionsTest.cs +++ b/tests/MongoDB.Driver.Tests/CreateManyIndexOptionsTest.cs @@ -15,7 +15,7 @@ using System; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests diff --git a/tests/MongoDB.Driver.Tests/CreateOneIndexOptionsTest.cs b/tests/MongoDB.Driver.Tests/CreateOneIndexOptionsTest.cs index 1ee8cb739d3..e0b8d0dd4f2 100644 --- a/tests/MongoDB.Driver.Tests/CreateOneIndexOptionsTest.cs +++ b/tests/MongoDB.Driver.Tests/CreateOneIndexOptionsTest.cs @@ -15,7 +15,7 @@ using System; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests diff --git a/tests/MongoDB.Driver.Tests/CreateViewOptionsTests.cs b/tests/MongoDB.Driver.Tests/CreateViewOptionsTests.cs index e7e1d3b5483..6ba3faad10f 100644 --- a/tests/MongoDB.Driver.Tests/CreateViewOptionsTests.cs +++ b/tests/MongoDB.Driver.Tests/CreateViewOptionsTests.cs @@ -17,7 +17,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests diff --git a/tests/MongoDB.Driver.Tests/DecryptedSecureStringTests.cs b/tests/MongoDB.Driver.Tests/DecryptedSecureStringTests.cs index b12eee1a875..81d139470aa 100644 --- a/tests/MongoDB.Driver.Tests/DecryptedSecureStringTests.cs +++ b/tests/MongoDB.Driver.Tests/DecryptedSecureStringTests.cs @@ -20,7 +20,7 @@ using System.Security; using FluentAssertions; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests diff --git a/tests/MongoDB.Driver.Tests/DropIndexOptionsTest.cs b/tests/MongoDB.Driver.Tests/DropIndexOptionsTest.cs index e860bca5baa..39933afe653 100644 --- a/tests/MongoDB.Driver.Tests/DropIndexOptionsTest.cs +++ b/tests/MongoDB.Driver.Tests/DropIndexOptionsTest.cs @@ -15,7 +15,7 @@ using System; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests diff --git a/tests/MongoDB.Driver.Tests/Encryption/AutoEncryptionOptionsTests.cs b/tests/MongoDB.Driver.Tests/Encryption/AutoEncryptionOptionsTests.cs index 1e233ee4b4b..75fb468d505 100644 --- a/tests/MongoDB.Driver.Tests/Encryption/AutoEncryptionOptionsTests.cs +++ b/tests/MongoDB.Driver.Tests/Encryption/AutoEncryptionOptionsTests.cs @@ -19,7 +19,7 @@ using System.Security.Cryptography.X509Certificates; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Encryption; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Tests/Encryption/AutoEncryptionTests.cs b/tests/MongoDB.Driver.Tests/Encryption/AutoEncryptionTests.cs index 629de19ff94..9027da0ed13 100644 --- a/tests/MongoDB.Driver.Tests/Encryption/AutoEncryptionTests.cs +++ b/tests/MongoDB.Driver.Tests/Encryption/AutoEncryptionTests.cs @@ -20,7 +20,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.Logging; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -47,7 +47,7 @@ public AutoEncryptionTests(ITestOutputHelper testOutputHelper) { } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void CryptClient_should_be_initialized([Values(false, true)] bool withAutoEncryption) { @@ -68,7 +68,7 @@ public void CryptClient_should_be_initialized([Values(false, true)] bool withAut } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public async Task Mongocryptd_should_be_initialized_when_auto_encryption([Values(false, true)] bool withAutoEncryption, [Values(false, true)] bool async) { @@ -107,7 +107,7 @@ public async Task Mongocryptd_should_be_initialized_when_auto_encryption([Values } } - [SkippableFact] + [Fact] public void Shared_library_should_be_loaded_when_CRYPT_SHARED_LIB_PATH_is_set() { RequireServer.Check().Supports(Feature.ClientSideEncryption); diff --git a/tests/MongoDB.Driver.Tests/Encryption/ClientEncryptionTests.cs b/tests/MongoDB.Driver.Tests/Encryption/ClientEncryptionTests.cs index 7c3623165a6..70b9607ba3b 100644 --- a/tests/MongoDB.Driver.Tests/Encryption/ClientEncryptionTests.cs +++ b/tests/MongoDB.Driver.Tests/Encryption/ClientEncryptionTests.cs @@ -18,7 +18,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using MongoDB.Driver.Encryption; @@ -35,7 +35,7 @@ public class ClientEncryptionTests private static readonly CollectionNamespace __keyVaultCollectionNamespace = CollectionNamespace.FromFullName("datakeys.keyvault"); #endregion - [SkippableFact] + [Fact] public async Task AddAlternateKeyName_should_correctly_handle_input_arguments() { RequireServer.Check().Supports(Feature.ClientSideEncryption); @@ -49,7 +49,7 @@ public async Task AddAlternateKeyName_should_correctly_handle_input_arguments() } } - [SkippableFact] + [Fact] public async Task CreateDataKey_should_correctly_handle_input_arguments() { RequireServer.Check().Supports(Feature.ClientSideEncryption); @@ -65,7 +65,7 @@ public async Task CreateDataKey_should_correctly_handle_input_arguments() } - [SkippableFact] + [Fact] public void CryptClient_should_be_initialized() { RequireServer.Check().Supports(Feature.ClientSideEncryption); @@ -77,7 +77,7 @@ public void CryptClient_should_be_initialized() } } - [SkippableFact] + [Fact] public async Task Decrypt_should_correctly_handle_input_arguments() { RequireServer.Check().Supports(Feature.ClientSideEncryption); @@ -89,7 +89,7 @@ public async Task Decrypt_should_correctly_handle_input_arguments() } } - [SkippableFact] + [Fact] public async Task Encrypt_should_correctly_handle_input_arguments() { RequireServer.Check().Supports(Feature.ClientSideEncryption); @@ -104,7 +104,7 @@ public async Task Encrypt_should_correctly_handle_input_arguments() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public async Task Encryption_should_use_correct_binarySubType([Values(false, true)] bool async) { @@ -125,7 +125,7 @@ public async Task Encryption_should_use_correct_binarySubType([Values(false, tru } } - [SkippableFact] + [Fact] public async Task GetKeyByAlternateKeyName_should_correctly_handle_input_arguments() { RequireServer.Check().Supports(Feature.ClientSideEncryption); @@ -137,7 +137,7 @@ public async Task GetKeyByAlternateKeyName_should_correctly_handle_input_argumen } } - [SkippableFact] + [Fact] public async Task RemoveAlternateKeyName_should_correctly_handle_input_arguments() { RequireServer.Check().Supports(Feature.ClientSideEncryption); @@ -151,7 +151,7 @@ public async Task RemoveAlternateKeyName_should_correctly_handle_input_arguments } } - [SkippableFact] + [Fact] public async Task RewrapManyDataKey_should_correctly_handle_input_arguments() { RequireServer.Check().Supports(Feature.ClientSideEncryption); diff --git a/tests/MongoDB.Driver.Tests/EstimatedDocumentCountOptionsTests.cs b/tests/MongoDB.Driver.Tests/EstimatedDocumentCountOptionsTests.cs index 69dafc95bf0..dae0b51ff0b 100644 --- a/tests/MongoDB.Driver.Tests/EstimatedDocumentCountOptionsTests.cs +++ b/tests/MongoDB.Driver.Tests/EstimatedDocumentCountOptionsTests.cs @@ -15,7 +15,7 @@ using System; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests diff --git a/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderTests.cs index ac20e6be083..a9164295ac8 100644 --- a/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderTests.cs @@ -20,7 +20,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using MongoDB.Driver.GeoJsonObjectModel; using Xunit; @@ -1244,7 +1244,7 @@ private static bool CreateTestData() } #endregion - [SkippableTheory] + [Theory] [InlineData(0U, new[] { 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : 0 } }, { X : { $lt : 0 } } ] }")] [InlineData(1U, new[] { 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : 1 } }, { X : { $lt : 0 } } ] }")] [InlineData(0x7fffffffU, new[] { 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : 2147483647 } }, { X : { $lt : 0 } } ] }")] @@ -1265,7 +1265,7 @@ public void Gt_UInt32(uint value, int[] expectedIds, string expectedFilter) ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0U, new[] { 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : 0 } }, { X : { $lt : 0 } } ] }")] [InlineData(1U, new[] { 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : 1 } }, { X : { $lt : 0 } } ] }")] [InlineData(0x7fffffffU, new[] { 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : 2147483647 } }, { X : { $lt : 0 } } ] }")] @@ -1286,7 +1286,7 @@ public void Gt_UInt32_typed(uint value, int[] expectedIds, string expectedFilter ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0U, new[] { 1, 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : 0 } }, { X : { $lt : 0 } } ] }")] [InlineData(1U, new[] { 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : 1 } }, { X : { $lt : 0 } } ] }")] [InlineData(0x7fffffffU, new[] { 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : 2147483647 } }, { X : { $lt : 0 } } ] }")] @@ -1307,7 +1307,7 @@ public void Gte_UInt32(uint value, int[] expectedIds, string expectedFilter) ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0U, new[] { 1, 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : 0 } }, { X : { $lt : 0 } } ] }")] [InlineData(1U, new[] { 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : 1 } }, { X : { $lt : 0 } } ] }")] [InlineData(0x7fffffffU, new[] { 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : 2147483647 } }, { X : { $lt : 0 } } ] }")] @@ -1328,7 +1328,7 @@ public void Gte_UInt32_typed(uint value, int[] expectedIds, string expectedFilte ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0U, new int[0], "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : 0 } } ] }")] [InlineData(1U, new[] { 1 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : 1 } } ] }")] [InlineData(0x7fffffffU, new[] { 1, 2 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : 2147483647 } } ] }")] @@ -1349,7 +1349,7 @@ public void Lt_UInt32(uint value, int[] expectedIds, string expectedFilter) ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0U, new int[0], "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : 0 } } ] }")] [InlineData(1U, new[] { 1 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : 1 } } ] }")] [InlineData(0x7fffffffU, new[] { 1, 2 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : 2147483647 } } ] }")] @@ -1370,7 +1370,7 @@ public void Lt_UInt32_typed(uint value, int[] expectedIds, string expectedFilter ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0U, new int[] { 1 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : 0 } } ] }")] [InlineData(1U, new[] { 1, 2 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : 1 } } ] }")] [InlineData(0x7fffffffU, new[] { 1, 2, 3 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : 2147483647 } } ] }")] @@ -1391,7 +1391,7 @@ public void Lte_UInt32(uint value, int[] expectedIds, string expectedFilter) ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0U, new int[] { 1 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : 0 } } ] }")] [InlineData(1U, new[] { 1, 2 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : 1 } } ] }")] [InlineData(0x7fffffffU, new[] { 1, 2, 3 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : 2147483647 } } ] }")] @@ -1465,7 +1465,7 @@ private static bool CreateTestData() } #endregion - [SkippableTheory] + [Theory] [InlineData(0UL, new[] { 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : NumberLong(0) } }, { X : { $lt : 0 } } ] }")] [InlineData(1UL, new[] { 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : NumberLong(1) } }, { X : { $lt : 0 } } ] }")] [InlineData(0x7fffffffffffffffUL, new[] { 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : NumberLong(9223372036854775807) } }, { X : { $lt : 0 } } ] }")] @@ -1486,7 +1486,7 @@ public void Gt_UInt64(ulong value, int[] expectedIds, string expectedFilter) ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0UL, new[] { 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : NumberLong(0) } }, { X : { $lt : 0 } } ] }")] [InlineData(1UL, new[] { 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : NumberLong(1) } }, { X : { $lt : 0 } } ] }")] [InlineData(0x7fffffffffffffffUL, new[] { 4, 5, 6, 7 }, "{ $or : [ { X : { $gt : NumberLong(9223372036854775807) } }, { X : { $lt : 0 } } ] }")] @@ -1507,7 +1507,7 @@ public void Gt_UInt64_typed(ulong value, int[] expectedIds, string expectedFilte ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0UL, new[] { 1, 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : NumberLong(0) } }, { X : { $lt : 0 } } ] }")] [InlineData(1UL, new[] { 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : NumberLong(1) } }, { X : { $lt : 0 } } ] }")] [InlineData(0x7fffffffffffffffUL, new[] { 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : NumberLong(9223372036854775807) } }, { X : { $lt : 0 } } ] }")] @@ -1528,7 +1528,7 @@ public void Gte_UInt64(ulong value, int[] expectedIds, string expectedFilter) ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0UL, new[] { 1, 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : NumberLong(0) } }, { X : { $lt : 0 } } ] }")] [InlineData(1UL, new[] { 2, 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : NumberLong(1) } }, { X : { $lt : 0 } } ] }")] [InlineData(0x7fffffffffffffffUL, new[] { 3, 4, 5, 6, 7 }, "{ $or : [ { X : { $gte : NumberLong(9223372036854775807) } }, { X : { $lt : 0 } } ] }")] @@ -1549,7 +1549,7 @@ public void Gte_UInt64_typed(ulong value, int[] expectedIds, string expectedFilt ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0UL, new int[0], "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : NumberLong(0) } } ] }")] [InlineData(1UL, new[] { 1 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : NumberLong(1) } } ] }")] [InlineData(0x7fffffffffffffffUL, new[] { 1, 2 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : NumberLong(9223372036854775807) } } ] }")] @@ -1570,7 +1570,7 @@ public void Lt_UInt64(ulong value, int[] expectedIds, string expectedFilter) ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0UL, new int[0], "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : NumberLong(0) } } ] }")] [InlineData(1UL, new[] { 1 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : NumberLong(1) } } ] }")] [InlineData(0x7fffffffffffffffUL, new[] { 1, 2 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lt : NumberLong(9223372036854775807) } } ] }")] @@ -1591,7 +1591,7 @@ public void Lt_UInt64_typed(ulong value, int[] expectedIds, string expectedFilte ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0UL, new[] { 1 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : NumberLong(0) } } ] }")] [InlineData(1UL, new[] { 1, 2 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : NumberLong(1) } } ] }")] [InlineData(0x7fffffffffffffffUL, new[] { 1, 2, 3 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : NumberLong(9223372036854775807) } } ] }")] @@ -1612,7 +1612,7 @@ public void Lte_UInt64(ulong value, int[] expectedIds, string expectedFilter) ids.Should().Equal(expectedIds); } - [SkippableTheory] + [Theory] [InlineData(0UL, new[] { 1 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : NumberLong(0) } } ] }")] [InlineData(1UL, new[] { 1, 2 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : NumberLong(1) } } ] }")] [InlineData(0x7fffffffffffffffUL, new[] { 1, 2, 3 }, "{ $and : [ { X : { $gte : 0 } }, { X : { $lte : NumberLong(9223372036854775807) } } ] }")] diff --git a/tests/MongoDB.Driver.Tests/FindFluentTests.cs b/tests/MongoDB.Driver.Tests/FindFluentTests.cs index b9ca37b891c..bae0d79750d 100644 --- a/tests/MongoDB.Driver.Tests/FindFluentTests.cs +++ b/tests/MongoDB.Driver.Tests/FindFluentTests.cs @@ -20,7 +20,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Tests/IAggregateFluentExtensionsTests.cs b/tests/MongoDB.Driver.Tests/IAggregateFluentExtensionsTests.cs index 24051134cb2..17377ed835c 100644 --- a/tests/MongoDB.Driver.Tests/IAggregateFluentExtensionsTests.cs +++ b/tests/MongoDB.Driver.Tests/IAggregateFluentExtensionsTests.cs @@ -17,7 +17,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using Moq; @@ -203,7 +203,7 @@ public void Lookup_should_generate_the_correct_group_when_using_lambdas() AssertLast(subject, expectedLookup); } - [SkippableFact] + [Fact] public void Lookup_expressive_should_generate_the_correct_lookup_when_using_BsonDocument() { RequireServer.Check(); @@ -219,7 +219,7 @@ public void Lookup_expressive_should_generate_the_correct_lookup_when_using_Bson AssertLast(subject, expectedLookup); } - [SkippableFact] + [Fact] public void Lookup_expressive_should_generate_the_correct_lookup_when_using_lambdas() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/IFindFluentExtensionsTests.cs b/tests/MongoDB.Driver.Tests/IFindFluentExtensionsTests.cs index 8c0b6b2b1bc..60bc77841cc 100644 --- a/tests/MongoDB.Driver.Tests/IFindFluentExtensionsTests.cs +++ b/tests/MongoDB.Driver.Tests/IFindFluentExtensionsTests.cs @@ -20,7 +20,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Tests/IMongoClientExtensionsTests.cs b/tests/MongoDB.Driver.Tests/IMongoClientExtensionsTests.cs index e3a103c5ec7..4cd59675a0f 100644 --- a/tests/MongoDB.Driver.Tests/IMongoClientExtensionsTests.cs +++ b/tests/MongoDB.Driver.Tests/IMongoClientExtensionsTests.cs @@ -15,7 +15,7 @@ using System.Threading; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Tests/IMongoCollectionExtensionsTests.cs b/tests/MongoDB.Driver.Tests/IMongoCollectionExtensionsTests.cs index 77279086626..7b326b27cf3 100644 --- a/tests/MongoDB.Driver.Tests/IMongoCollectionExtensionsTests.cs +++ b/tests/MongoDB.Driver.Tests/IMongoCollectionExtensionsTests.cs @@ -18,7 +18,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using MongoDB.Driver.Tests.Linq.Linq2ImplementationTests; using MongoDB.Driver.Tests.Linq.Linq3ImplementationTests; diff --git a/tests/MongoDB.Driver.Tests/IMongoDatabaseExtensionsTests.cs b/tests/MongoDB.Driver.Tests/IMongoDatabaseExtensionsTests.cs index 7158c95f3da..ac41119a061 100644 --- a/tests/MongoDB.Driver.Tests/IMongoDatabaseExtensionsTests.cs +++ b/tests/MongoDB.Driver.Tests/IMongoDatabaseExtensionsTests.cs @@ -15,7 +15,7 @@ using System.Threading; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Tests/Jira/CSharp2564Tests.cs b/tests/MongoDB.Driver.Tests/Jira/CSharp2564Tests.cs index 071c74bfa84..c3147928d60 100644 --- a/tests/MongoDB.Driver.Tests/Jira/CSharp2564Tests.cs +++ b/tests/MongoDB.Driver.Tests/Jira/CSharp2564Tests.cs @@ -30,7 +30,7 @@ namespace MongoDB.Driver.Tests.Jira { public class CSharp2564Tests { - [SkippableFact] + [Fact] public async Task Misbehaved_async_method_should_not_deadlock_server_selection() { RequireServer.Check().ClusterType(ClusterType.ReplicaSet); diff --git a/tests/MongoDB.Driver.Tests/Jira/CSharp3188Tests.cs b/tests/MongoDB.Driver.Tests/Jira/CSharp3188Tests.cs index eace8ca6627..2027d15dab2 100644 --- a/tests/MongoDB.Driver.Tests/Jira/CSharp3188Tests.cs +++ b/tests/MongoDB.Driver.Tests/Jira/CSharp3188Tests.cs @@ -18,7 +18,7 @@ using System.Net.Sockets; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; @@ -28,7 +28,7 @@ namespace MongoDB.Driver.Tests.Jira { public class CSharp3188Tests { - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Connection_timeout_should_throw_expected_exception([Values(false, true)] bool async) { diff --git a/tests/MongoDB.Driver.Tests/Jira/CSharp3915Tests.cs b/tests/MongoDB.Driver.Tests/Jira/CSharp3915Tests.cs index 035d53ae041..f614237004a 100644 --- a/tests/MongoDB.Driver.Tests/Jira/CSharp3915Tests.cs +++ b/tests/MongoDB.Driver.Tests/Jira/CSharp3915Tests.cs @@ -28,7 +28,7 @@ namespace MongoDB.Driver.Tests.Jira public class CSharp3915Tests : Linq3IntegrationTest { // this example is from: https://www.mongodb.com/docs/v5.2/reference/operator/aggregation/densify - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void Densify_time_series_data_example_using_aggregate_should_work(bool usingExpressions) @@ -76,7 +76,7 @@ public void Densify_time_series_data_example_using_aggregate_should_work(bool us } // this example is from: https://www.mongodb.com/docs/v5.2/reference/operator/aggregation/densify - [SkippableFact] + [Fact] public void Densify_time_series_data_example_using_linq_should_work() { RequireServer.Check().Supports(Feature.DensifyStage); @@ -112,7 +112,7 @@ public void Densify_time_series_data_example_using_linq_should_work() } // this example is from: https://www.mongodb.com/docs/v5.2/reference/operator/aggregation/densify - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void Densify_the_full_range_of_values_example_using_aggregate_should_work(bool usingExpressions) @@ -164,7 +164,7 @@ public void Densify_the_full_range_of_values_example_using_aggregate_should_work } // this example is from: https://www.mongodb.com/docs/v5.2/reference/operator/aggregation/densify - [SkippableFact] + [Fact] public void Densify_the_full_range_of_values_example_using_linq_should_work() { RequireServer.Check().Supports(Feature.DensifyStage); @@ -203,7 +203,7 @@ public void Densify_the_full_range_of_values_example_using_linq_should_work() } // this example is from: https://www.mongodb.com/docs/v5.2/reference/operator/aggregation/densify - [SkippableTheory] + [Theory] [InlineData(false)] [InlineData(true)] public void Densify_values_within_each_partition_example_using_aggregate_should_work(bool usingExpressions) @@ -247,7 +247,7 @@ public void Densify_values_within_each_partition_example_using_aggregate_should_ } // this example is from: https://www.mongodb.com/docs/v5.2/reference/operator/aggregation/densify - [SkippableFact] + [Fact] public void Densify_values_within_each_partition_example_using_linq_should_work() { RequireServer.Check().Supports(Feature.DensifyStage); diff --git a/tests/MongoDB.Driver.Tests/JsonDrivenTests/JsonDrivenTestFactory.cs b/tests/MongoDB.Driver.Tests/JsonDrivenTests/JsonDrivenTestFactory.cs index dd46600f40f..322e77dac89 100644 --- a/tests/MongoDB.Driver.Tests/JsonDrivenTests/JsonDrivenTestFactory.cs +++ b/tests/MongoDB.Driver.Tests/JsonDrivenTests/JsonDrivenTestFactory.cs @@ -19,6 +19,7 @@ using MongoDB.Bson.TestHelpers.JsonDrivenTests; using MongoDB.Driver.Core; using Xunit; +using Xunit.Sdk; namespace MongoDB.Driver.Tests.JsonDrivenTests { diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/AggregateQueryableExecutionModelTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/AggregateQueryableExecutionModelTests.cs index 71641b87c47..7dad1c6e754 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/AggregateQueryableExecutionModelTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/AggregateQueryableExecutionModelTests.cs @@ -16,7 +16,7 @@ using System.Threading; using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using Moq; using Xunit; diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/MongoQueryProviderImplTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/MongoQueryProviderImplTests.cs index abb9802d549..4bccd8615e1 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/MongoQueryProviderImplTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/MongoQueryProviderImplTests.cs @@ -18,7 +18,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using MongoDB.Driver.Linq.Linq2Implementation; using Moq; diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/MongoQueryableTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/MongoQueryableTests.cs index fb4a19af16a..a293d2a62ac 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/MongoQueryableTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/MongoQueryableTests.cs @@ -179,7 +179,7 @@ public async Task CountAsync_with_no_matches() result.Should().Be(0); } - [SkippableFact] + [Fact] public void Distinct_document_followed_by_where() { RequireServer.Check(); @@ -193,7 +193,7 @@ public void Distinct_document_followed_by_where() "{ $match: { '_id.A': 'Awesome' } }"); } - [SkippableFact] + [Fact] public void Distinct_document_preceded_by_select_where() { RequireServer.Check(); @@ -209,7 +209,7 @@ public void Distinct_document_preceded_by_select_where() "{ $group: { '_id': '$$ROOT' } }"); } - [SkippableFact] + [Fact] public void Distinct_document_preceded_by_where_select() { RequireServer.Check(); @@ -224,7 +224,7 @@ public void Distinct_document_preceded_by_where_select() "{ $group: { '_id': { 'A': '$A', 'B': '$B' } } }"); } - [SkippableFact] + [Fact] public void Distinct_field_preceded_by_where_select() { RequireServer.Check(); @@ -239,7 +239,7 @@ public void Distinct_field_preceded_by_where_select() "{ $group: { '_id': '$A' } }"); } - [SkippableFact] + [Fact] public void Distinct_field_preceded_by_select_where() { RequireServer.Check(); @@ -473,7 +473,7 @@ public void GroupBy_with_resultSelector_anonymous_type_method() "{ $group: { _id: '$A', FirstB: { $first: '$B'} } }"); } - [SkippableFact] + [Fact] public void GroupJoin_method() { RequireServer.Check(); @@ -489,7 +489,7 @@ public void GroupJoin_method() "{ $lookup: { from: 'testcollection_other', localField: '_id', foreignField: '_id', as: 'o' } }"); } - [SkippableFact] + [Fact] public void GroupJoinForeignField_method() { RequireServer.Check(); @@ -505,7 +505,7 @@ public void GroupJoinForeignField_method() "{ $lookup: { from: 'testcollection_other', localField: '_id', foreignField: 'CEF', as: 'o' } }"); } - [SkippableFact] + [Fact] public void GroupJoin_syntax() { RequireServer.Check(); @@ -519,7 +519,7 @@ public void GroupJoin_syntax() "{ $project: { A: '$A', SumCEF: { $sum: '$joined.CEF' }, _id: 0 } }"); } - [SkippableFact] + [Fact] public void GroupJoin_syntax_with_a_transparent_identifier() { RequireServer.Check(); @@ -535,7 +535,7 @@ orderby p.B "{ $project: { A: '$A', Joined: '$joined', _id: 0 } }"); } - [SkippableFact] + [Fact] public void GroupJoin_syntax_with_select_many() { RequireServer.Check(); @@ -551,7 +551,7 @@ public void GroupJoin_syntax_with_select_many() "{ $project: { A: '$A', CEF: '$joined.CEF', _id: 0 } }"); } - [SkippableFact] + [Fact] public void GroupJoin_syntax_with_select_many_and_DefaultIfEmpty() { RequireServer.Check(); @@ -568,7 +568,7 @@ public void GroupJoin_syntax_with_select_many_and_DefaultIfEmpty() "{ $project: { A: '$A', CEF: { $ifNull: ['$joined.CEF', null] }, _id: 0 } }"); } - [SkippableFact] + [Fact] public void Join_method() { RequireServer.Check(); @@ -585,7 +585,7 @@ public void Join_method() "{ $unwind: '$o' }"); } - [SkippableFact] + [Fact] public void JoinForeignField_method() { RequireServer.Check(); @@ -602,7 +602,7 @@ public void JoinForeignField_method() "{ $unwind: '$o' }"); } - [SkippableFact] + [Fact] public void Join_syntax() { RequireServer.Check(); @@ -617,7 +617,7 @@ public void Join_syntax() "{ $project: { A: '$A', CEF: '$o.CEF', _id: 0 } }"); } - [SkippableFact] + [Fact] public void Join_syntax_with_a_transparent_identifier() { RequireServer.Check(); @@ -866,7 +866,7 @@ public void OrderBy_ThenBy_ThenByDescending_with_redundant_fields_in_different_d act.ShouldThrow(); } - [SkippableFact] + [Fact] public void Sample() { RequireServer.Check(); @@ -877,7 +877,7 @@ public void Sample() "{ $sample: { size: 100 } }"); } - [SkippableFact] + [Fact] public void Sample_after_another_function() { RequireServer.Check(); @@ -934,7 +934,7 @@ public void Select_method_computed_scalar_followed_by_where() "{ $match: { __fld0: 'Awesome Balloon' } }"); } - [SkippableFact] + [Fact] public void Select_method_with_predicated_any() { RequireServer.Check(); @@ -1056,7 +1056,7 @@ public void Select_syntax_array() "{ $project: { M: '$M', _id: 0 } }"); } - [SkippableFact] + [Fact] public void Select_method_array_index() { RequireServer.Check(); @@ -1067,7 +1067,7 @@ public void Select_method_array_index() "{ $project: { __fld0: { $arrayElemAt: ['$M', 0] }, _id: 0 } }"); } - [SkippableFact] + [Fact] public void Select_syntax_array_index() { RequireServer.Check(); @@ -1079,7 +1079,7 @@ public void Select_syntax_array_index() "{ $project: { __fld0: { $arrayElemAt: ['$M', 0] }, _id: 0 } }"); } - [SkippableFact] + [Fact] public void Select_method_embedded_pipeline() { RequireServer.Check(); @@ -1090,7 +1090,7 @@ public void Select_method_embedded_pipeline() "{ $project: { __fld0: { $arrayElemAt: ['$M', 0] }, _id: 0 } }"); } - [SkippableFact] + [Fact] public void Select_method_computed_array() { RequireServer.Check(); @@ -1102,7 +1102,7 @@ public void Select_method_computed_array() "{ $project: { __fld0: { $map: { input: '$M', as: 'i', in: { $add: ['$$i', 1] } } }, _id: 0 } }"); } - [SkippableFact] + [Fact] public void Select_syntax_computed_array() { RequireServer.Check(); @@ -1546,7 +1546,7 @@ public void Skip() "{ $skip: 10 }"); } - [SkippableFact] + [Fact] public void StandardDeviationPopulation() { RequireServer.Check(); @@ -1556,7 +1556,7 @@ public void StandardDeviationPopulation() result.Should().Be(50); } - [SkippableFact] + [Fact] public void StandardDeviationPopulation_with_selector() { RequireServer.Check(); @@ -1566,7 +1566,7 @@ public void StandardDeviationPopulation_with_selector() result.Should().Be(50); } - [SkippableFact] + [Fact] public async Task StandardDeviationPopulationAsync() { RequireServer.Check(); @@ -1576,7 +1576,7 @@ public async Task StandardDeviationPopulationAsync() result.Should().Be(50); } - [SkippableFact] + [Fact] public async Task StandardDeviationPopulationAsync_with_selector() { RequireServer.Check(); @@ -1586,7 +1586,7 @@ public async Task StandardDeviationPopulationAsync_with_selector() result.Should().Be(50); } - [SkippableFact] + [Fact] public void StandardDeviationSample() { RequireServer.Check(); @@ -1596,7 +1596,7 @@ public void StandardDeviationSample() result.Should().BeApproximately(70.7106781186548, .0001); } - [SkippableFact] + [Fact] public void StandardDeviationSample_with_selector() { RequireServer.Check(); @@ -1606,7 +1606,7 @@ public void StandardDeviationSample_with_selector() result.Should().BeApproximately(70.7106781186548, .0001); } - [SkippableFact] + [Fact] public async Task StandardDeviationSampleAsync() { RequireServer.Check(); @@ -1616,7 +1616,7 @@ public async Task StandardDeviationSampleAsync() result.Should().BeApproximately(70.7106781186548, .0001); } - [SkippableFact] + [Fact] public async Task StandardDeviationSampleAsync_with_selector() { RequireServer.Check(); @@ -1719,7 +1719,7 @@ public void Where_method_with_predicated_any() "{ $match : { 'G' : { '$elemMatch' : { 'D' : \"Don't\" } } } }"); } - [SkippableFact] + [Fact] public void AsQueryable_in_transaction() { RequireServer.Check().ClusterTypes(ClusterType.ReplicaSet, ClusterType.Sharded).Supports(Feature.Transactions); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/AggregateGroupTranslatorTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/AggregateGroupTranslatorTests.cs index af2cdbb7fce..03ff1fb006e 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/AggregateGroupTranslatorTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/AggregateGroupTranslatorTests.cs @@ -299,7 +299,7 @@ public void Should_translate_push_with_ToList() result.Value.Result.Should().Equal(111); } - [SkippableFact] + [Fact] public void Should_translate_stdDevPop_with_embedded_projector() { RequireServer.Check(); @@ -311,7 +311,7 @@ public void Should_translate_stdDevPop_with_embedded_projector() result.Value.Result.Should().Be(50); } - [SkippableFact] + [Fact] public void Should_translate_stdDevPop_with_selected_projector() { RequireServer.Check(); @@ -323,7 +323,7 @@ public void Should_translate_stdDevPop_with_selected_projector() result.Value.Result.Should().Be(50); } - [SkippableFact] + [Fact] public void Should_translate_stdDevSamp_with_embedded_projector() { RequireServer.Check(); @@ -335,7 +335,7 @@ public void Should_translate_stdDevSamp_with_embedded_projector() result.Value.Result.Should().BeApproximately(70.7106781156545, .0001); } - [SkippableFact] + [Fact] public void Should_translate_stdDevSamp_with_selected_projector() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/AggregateProjectTranslatorTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/AggregateProjectTranslatorTests.cs index d284572788c..bd31927a996 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/AggregateProjectTranslatorTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/AggregateProjectTranslatorTests.cs @@ -57,7 +57,7 @@ public void Should_translate_using_non_anonymous_type_with_parameterized_constru result.Value.Field.Should().Be("Balloon"); } - [SkippableFact] + [Fact] public void Should_translate_abs() { RequireServer.Check(); @@ -88,7 +88,7 @@ public void Should_translate_add_flattened() result.Value.Result.Should().Be(43); } - [SkippableFact] + [Fact] public void Should_translate_allElementsTrue() { RequireServer.Check(); @@ -100,7 +100,7 @@ public void Should_translate_allElementsTrue() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_anyElementTrue() { RequireServer.Check(); @@ -112,7 +112,7 @@ public void Should_translate_anyElementTrue() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_anyElementTrue_with_predicate() { RequireServer.Check(); @@ -124,7 +124,7 @@ public void Should_translate_anyElementTrue_with_predicate() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_anyElementTrue_using_Contains() { RequireServer.Check(); @@ -136,7 +136,7 @@ public void Should_translate_anyElementTrue_using_Contains() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_anyElementTrue_using_Contains_on_a_local_collection() { RequireServer.Check(); @@ -169,7 +169,7 @@ public void Should_translate_and_flattened() result.Value.Result.Should().BeFalse(); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_constant_ElementAt() { RequireServer.Check(); @@ -181,7 +181,7 @@ public void Should_translate_arrayElemAt_using_a_constant_ElementAt() result.Value.Result.Should().Be(4); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_constant_indexer() { RequireServer.Check(); @@ -193,7 +193,7 @@ public void Should_translate_arrayElemAt_using_a_constant_indexer() result.Value.Result.Should().Be(4); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_constant_get_Item() { RequireServer.Check(); @@ -205,7 +205,7 @@ public void Should_translate_arrayElemAt_using_a_constant_get_Item() result.Value.Result.Should().Be(20); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_variable_ElementAt() { RequireServer.Check(); @@ -217,7 +217,7 @@ public void Should_translate_arrayElemAt_using_a_variable_ElementAt() result.Value.Result.Should().Be(4); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_variable_indexer() { RequireServer.Check(); @@ -229,7 +229,7 @@ public void Should_translate_arrayElemAt_using_a_variable_indexer() result.Value.Result.Should().Be(4); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_variable_get_Item() { RequireServer.Check(); @@ -241,7 +241,7 @@ public void Should_translate_arrayElemAt_using_a_variable_get_Item() result.Value.Result.Should().Be(20); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_constant_ElementAt_followed_by_a_field() { RequireServer.Check(); @@ -253,7 +253,7 @@ public void Should_translate_arrayElemAt_using_a_constant_ElementAt_followed_by_ result.Value.Result.Should().Be("Dolphin"); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_variable_ElementAt_followed_by_a_field() { RequireServer.Check(); @@ -265,7 +265,7 @@ public void Should_translate_arrayElemAt_using_a_variable_ElementAt_followed_by_ result.Value.Result.Should().Be("Dolphin"); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_First() { RequireServer.Check(); @@ -277,7 +277,7 @@ public void Should_translate_arrayElemAt_using_First() result.Value.Result.Should().Be(2); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_First_followed_by_a_field() { RequireServer.Check(); @@ -289,7 +289,7 @@ public void Should_translate_arrayElemAt_using_First_followed_by_a_field() result.Value.Result.Should().Be("Don't"); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_Last() { RequireServer.Check(); @@ -301,7 +301,7 @@ public void Should_translate_arrayElemAt_using_Last() result.Value.Result.Should().Be(5); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_Last_followed_by_a_field() { RequireServer.Check(); @@ -313,7 +313,7 @@ public void Should_translate_arrayElemAt_using_Last_followed_by_a_field() result.Value.Result.Should().Be("Dolphin"); } - [SkippableFact] + [Fact] public void Should_translate_avg() { RequireServer.Check(); @@ -325,7 +325,7 @@ public void Should_translate_avg() result.Value.Result.Should().BeApproximately(3.66666667, .0001); } - [SkippableFact] + [Fact] public void Should_translate_avg_with_selector() { RequireServer.Check(); @@ -337,7 +337,7 @@ public void Should_translate_avg_with_selector() result.Value.Result.Should().Be(44); } - [SkippableFact] + [Fact] public void Should_translate_boolToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -349,7 +349,7 @@ public void Should_translate_boolToString() result.Value.Result.Should().Be("true"); } - [SkippableFact] + [Fact] public void Should_translate_ceil() { RequireServer.Check(); @@ -381,7 +381,7 @@ public void Should_translate_compare() result.Value.Result.Should().Be(0); } - [SkippableFact] + [Fact] public void Should_translate_concat() { RequireServer.Check(); @@ -393,7 +393,7 @@ public void Should_translate_concat() result.Value.Result.Should().Be("AwesomeBalloon"); } - [SkippableFact] + [Fact] public void Should_translate_concat_flattened() { RequireServer.Check(); @@ -405,7 +405,7 @@ public void Should_translate_concat_flattened() result.Value.Result.Should().Be("Awesome Balloon"); } - [SkippableFact] + [Fact] public void Should_translate_concatArrays() { RequireServer.Check(); @@ -427,7 +427,7 @@ public void Should_translate_condition() result.Value.Result.Should().Be("b"); } - [SkippableFact] + [Fact] public void Should_translate_dateTimeToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -439,7 +439,7 @@ public void Should_translate_dateTimeToString() result.Value.Result.Should().Be("2012-12-01T13:14:15.016Z"); } - [SkippableFact] + [Fact] public void Should_translate_dateToString() { RequireServer.Check(); @@ -481,7 +481,7 @@ public void Should_translate_day_of_year() result.Value.Result.Should().Be(336); } - [SkippableFact] + [Fact] public void Should_translate_decimalToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -513,7 +513,7 @@ public void Should_translate_divide_3_numbers() result.Value.Result.Should().BeApproximately(0.04, .01); } - [SkippableFact] + [Fact] public void Should_translate_doubleToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -545,7 +545,7 @@ public void Should_translate_equals_as_a_method_call() result.Value.Result.Should().BeFalse(); } - [SkippableFact] + [Fact] public void Should_translate_exp() { RequireServer.Check(); @@ -557,7 +557,7 @@ public void Should_translate_exp() result.Value.Result.Should().BeApproximately(59874.1417151978, .0001); } - [SkippableFact] + [Fact] public void Should_translate_floor() { RequireServer.Check(); @@ -599,7 +599,7 @@ public void Should_translate_hour() result.Value.Result.Should().Be(13); } - [SkippableFact] + [Fact] public void Should_translate_indexOfBytes() { RequireServer.Check(); @@ -629,7 +629,7 @@ public void Should_translate_indexOfBytes() result.Value.Result.Should().Be(-1); } - [SkippableFact] + [Fact] public void Should_translate_indexOfCP() { RequireServer.Check(); @@ -659,7 +659,7 @@ public void Should_translate_indexOfCP() result.Value.Result.Should().Be(-1); } - [SkippableFact] + [Fact] public void Should_translate_intToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -691,7 +691,7 @@ public void Should_translate_less_than_or_equal() result.Value.Result.Should().BeFalse(); } - [SkippableFact] + [Fact] public void Should_translate_literal_when_a_constant_strings_begins_with_a_dollar() { RequireServer.Check(); @@ -703,7 +703,7 @@ public void Should_translate_literal_when_a_constant_strings_begins_with_a_dolla result.Value.Result.Should().BeFalse(); } - [SkippableFact] + [Fact] public void Should_translate_ln() { RequireServer.Check(); @@ -715,7 +715,7 @@ public void Should_translate_ln() result.Value.Result.Should().BeApproximately(2.39789527279837, .0001); } - [SkippableFact] + [Fact] public void Should_translate_log() { RequireServer.Check(); @@ -727,7 +727,7 @@ public void Should_translate_log() result.Value.Result.Should().Be(1); } - [SkippableFact] + [Fact] public void Should_translate_log10() { RequireServer.Check(); @@ -739,7 +739,7 @@ public void Should_translate_log10() result.Value.Result.Should().BeApproximately(1.0413928515823, .0001); } - [SkippableFact] + [Fact] public void Should_translate_longToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -751,7 +751,7 @@ public void Should_translate_longToString() result.Value.Result.Should().Be("9"); } - [SkippableFact] + [Fact] public void Should_translate_map_with_document() { RequireServer.Check(); @@ -763,7 +763,7 @@ public void Should_translate_map_with_document() result.Value.Result.Should().Equal("Don't0", "Dolphin0"); } - [SkippableFact] + [Fact] public void Should_translate_map_with_value() { RequireServer.Check(); @@ -775,7 +775,7 @@ public void Should_translate_map_with_value() result.Value.Result.Should().Equal("it0", "icky0"); } - [SkippableFact] + [Fact] public void Should_translate_max() { RequireServer.Check(); @@ -787,7 +787,7 @@ public void Should_translate_max() result.Value.Result.Should().Be(5); } - [SkippableFact] + [Fact] public void Should_translate_max_with_selector() { RequireServer.Check(); @@ -799,7 +799,7 @@ public void Should_translate_max_with_selector() result.Value.Result.Should().Be(55); } - [SkippableFact] + [Fact] public void Should_translate_millisecond() { RequireServer.Check(); @@ -811,7 +811,7 @@ public void Should_translate_millisecond() result.Value.Result.Should().Be(16); } - [SkippableFact] + [Fact] public void Should_translate_min() { RequireServer.Check(); @@ -823,7 +823,7 @@ public void Should_translate_min() result.Value.Result.Should().Be(2); } - [SkippableFact] + [Fact] public void Should_translate_min_with_selector() { RequireServer.Check(); @@ -885,7 +885,7 @@ public void Should_translate_multiply_flattened() result.Value.Result.Should().Be(2420); } - [SkippableFact] + [Fact] public void Should_translate_new_DateTime() { RequireServer.Check(); @@ -933,7 +933,7 @@ public void Should_translate_not_equals() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_objectIdToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -965,7 +965,7 @@ public void Should_translate_or_flattened() result.Value.Result.Should().BeFalse(); } - [SkippableFact] + [Fact] public void Should_translate_DateTime_parse() { RequireServer.Check(); @@ -977,7 +977,7 @@ public void Should_translate_DateTime_parse() result.Value.Result.Should().Be(new DateTime(2017, 2, 8, 12, 10, 40, 787, DateTimeKind.Utc)); } - [SkippableFact] + [Fact] public void Should_translate_pow() { RequireServer.Check(); @@ -989,7 +989,7 @@ public void Should_translate_pow() result.Value.Result.Should().Be(161051); } - [SkippableFact] + [Fact] public void Should_translate_range() { RequireServer.Check(); @@ -1001,7 +1001,7 @@ public void Should_translate_range() result.Value.Result.Should().BeEquivalentTo(11, 12, 13); } - [SkippableFact] + [Fact] public void Should_translate_reduce() { RequireServer.Check(); @@ -1025,7 +1025,7 @@ public void Should_translate_reduce() typeResult.Value.Result.y.Should().Be(5); } - [SkippableFact] + [Fact] public void Should_translate_reverse() { RequireServer.Check(); @@ -1047,7 +1047,7 @@ public void Should_translate_second() result.Value.Result.Should().Be(15); } - [SkippableFact] + [Fact] public void Should_translate_size_greater_than_zero_from_any() { RequireServer.Check(); @@ -1059,7 +1059,7 @@ public void Should_translate_size_greater_than_zero_from_any() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_size_from_an_array() { RequireServer.Check(); @@ -1071,7 +1071,7 @@ public void Should_translate_size_from_an_array() result.Value.Result.Should().Be(3); } - [SkippableFact] + [Fact] public void Should_translate_size_from_Count_extension_method() { RequireServer.Check(); @@ -1083,7 +1083,7 @@ public void Should_translate_size_from_Count_extension_method() result.Value.Result.Should().Be(3); } - [SkippableFact] + [Fact] public void Should_translate_size_from_LongCount_extension_method() { RequireServer.Check(); @@ -1095,7 +1095,7 @@ public void Should_translate_size_from_LongCount_extension_method() result.Value.Result.Should().Be(3); } - [SkippableFact] + [Fact] public void Should_translate_size_from_Count_property_on_Generic_ICollection() { RequireServer.Check(); @@ -1107,7 +1107,7 @@ public void Should_translate_size_from_Count_property_on_Generic_ICollection() result.Value.Result.Should().Be(3); } - [SkippableFact] + [Fact] public void Should_translate_set_difference() { RequireServer.Check(); @@ -1119,7 +1119,7 @@ public void Should_translate_set_difference() result.Value.Result.Should().Equal("icky"); } - [SkippableFact] + [Fact] public void Should_translate_set_difference_reversed() { RequireServer.Check(); @@ -1131,7 +1131,7 @@ public void Should_translate_set_difference_reversed() result.Value.Result.Should().Equal("not in here"); } - [SkippableFact] + [Fact] public void Should_translate_set_equals() { RequireServer.Check(); @@ -1143,7 +1143,7 @@ public void Should_translate_set_equals() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_set_equals_reversed() { RequireServer.Check(); @@ -1156,7 +1156,7 @@ public void Should_translate_set_equals_reversed() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_set_intersection() { RequireServer.Check(); @@ -1168,7 +1168,7 @@ public void Should_translate_set_intersection() result.Value.Result.Should().Equal("it"); } - [SkippableFact] + [Fact] public void Should_translate_set_intersection_reversed() { RequireServer.Check(); @@ -1180,7 +1180,7 @@ public void Should_translate_set_intersection_reversed() result.Value.Result.Should().Equal("it"); } - [SkippableFact] + [Fact] public void Should_translate_set_is_subset() { RequireServer.Check(); @@ -1192,7 +1192,7 @@ public void Should_translate_set_is_subset() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_set_is_subset_reversed() { RequireServer.Check(); @@ -1205,7 +1205,7 @@ public void Should_translate_set_is_subset_reversed() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_set_union() { RequireServer.Check(); @@ -1217,7 +1217,7 @@ public void Should_translate_set_union() result.Value.Result.Should().BeEquivalentTo("it", "icky", "not in here"); } - [SkippableFact] + [Fact] public void Should_translate_set_union_reversed() { RequireServer.Check(); @@ -1229,7 +1229,7 @@ public void Should_translate_set_union_reversed() result.Value.Result.Should().BeEquivalentTo("it", "icky", "not in here"); } - [SkippableFact] + [Fact] public void Should_translate_sqrt() { RequireServer.Check(); @@ -1241,7 +1241,7 @@ public void Should_translate_sqrt() result.Value.Result.Should().BeApproximately(3.31662479, .0001); } - [SkippableFact] + [Fact] public void Should_translate_stringToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -1253,7 +1253,7 @@ public void Should_translate_stringToString() result.Value.Result.Should().Be("Awesome"); } - [SkippableFact] + [Fact] public void Should_translate_trunc() { RequireServer.Check(); @@ -1265,7 +1265,7 @@ public void Should_translate_trunc() result.Value.Result.Should().Be(1); } - [SkippableFact] + [Fact] public void Should_translate_where_to_filter() { RequireServer.Check(); @@ -1278,7 +1278,7 @@ public void Should_translate_where_to_filter() result.Value.Result.Single().D.Should().Be("Don't"); } - [SkippableFact] + [Fact] public void Should_translate_where_then_select_to_filter_then_map() { RequireServer.Check(); @@ -1291,7 +1291,7 @@ public void Should_translate_where_then_select_to_filter_then_map() result.Value.Result.Single().Should().Be("Don't"); } - [SkippableFact] + [Fact] public void Should_translate_select_then_where_to_map_then_filter() { RequireServer.Check(); @@ -1304,7 +1304,7 @@ public void Should_translate_select_then_where_to_map_then_filter() result.Value.Result.Single().Should().Be("Don't"); } - [SkippableFact] + [Fact] public void Should_translate_select_with_an_anonymous_type_then_where_to_map_then_filter() { RequireServer.Check(); @@ -1318,7 +1318,7 @@ public void Should_translate_select_with_an_anonymous_type_then_where_to_map_the result.Value.Result.Single().F.Should().Be(33); } - [SkippableFact] + [Fact] public void Should_translate_strLenBytes() { RequireServer.Check(); @@ -1330,7 +1330,7 @@ public void Should_translate_strLenBytes() result.Value.Result.Should().Be(7); } - [SkippableFact] + [Fact] public void Should_translate_strLenCP() { RequireServer.Check(); @@ -1342,7 +1342,7 @@ public void Should_translate_strLenCP() result.Value.Result.Should().Be(7); } - [SkippableFact] + [Fact] public void Should_translate_split() { RequireServer.Check(); @@ -1368,7 +1368,7 @@ public void Should_translate_split() result4.Value.Result.Should().BeEquivalentTo("Aw", "ome"); } - [SkippableFact] + [Fact] public void Should_translate_stdDevPop() { RequireServer.Check(); @@ -1380,7 +1380,7 @@ public void Should_translate_stdDevPop() result.Value.Result.Should().BeApproximately(1.247219128924647, .0001); } - [SkippableFact] + [Fact] public void Should_translate_stdDevPop_with_selector() { RequireServer.Check(); @@ -1392,7 +1392,7 @@ public void Should_translate_stdDevPop_with_selector() result.Value.Result.Should().Be(11); } - [SkippableFact] + [Fact] public void Should_translate_stdDevSamp() { RequireServer.Check(); @@ -1404,7 +1404,7 @@ public void Should_translate_stdDevSamp() result.Value.Result.Should().BeApproximately(1.5275252316519468, .0001); } - [SkippableFact] + [Fact] public void Should_translate_stdDevSamp_with_selector() { RequireServer.Check(); @@ -1478,7 +1478,7 @@ public void Should_translate_substr() result.Value.Result.Should().Be("loon"); } - [SkippableFact] + [Fact] public void Should_translate_substrCP() { RequireServer.Check(); @@ -1510,7 +1510,7 @@ public void Should_translate_subtract_3_numbers() result.Value.Result.Should().Be(-23); } - [SkippableFact] + [Fact] public void Should_translate_slice_with_2_arguments() { RequireServer.Check(); @@ -1522,7 +1522,7 @@ public void Should_translate_slice_with_2_arguments() result.Value.Result.Should().BeEquivalentTo(2, 4); } - [SkippableFact] + [Fact] public void Should_translate_slice_with_3_arguments() { RequireServer.Check(); @@ -1534,7 +1534,7 @@ public void Should_translate_slice_with_3_arguments() result.Value.Result.Should().BeEquivalentTo(4, 5); } - [SkippableFact] + [Fact] public void Should_translate_sum() { RequireServer.Check(); @@ -1546,7 +1546,7 @@ public void Should_translate_sum() result.Value.Result.Should().Be(11); } - [SkippableFact] + [Fact] public void Should_translate_sum_with_selector() { RequireServer.Check(); @@ -1608,7 +1608,7 @@ public void Should_translate_year() result.Value.Result.Should().Be(2012); } - [SkippableFact] + [Fact] public void Should_translate_zip_with_operation() { RequireServer.Check(); @@ -1620,7 +1620,7 @@ public void Should_translate_zip_with_operation() result.Value.Result.Should().BeEquivalentTo(12L, 24L, 35L); } - [SkippableFact] + [Fact] public void Should_translate_zip_with_anonymous_type() { RequireServer.Check(); @@ -1657,7 +1657,7 @@ public void Should_translate_a_derived_class_projection() result.Value.DerivedProperty.Should().Be("Balloon"); } - [SkippableFact] + [Fact] public void Should_translate_array_projection_complex() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/PredicateTranslatorTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/PredicateTranslatorTests.cs index ceede91b1cf..21656133d03 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/PredicateTranslatorTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTests/Translators/PredicateTranslatorTests.cs @@ -477,7 +477,7 @@ public void Any_with_a_predicate_on_scalars_legacy() "{ M : { $elemMatch : { $gt : 2, $lt : 6 } } }"); } - [SkippableFact] + [Fact] public void Any_with_a_predicate_on_scalars() { RequireServer.Check(); @@ -545,7 +545,7 @@ public void AsQueryable() "{ 'G' : { '$elemMatch' : { 'D' : \"Don't\" } } }"); } - [SkippableFact] + [Fact] public void BitsAllClear_with_bitwise_operators() { RequireServer.Check(); @@ -556,7 +556,7 @@ public void BitsAllClear_with_bitwise_operators() "{'C.E.F': { $bitsAllClear: 20 } }"); } - [SkippableFact] + [Fact] public void BitsAllSet_with_bitwise_operators() { RequireServer.Check(); @@ -567,7 +567,7 @@ public void BitsAllSet_with_bitwise_operators() "{'C.E.F': { $bitsAllSet: 7 } }"); } - [SkippableFact] + [Fact] public void BitsAllSet_with_HasFlag() { RequireServer.Check(); @@ -578,7 +578,7 @@ public void BitsAllSet_with_HasFlag() "{Q: { $bitsAllSet: 1 } }"); } - [SkippableFact] + [Fact] public void BitsAnyClear_with_bitwise_operators() { RequireServer.Check(); @@ -589,7 +589,7 @@ public void BitsAnyClear_with_bitwise_operators() "{'C.E.F': { $bitsAnyClear: 7 } }"); } - [SkippableFact] + [Fact] public void BitsAnySet_with_bitwise_operators() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/MongoQueryableTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/MongoQueryableTests.cs index 054d5df1405..a8ca9fecff6 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/MongoQueryableTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/MongoQueryableTests.cs @@ -189,7 +189,7 @@ public async Task CountAsync_with_no_matches() result.Should().Be(0); } - [SkippableFact] + [Fact] public void Distinct_document_followed_by_where() { RequireServer.Check(); @@ -204,7 +204,7 @@ public void Distinct_document_followed_by_where() "{ $match: { A: 'Awesome' } }"); } - [SkippableFact] + [Fact] public void Distinct_document_preceded_by_select_where() { RequireServer.Check(); @@ -221,7 +221,7 @@ public void Distinct_document_preceded_by_select_where() "{ $replaceRoot : { newRoot : '$_id' } }"); } - [SkippableFact] + [Fact] public void Distinct_document_preceded_by_where_select() { RequireServer.Check(); @@ -238,7 +238,7 @@ public void Distinct_document_preceded_by_where_select() "{ $replaceRoot : { newRoot : '$_id' } }"); } - [SkippableFact] + [Fact] public void Distinct_field_preceded_by_where_select() { RequireServer.Check(); @@ -255,7 +255,7 @@ public void Distinct_field_preceded_by_where_select() "{ $replaceRoot : { newRoot : '$_id' } }"); } - [SkippableFact] + [Fact] public void Distinct_field_preceded_by_select_where() { RequireServer.Check(); @@ -549,7 +549,7 @@ public void GroupBy_with_resultSelector_anonymous_type_method2() "{ $project : { Key : '$_id', FirstB : '$__agg0', _id : 0 } }"); } - [SkippableFact] + [Fact] public void GroupJoin_method() { RequireServer.Check(); @@ -567,7 +567,7 @@ public void GroupJoin_method() "{ $project : { p : '$_outer', o : '$_inner', _id : 0 } }"); } - [SkippableFact] + [Fact] public void GroupJoinForeignField_method() { RequireServer.Check(); @@ -585,7 +585,7 @@ public void GroupJoinForeignField_method() "{ $project : { p : '$_outer', o : '$_inner', _id : 0 } }"); } - [SkippableFact] + [Fact] public void GroupJoin_syntax() { RequireServer.Check(); @@ -600,7 +600,7 @@ public void GroupJoin_syntax() "{ $project : { A : '$_outer.A', SumCEF : { $sum : '$_inner.CEF' }, _id : 0 } }"); } - [SkippableFact] + [Fact] public void GroupJoin_syntax_with_a_transparent_identifier() { RequireServer.Check(); @@ -618,7 +618,7 @@ orderby p.B "{ $project : { A : '$p.A', Joined : '$joined', _id : 0 } }"); } - [SkippableFact] + [Fact] public void GroupJoin_syntax_with_select_many() { RequireServer.Check(); @@ -637,7 +637,7 @@ public void GroupJoin_syntax_with_select_many() "{ $unwind : '$_v' }"); } - [SkippableFact] + [Fact] public void GroupJoin_syntax_with_select_many_and_DefaultIfEmpty() { RequireServer.Check(); @@ -656,7 +656,7 @@ public void GroupJoin_syntax_with_select_many_and_DefaultIfEmpty() "{ $unwind : '$_v' }"); } - [SkippableFact] + [Fact] public void Join_method() { RequireServer.Check(); @@ -675,7 +675,7 @@ public void Join_method() "{ $project : { p : '$_outer', o : '$_inner', _id : 0 } }"); } - [SkippableFact] + [Fact] public void JoinForeignField_method() { RequireServer.Check(); @@ -694,7 +694,7 @@ public void JoinForeignField_method() "{ $project : { p : '$_outer', o : '$_inner', _id : 0 } }"); } - [SkippableFact] + [Fact] public void Join_syntax() { RequireServer.Check(); @@ -710,7 +710,7 @@ public void Join_syntax() "{ $project : { A : '$_outer.A', CEF : '$_inner.CEF', _id : 0 } }"); } - [SkippableFact] + [Fact] public void Join_syntax_with_a_transparent_identifier() { RequireServer.Check(); @@ -961,7 +961,7 @@ public void OrderBy_ThenBy_ThenByDescending_with_redundant_fields_in_different_d act.ShouldThrow(); } - [SkippableFact] + [Fact] public void Sample() { RequireServer.Check(); @@ -972,7 +972,7 @@ public void Sample() "{ $sample: { size: 100 } }"); } - [SkippableFact] + [Fact] public void Sample_after_another_function() { RequireServer.Check(); @@ -1032,7 +1032,7 @@ public void Select_method_computed_scalar_followed_by_where() "{ $match : { _v : 'Awesome Balloon' } }"); } - [SkippableFact] + [Fact] public void Select_method_with_predicated_any() { RequireServer.Check(); @@ -1154,7 +1154,7 @@ public void Select_syntax_array() "{ $project : { _v : '$M', _id : 0 } }"); } - [SkippableFact] + [Fact] public void Select_method_array_index() { RequireServer.Check(); @@ -1165,7 +1165,7 @@ public void Select_method_array_index() "{ $project : { _v : { $arrayElemAt : ['$M', 0] }, _id : 0 } }"); } - [SkippableFact] + [Fact] public void Select_syntax_array_index() { RequireServer.Check(); @@ -1177,7 +1177,7 @@ public void Select_syntax_array_index() "{ $project : { _v : { $arrayElemAt : ['$M', 0] }, _id : 0 } }"); } - [SkippableFact] + [Fact] public void Select_method_embedded_pipeline() { RequireServer.Check(); @@ -1188,7 +1188,7 @@ public void Select_method_embedded_pipeline() "{ $project : { _v : { $arrayElemAt : ['$M', 0] }, _id : 0 } }"); } - [SkippableFact] + [Fact] public void Select_method_computed_array() { RequireServer.Check(); @@ -1200,7 +1200,7 @@ public void Select_method_computed_array() "{ $project : { _v : { $map : { input : '$M', as : 'i', in : { $add : ['$$i', 1] } } }, _id : 0 } }"); } - [SkippableFact] + [Fact] public void Select_syntax_computed_array() { RequireServer.Check(); @@ -1645,7 +1645,7 @@ public void Skip() "{ $skip: 10 }"); } - [SkippableFact] + [Fact] public void StandardDeviationPopulation() { RequireServer.Check(); @@ -1655,7 +1655,7 @@ public void StandardDeviationPopulation() result.Should().Be(50); } - [SkippableFact] + [Fact] public void StandardDeviationPopulation_with_selector() { RequireServer.Check(); @@ -1665,7 +1665,7 @@ public void StandardDeviationPopulation_with_selector() result.Should().Be(50); } - [SkippableFact] + [Fact] public async Task StandardDeviationPopulationAsync() { RequireServer.Check(); @@ -1675,7 +1675,7 @@ public async Task StandardDeviationPopulationAsync() result.Should().Be(50); } - [SkippableFact] + [Fact] public async Task StandardDeviationPopulationAsync_with_selector() { RequireServer.Check(); @@ -1685,7 +1685,7 @@ public async Task StandardDeviationPopulationAsync_with_selector() result.Should().Be(50); } - [SkippableFact] + [Fact] public void StandardDeviationSample() { RequireServer.Check(); @@ -1695,7 +1695,7 @@ public void StandardDeviationSample() result.Should().BeApproximately(70.7106781186548, .0001); } - [SkippableFact] + [Fact] public void StandardDeviationSample_with_selector() { RequireServer.Check(); @@ -1705,7 +1705,7 @@ public void StandardDeviationSample_with_selector() result.Should().BeApproximately(70.7106781186548, .0001); } - [SkippableFact] + [Fact] public async Task StandardDeviationSampleAsync() { RequireServer.Check(); @@ -1715,7 +1715,7 @@ public async Task StandardDeviationSampleAsync() result.Should().BeApproximately(70.7106781186548, .0001); } - [SkippableFact] + [Fact] public async Task StandardDeviationSampleAsync_with_selector() { RequireServer.Check(); @@ -1818,7 +1818,7 @@ public void Where_method_with_predicated_any() "{ $match : { 'G' : { '$elemMatch' : { 'D' : \"Don't\" } } } }"); } - [SkippableFact] + [Fact] public void AsQueryable_in_transaction() { RequireServer.Check().ClusterTypes(ClusterType.ReplicaSet, ClusterType.Sharded).Supports(Feature.Transactions); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/AggregateGroupTranslatorTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/AggregateGroupTranslatorTests.cs index 1d2734c74fa..891be65801b 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/AggregateGroupTranslatorTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/AggregateGroupTranslatorTests.cs @@ -387,7 +387,7 @@ public void Should_translate_push_with_ToList() result.Value.Result.Should().Equal(111); } - [SkippableFact] + [Fact] public void Should_translate_stdDevPop_with_embedded_projector() { RequireServer.Check(); @@ -402,7 +402,7 @@ public void Should_translate_stdDevPop_with_embedded_projector() result.Value.Result.Should().Be(50); } - [SkippableFact] + [Fact] public void Should_translate_stdDevPop_with_selected_projector() { RequireServer.Check(); @@ -417,7 +417,7 @@ public void Should_translate_stdDevPop_with_selected_projector() result.Value.Result.Should().Be(50); } - [SkippableFact] + [Fact] public void Should_translate_stdDevSamp_with_embedded_projector() { RequireServer.Check(); @@ -432,7 +432,7 @@ public void Should_translate_stdDevSamp_with_embedded_projector() result.Value.Result.Should().BeApproximately(70.7106781156545, .0001); } - [SkippableFact] + [Fact] public void Should_translate_stdDevSamp_with_selected_projector() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/AggregateProjectTranslatorTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/AggregateProjectTranslatorTests.cs index 5a3e43ddd72..197cd04eac2 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/AggregateProjectTranslatorTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/AggregateProjectTranslatorTests.cs @@ -58,7 +58,7 @@ public void Should_translate_using_non_anonymous_type_with_parameterized_constru result.Value.Field.Should().Be("Balloon"); } - [SkippableFact] + [Fact] public void Should_translate_abs() { RequireServer.Check(); @@ -89,7 +89,7 @@ public void Should_translate_add_flattened() result.Value.Result.Should().Be(43); } - [SkippableFact] + [Fact] public void Should_translate_allElementsTrue() { RequireServer.Check(); @@ -101,7 +101,7 @@ public void Should_translate_allElementsTrue() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_anyElementTrue() { RequireServer.Check(); @@ -113,7 +113,7 @@ public void Should_translate_anyElementTrue() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_anyElementTrue_with_predicate() { RequireServer.Check(); @@ -125,7 +125,7 @@ public void Should_translate_anyElementTrue_with_predicate() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_anyElementTrue_using_Contains() { RequireServer.Check(); @@ -137,7 +137,7 @@ public void Should_translate_anyElementTrue_using_Contains() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_anyElementTrue_using_Contains_on_a_local_collection() { RequireServer.Check(); @@ -170,7 +170,7 @@ public void Should_translate_and_flattened() result.Value.Result.Should().BeFalse(); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_constant_ElementAt() { RequireServer.Check(); @@ -182,7 +182,7 @@ public void Should_translate_arrayElemAt_using_a_constant_ElementAt() result.Value.Result.Should().Be(4); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_constant_indexer() { RequireServer.Check(); @@ -194,7 +194,7 @@ public void Should_translate_arrayElemAt_using_a_constant_indexer() result.Value.Result.Should().Be(4); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_constant_get_Item() { RequireServer.Check(); @@ -206,7 +206,7 @@ public void Should_translate_arrayElemAt_using_a_constant_get_Item() result.Value.Result.Should().Be(20); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_variable_ElementAt() { RequireServer.Check(); @@ -218,7 +218,7 @@ public void Should_translate_arrayElemAt_using_a_variable_ElementAt() result.Value.Result.Should().Be(4); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_variable_indexer() { RequireServer.Check(); @@ -230,7 +230,7 @@ public void Should_translate_arrayElemAt_using_a_variable_indexer() result.Value.Result.Should().Be(4); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_variable_get_Item() { RequireServer.Check(); @@ -242,7 +242,7 @@ public void Should_translate_arrayElemAt_using_a_variable_get_Item() result.Value.Result.Should().Be(20); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_constant_ElementAt_followed_by_a_field() { RequireServer.Check(); @@ -254,7 +254,7 @@ public void Should_translate_arrayElemAt_using_a_constant_ElementAt_followed_by_ result.Value.Result.Should().Be("Dolphin"); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_a_variable_ElementAt_followed_by_a_field() { RequireServer.Check(); @@ -266,7 +266,7 @@ public void Should_translate_arrayElemAt_using_a_variable_ElementAt_followed_by_ result.Value.Result.Should().Be("Dolphin"); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_First() { RequireServer.Check(); @@ -278,7 +278,7 @@ public void Should_translate_arrayElemAt_using_First() result.Value.Result.Should().Be(2); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_First_followed_by_a_field() { RequireServer.Check(); @@ -290,7 +290,7 @@ public void Should_translate_arrayElemAt_using_First_followed_by_a_field() result.Value.Result.Should().Be("Don't"); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_Last() { RequireServer.Check(); @@ -302,7 +302,7 @@ public void Should_translate_arrayElemAt_using_Last() result.Value.Result.Should().Be(5); } - [SkippableFact] + [Fact] public void Should_translate_arrayElemAt_using_Last_followed_by_a_field() { RequireServer.Check(); @@ -314,7 +314,7 @@ public void Should_translate_arrayElemAt_using_Last_followed_by_a_field() result.Value.Result.Should().Be("Dolphin"); } - [SkippableFact] + [Fact] public void Should_translate_avg() { RequireServer.Check(); @@ -326,7 +326,7 @@ public void Should_translate_avg() result.Value.Result.Should().BeApproximately(3.66666667, .0001); } - [SkippableFact] + [Fact] public void Should_translate_avg_with_selector() { RequireServer.Check(); @@ -338,7 +338,7 @@ public void Should_translate_avg_with_selector() result.Value.Result.Should().Be(44); } - [SkippableFact] + [Fact] public void Should_translate_boolToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -350,7 +350,7 @@ public void Should_translate_boolToString() result.Value.Result.Should().Be("true"); } - [SkippableFact] + [Fact] public void Should_translate_ceil() { RequireServer.Check(); @@ -382,7 +382,7 @@ public void Should_translate_compare() result.Value.Result.Should().Be(0); } - [SkippableFact] + [Fact] public void Should_translate_concat() { RequireServer.Check(); @@ -394,7 +394,7 @@ public void Should_translate_concat() result.Value.Result.Should().Be("AwesomeBalloon"); } - [SkippableFact] + [Fact] public void Should_translate_concat_flattened() { RequireServer.Check(); @@ -406,7 +406,7 @@ public void Should_translate_concat_flattened() result.Value.Result.Should().Be("Awesome Balloon"); } - [SkippableFact] + [Fact] public void Should_translate_concatArrays() { RequireServer.Check(); @@ -428,7 +428,7 @@ public void Should_translate_condition() result.Value.Result.Should().Be("b"); } - [SkippableFact] + [Fact] public void Should_translate_dateTimeToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -440,7 +440,7 @@ public void Should_translate_dateTimeToString() result.Value.Result.Should().Be("2012-12-01T13:14:15.016Z"); } - [SkippableFact] + [Fact] public void Should_translate_dateToString() { RequireServer.Check(); @@ -482,7 +482,7 @@ public void Should_translate_day_of_year() result.Value.Result.Should().Be(336); } - [SkippableFact] + [Fact] public void Should_translate_decimalToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -514,7 +514,7 @@ public void Should_translate_divide_3_numbers() result.Value.Result.Should().BeApproximately(0.04, .01); } - [SkippableFact] + [Fact] public void Should_translate_doubleToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -546,7 +546,7 @@ public void Should_translate_equals_as_a_method_call() result.Value.Result.Should().BeFalse(); } - [SkippableFact] + [Fact] public void Should_translate_exp() { RequireServer.Check(); @@ -558,7 +558,7 @@ public void Should_translate_exp() result.Value.Result.Should().BeApproximately(59874.1417151978, .0001); } - [SkippableFact] + [Fact] public void Should_translate_floor() { RequireServer.Check(); @@ -600,7 +600,7 @@ public void Should_translate_hour() result.Value.Result.Should().Be(13); } - [SkippableFact] + [Fact] public void Should_translate_indexOfBytes() { RequireServer.Check(); @@ -618,7 +618,7 @@ public void Should_translate_indexOfBytes() result.Value.Result.Should().Be(-1); } - [SkippableFact] + [Fact] public void Should_translate_indexOfCP() { RequireServer.Check(); @@ -648,7 +648,7 @@ public void Should_translate_indexOfCP() result.Value.Result.Should().Be(-1); } - [SkippableFact] + [Fact] public void Should_translate_intToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -680,7 +680,7 @@ public void Should_translate_less_than_or_equal() result.Value.Result.Should().BeFalse(); } - [SkippableFact] + [Fact] public void Should_translate_literal_when_a_constant_strings_begins_with_a_dollar() { RequireServer.Check(); @@ -692,7 +692,7 @@ public void Should_translate_literal_when_a_constant_strings_begins_with_a_dolla result.Value.Result.Should().BeFalse(); } - [SkippableFact] + [Fact] public void Should_translate_ln() { RequireServer.Check(); @@ -704,7 +704,7 @@ public void Should_translate_ln() result.Value.Result.Should().BeApproximately(2.39789527279837, .0001); } - [SkippableFact] + [Fact] public void Should_translate_log() { RequireServer.Check(); @@ -716,7 +716,7 @@ public void Should_translate_log() result.Value.Result.Should().Be(1); } - [SkippableFact] + [Fact] public void Should_translate_log10() { RequireServer.Check(); @@ -728,7 +728,7 @@ public void Should_translate_log10() result.Value.Result.Should().BeApproximately(1.0413928515823, .0001); } - [SkippableFact] + [Fact] public void Should_translate_longToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -740,7 +740,7 @@ public void Should_translate_longToString() result.Value.Result.Should().Be("9"); } - [SkippableFact] + [Fact] public void Should_translate_map_with_document() { RequireServer.Check(); @@ -752,7 +752,7 @@ public void Should_translate_map_with_document() result.Value.Result.Should().Equal("Don't0", "Dolphin0"); } - [SkippableFact] + [Fact] public void Should_translate_map_with_value() { RequireServer.Check(); @@ -764,7 +764,7 @@ public void Should_translate_map_with_value() result.Value.Result.Should().Equal("it0", "icky0"); } - [SkippableFact] + [Fact] public void Should_translate_max() { RequireServer.Check(); @@ -776,7 +776,7 @@ public void Should_translate_max() result.Value.Result.Should().Be(5); } - [SkippableFact] + [Fact] public void Should_translate_max_with_selector() { RequireServer.Check(); @@ -788,7 +788,7 @@ public void Should_translate_max_with_selector() result.Value.Result.Should().Be(55); } - [SkippableFact] + [Fact] public void Should_translate_millisecond() { RequireServer.Check(); @@ -800,7 +800,7 @@ public void Should_translate_millisecond() result.Value.Result.Should().Be(16); } - [SkippableFact] + [Fact] public void Should_translate_min() { RequireServer.Check(); @@ -812,7 +812,7 @@ public void Should_translate_min() result.Value.Result.Should().Be(2); } - [SkippableFact] + [Fact] public void Should_translate_min_with_selector() { RequireServer.Check(); @@ -874,7 +874,7 @@ public void Should_translate_multiply_flattened() result.Value.Result.Should().Be(2420); } - [SkippableFact] + [Fact] public void Should_translate_new_DateTime() { RequireServer.Check(); @@ -922,7 +922,7 @@ public void Should_translate_not_equals() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_objectIdToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -954,7 +954,7 @@ public void Should_translate_or_flattened() result.Value.Result.Should().BeFalse(); } - [SkippableFact] + [Fact] public void Should_translate_DateTime_parse() { RequireServer.Check(); @@ -966,7 +966,7 @@ public void Should_translate_DateTime_parse() result.Value.Result.Should().Be(new DateTime(2017, 2, 8, 12, 10, 40, 787, DateTimeKind.Utc)); } - [SkippableFact] + [Fact] public void Should_translate_pow() { RequireServer.Check(); @@ -978,7 +978,7 @@ public void Should_translate_pow() result.Value.Result.Should().Be(161051); } - [SkippableFact] + [Fact] public void Should_translate_range() { RequireServer.Check(); @@ -990,7 +990,7 @@ public void Should_translate_range() result.Value.Result.Should().BeEquivalentTo(11, 12, 13); } - [SkippableFact] + [Fact] public void Should_translate_reduce() { RequireServer.Check(); @@ -1111,7 +1111,7 @@ public void Should_translate_reduce() typeResult.Value.Result.y.Should().Be(5); } - [SkippableFact] + [Fact] public void Should_translate_reverse() { RequireServer.Check(); @@ -1133,7 +1133,7 @@ public void Should_translate_second() result.Value.Result.Should().Be(15); } - [SkippableFact] + [Fact] public void Should_translate_size_greater_than_zero_from_any() { RequireServer.Check(); @@ -1145,7 +1145,7 @@ public void Should_translate_size_greater_than_zero_from_any() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_size_from_an_array() { RequireServer.Check(); @@ -1157,7 +1157,7 @@ public void Should_translate_size_from_an_array() result.Value.Result.Should().Be(3); } - [SkippableFact] + [Fact] public void Should_translate_size_from_Count_extension_method() { RequireServer.Check(); @@ -1169,7 +1169,7 @@ public void Should_translate_size_from_Count_extension_method() result.Value.Result.Should().Be(3); } - [SkippableFact] + [Fact] public void Should_translate_size_from_LongCount_extension_method() { RequireServer.Check(); @@ -1181,7 +1181,7 @@ public void Should_translate_size_from_LongCount_extension_method() result.Value.Result.Should().Be(3); } - [SkippableFact] + [Fact] public void Should_translate_size_from_Count_property_on_Generic_ICollection() { RequireServer.Check(); @@ -1193,7 +1193,7 @@ public void Should_translate_size_from_Count_property_on_Generic_ICollection() result.Value.Result.Should().Be(3); } - [SkippableFact] + [Fact] public void Should_translate_set_difference() { RequireServer.Check(); @@ -1205,7 +1205,7 @@ public void Should_translate_set_difference() result.Value.Result.Should().Equal("icky"); } - [SkippableFact] + [Fact] public void Should_translate_set_difference_reversed() { RequireServer.Check(); @@ -1217,7 +1217,7 @@ public void Should_translate_set_difference_reversed() result.Value.Result.Should().Equal("not in here"); } - [SkippableFact] + [Fact] public void Should_translate_set_equals() { RequireServer.Check(); @@ -1229,7 +1229,7 @@ public void Should_translate_set_equals() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_set_equals_reversed() { RequireServer.Check(); @@ -1242,7 +1242,7 @@ public void Should_translate_set_equals_reversed() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_set_intersection() { RequireServer.Check(); @@ -1254,7 +1254,7 @@ public void Should_translate_set_intersection() result.Value.Result.Should().Equal("it"); } - [SkippableFact] + [Fact] public void Should_translate_set_intersection_reversed() { RequireServer.Check(); @@ -1266,7 +1266,7 @@ public void Should_translate_set_intersection_reversed() result.Value.Result.Should().Equal("it"); } - [SkippableFact] + [Fact] public void Should_translate_set_is_subset() { RequireServer.Check(); @@ -1278,7 +1278,7 @@ public void Should_translate_set_is_subset() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_set_is_subset_reversed() { RequireServer.Check(); @@ -1291,7 +1291,7 @@ public void Should_translate_set_is_subset_reversed() result.Value.Result.Should().BeTrue(); } - [SkippableFact] + [Fact] public void Should_translate_set_union() { RequireServer.Check(); @@ -1303,7 +1303,7 @@ public void Should_translate_set_union() result.Value.Result.Should().BeEquivalentTo("it", "icky", "not in here"); } - [SkippableFact] + [Fact] public void Should_translate_set_union_reversed() { RequireServer.Check(); @@ -1315,7 +1315,7 @@ public void Should_translate_set_union_reversed() result.Value.Result.Should().BeEquivalentTo("it", "icky", "not in here"); } - [SkippableFact] + [Fact] public void Should_translate_sqrt() { RequireServer.Check(); @@ -1327,7 +1327,7 @@ public void Should_translate_sqrt() result.Value.Result.Should().BeApproximately(3.31662479, .0001); } - [SkippableFact] + [Fact] public void Should_translate_stringToString() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -1339,7 +1339,7 @@ public void Should_translate_stringToString() result.Value.Result.Should().Be("Awesome"); } - [SkippableFact] + [Fact] public void Should_translate_trunc() { RequireServer.Check(); @@ -1351,7 +1351,7 @@ public void Should_translate_trunc() result.Value.Result.Should().Be(1); } - [SkippableFact] + [Fact] public void Should_translate_where_to_filter() { RequireServer.Check(); @@ -1364,7 +1364,7 @@ public void Should_translate_where_to_filter() result.Value.Result.Single().D.Should().Be("Don't"); } - [SkippableFact] + [Fact] public void Should_translate_where_then_select_to_filter_then_map() { RequireServer.Check(); @@ -1377,7 +1377,7 @@ public void Should_translate_where_then_select_to_filter_then_map() result.Value.Result.Single().Should().Be("Don't"); } - [SkippableFact] + [Fact] public void Should_translate_select_then_where_to_map_then_filter() { RequireServer.Check(); @@ -1390,7 +1390,7 @@ public void Should_translate_select_then_where_to_map_then_filter() result.Value.Result.Single().Should().Be("Don't"); } - [SkippableFact] + [Fact] public void Should_translate_select_with_an_anonymous_type_then_where_to_map_then_filter() { RequireServer.Check(); @@ -1404,7 +1404,7 @@ public void Should_translate_select_with_an_anonymous_type_then_where_to_map_the result.Value.Result.Single().F.Should().Be(33); } - [SkippableFact] + [Fact] public void Should_translate_strLenBytes() { RequireServer.Check(); @@ -1416,7 +1416,7 @@ public void Should_translate_strLenBytes() result.Value.Result.Should().Be(7); } - [SkippableFact] + [Fact] public void Should_translate_strLenCP() { RequireServer.Check(); @@ -1428,7 +1428,7 @@ public void Should_translate_strLenCP() result.Value.Result.Should().Be(7); } - [SkippableFact] + [Fact] public void Should_translate_split() { RequireServer.Check(); @@ -1454,7 +1454,7 @@ public void Should_translate_split() result4.Value.Result.Should().BeEquivalentTo("Aw", "ome"); } - [SkippableFact] + [Fact] public void Should_translate_stdDevPop() { RequireServer.Check(); @@ -1466,7 +1466,7 @@ public void Should_translate_stdDevPop() result.Value.Result.Should().BeApproximately(1.247219128924647, .0001); } - [SkippableFact] + [Fact] public void Should_translate_stdDevPop_with_selector() { RequireServer.Check(); @@ -1478,7 +1478,7 @@ public void Should_translate_stdDevPop_with_selector() result.Value.Result.Should().Be(11); } - [SkippableFact] + [Fact] public void Should_translate_stdDevSamp() { RequireServer.Check(); @@ -1490,7 +1490,7 @@ public void Should_translate_stdDevSamp() result.Value.Result.Should().BeApproximately(1.5275252316519468, .0001); } - [SkippableFact] + [Fact] public void Should_translate_stdDevSamp_with_selector() { RequireServer.Check(); @@ -1562,7 +1562,7 @@ public void Should_translate_substr() result.Value.Result.Should().Be("loon"); } - [SkippableFact] + [Fact] public void Should_translate_substrBytes() { RequireServer.Check(); @@ -1594,7 +1594,7 @@ public void Should_translate_subtract_3_numbers() result.Value.Result.Should().Be(-23); } - [SkippableFact] + [Fact] public void Should_translate_slice_with_2_arguments() { RequireServer.Check(); @@ -1606,7 +1606,7 @@ public void Should_translate_slice_with_2_arguments() result.Value.Result.Should().BeEquivalentTo(2, 4); } - [SkippableFact] + [Fact] public void Should_translate_slice_with_3_arguments() { RequireServer.Check(); @@ -1618,7 +1618,7 @@ public void Should_translate_slice_with_3_arguments() result.Value.Result.Should().BeEquivalentTo(4, 5); } - [SkippableFact] + [Fact] public void Should_translate_sum() { RequireServer.Check(); @@ -1630,7 +1630,7 @@ public void Should_translate_sum() result.Value.Result.Should().Be(11); } - [SkippableFact] + [Fact] public void Should_translate_sum_with_selector() { RequireServer.Check(); @@ -1692,7 +1692,7 @@ public void Should_translate_year() result.Value.Result.Should().Be(2012); } - [SkippableFact] + [Fact] public void Should_translate_zip_with_operation() { RequireServer.Check(); @@ -1704,7 +1704,7 @@ public void Should_translate_zip_with_operation() result.Value.Result.Should().BeEquivalentTo(12L, 24L, 35L); } - [SkippableFact] + [Fact] public void Should_translate_zip_with_anonymous_type() { RequireServer.Check(); @@ -1741,7 +1741,7 @@ public void Should_translate_a_derived_class_projection() result.Value.DerivedProperty.Should().Be("Balloon"); } - [SkippableFact] + [Fact] public void Should_translate_array_projection_complex() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/PredicateTranslatorTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/PredicateTranslatorTests.cs index e77c83ccb84..9df49eb2bd7 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/PredicateTranslatorTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/PredicateTranslatorTests.cs @@ -479,7 +479,7 @@ public void Any_with_a_predicate_on_scalars_legacy() "{ M : { $elemMatch : { $gt : 2, $lt : 6 } } }"); } - [SkippableFact] + [Fact] public void Any_with_a_predicate_on_scalars() { RequireServer.Check(); @@ -551,7 +551,7 @@ public void AsQueryable() exception.Should().BeOfType(); } - [SkippableFact] + [Fact] public void BitsAllClear_with_bitwise_operators() { RequireServer.Check(); @@ -562,7 +562,7 @@ public void BitsAllClear_with_bitwise_operators() "{'C.E.F': { $bitsAllClear: 20 } }"); } - [SkippableFact] + [Fact] public void BitsAllSet_with_bitwise_operators() { RequireServer.Check(); @@ -573,7 +573,7 @@ public void BitsAllSet_with_bitwise_operators() "{'C.E.F': { $bitsAllSet: 7 } }"); } - [SkippableFact] + [Fact] public void BitsAllSet_with_HasFlag() { RequireServer.Check(); @@ -584,7 +584,7 @@ public void BitsAllSet_with_HasFlag() "{Q: { $bitsAllSet: 1 } }"); } - [SkippableFact] + [Fact] public void BitsAnyClear_with_bitwise_operators() { RequireServer.Check(); @@ -595,7 +595,7 @@ public void BitsAnyClear_with_bitwise_operators() "{'C.E.F': { $bitsAnyClear: 7 } }"); } - [SkippableFact] + [Fact] public void BitsAnySet_with_bitwise_operators() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2422Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2422Tests.cs index 55d2953a783..0b0830f21a3 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2422Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2422Tests.cs @@ -16,7 +16,7 @@ using System; using System.Linq; using System.Linq.Expressions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests.Linq.Linq3ImplementationTests.Jira diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2471Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2471Tests.cs index eb5ff8b6733..955db82f8b8 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2471Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2471Tests.cs @@ -26,7 +26,7 @@ namespace MongoDB.Driver.Tests.Linq.Linq3ImplementationTests.Jira { public class CSharp2471Tests : Linq3IntegrationTest { - [SkippableTheory] + [Theory] [InlineData("$acos", 1.0, 0.0)] #if NETCOREAPP3_1_OR_GREATER [InlineData("$acosh", 1.0, 0.0)] @@ -88,7 +88,7 @@ public void Trig_method_should_work(string trigOperator, double x, double expect result.Should().Be(expectedResult); } - [SkippableFact] + [Fact] public void Atan2_should_work() { RequireServer.Check().Supports(Feature.TrigOperators); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2472Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2472Tests.cs index e2e3aa43afd..469b9f301aa 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2472Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2472Tests.cs @@ -25,7 +25,7 @@ namespace MongoDB.Driver.Tests.Linq.Linq3ImplementationTests.Jira { public class CSharp2472Tests : Linq3IntegrationTest { - [SkippableFact] + [Fact] public void Numeric_casts_should_work() { RequireServer.Check().Supports(Feature.ToConversionOperators); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2727Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2727Tests.cs index 4d44e3dc079..a86863f8a36 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2727Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp2727Tests.cs @@ -27,7 +27,7 @@ namespace MongoDB.Driver.Tests.Linq.Linq3ImplementationTests.Jira { public class CSharp2727Tests : Linq3IntegrationTest { - [SkippableFact] + [Fact] public void Find_with_predicate_on_Body_should_work() { RequireServer.Check().Supports(Feature.AggregateToString); @@ -64,7 +64,7 @@ public void Find_with_predicate_on_Caption_should_work() results.Select(x => x.Id).Should().Equal(1, 2); } - [SkippableFact] + [Fact] public void Where_with_predicate_on_Body_should_work() { RequireServer.Check().Supports(Feature.AggregateToString); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3136Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3136Tests.cs index 1c8777585bc..bb392e08c06 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3136Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3136Tests.cs @@ -26,7 +26,7 @@ namespace MongoDB.Driver.Tests.Linq.Linq3ImplementationTests.Jira public class CSharp3136Tests : Linq3IntegrationTest { - [SkippableFact] + [Fact] public void DateTime_ToString_with_no_arguments_should_work() { RequireServer.Check().Supports(Feature.ToConversionOperators); @@ -68,7 +68,7 @@ public void DateTime_ToString_with_format_should_work() results.Should().Equal("03:04:05", "03:04:05"); } - [SkippableTheory] + [Theory] [InlineData(null, null, "{ $project : { _v : { $dateToString : { date : '$D' } }, _id : 0 } }", new[] { "2021-01-02T03:04:05.123Z", "2021-01-02T03:04:05.123Z" })] [InlineData("%H:%M:%S", null, "{ $project : { _v : { $dateToString : { date : '$D', format : '%H:%M:%S' } }, _id : 0 } }", new[] { "03:04:05", "03:04:05" })] [InlineData(null, "-04:00", "{ $project : { _v : { $dateToString : { date : '$D', timezone : '-04:00' } }, _id : 0 } }", new[] { "2021-01-01T23:04:05.123Z", "2021-01-01T23:04:05.123Z" })] @@ -97,7 +97,7 @@ public void DateTime_ToString_with_format_and_timezone_constants_should_work(str results.Should().Equal(expectedResults); } - [SkippableTheory] + [Theory] [InlineData(false, false, "{ $project : { _v : { $dateToString : { date : '$D' } }, _id : 0 } }", new[] { "2021-01-02T03:04:05.123Z", "2021-01-02T03:04:05.123Z" })] [InlineData(true, false, "{ $project : { _v : { $dateToString : { date : '$D', format : '$Format' } }, _id : 0 } }", new[] { "03:04:05", "03:04:05" })] [InlineData(false, true, "{ $project : { _v : { $dateToString : { date : '$D', timezone : '$Timezone' } }, _id : 0 } }", new[] { "2021-01-01T23:04:05.123Z", "2021-01-01T23:04:05.123Z" })] @@ -131,7 +131,7 @@ public void DateTime_ToString_with_format_and_timezone_expressions_should_work(b results.Should().Equal(expectedResults); } - [SkippableFact] + [Fact] public void NullableDateTime_ToString_with_no_arguments_should_work() { RequireServer.Check().Supports(Feature.ToConversionOperators); @@ -153,7 +153,7 @@ public void NullableDateTime_ToString_with_no_arguments_should_work() results.Should().Equal("2021-01-02T03:04:05.123Z", null); } - [SkippableTheory] + [Theory] [InlineData(null, null, null, "{ $project : { _v : { $dateToString : { date : '$N' } }, _id : 0 } }", new[] { "2021-01-02T03:04:05.123Z", null })] [InlineData(null, null, "xx", "{ $project : { _v : { $dateToString : { date : '$N', onNull : 'xx' } }, _id : 0 } }", new[] { "2021-01-02T03:04:05.123Z", "xx" })] [InlineData("%H:%M:%S", null, null, "{ $project : { _v : { $dateToString : { date : '$N', format : '%H:%M:%S' } }, _id : 0 } }", new[] { "03:04:05", null })] @@ -186,7 +186,7 @@ public void NullableDateTime_ToString_with_format_and_timezone_and_onNull_consta results.Should().Equal(expectedResults); } - [SkippableTheory] + [Theory] [InlineData(false, false, false, "{ $project : { _v : { $dateToString : { date : '$N' } }, _id : 0 } }", new[] { "2021-01-02T03:04:05.123Z", null })] [InlineData(false, false, true, "{ $project : { _v : { $dateToString : { date : '$N', onNull : '$OnNull' } }, _id : 0 } }", new[] { "2021-01-02T03:04:05.123Z", "missing" })] [InlineData(false, true, false, "{ $project : { _v : { $dateToString : { date : '$N', timezone : '$Timezone' } }, _id : 0 } }", new[] { "2021-01-01T23:04:05.123Z", null })] diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3933Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3933Tests.cs index ab279de2f1c..422fc3f4f3b 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3933Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3933Tests.cs @@ -18,7 +18,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using MongoDB.Driver.Linq.Linq3Implementation.Serializers; using Xunit; diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4079Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4079Tests.cs index 5a7a29df111..babd22cbe2e 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4079Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4079Tests.cs @@ -17,7 +17,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.Serialization; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using Xunit; diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4220Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4220Tests.cs index 197a42897a5..54592dd93e6 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4220Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4220Tests.cs @@ -20,7 +20,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using Xunit; diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4234Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4234Tests.cs index 02c635a983f..2ad1802e53b 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4234Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4234Tests.cs @@ -16,7 +16,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using Xunit; diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4244Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4244Tests.cs index 6b43ddee881..86bbb1c5f48 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4244Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4244Tests.cs @@ -23,7 +23,7 @@ namespace MongoDB.Driver.Tests.Linq.Linq3ImplementationTests.Jira { public class CSharp4244Tests : Linq3IntegrationTest { - [SkippableFact] + [Fact] public void Where_with_root_should_work() { RequireServer.Check().VersionGreaterThanOrEqualTo("6.0"); diff --git a/tests/MongoDB.Driver.Tests/ListDatabasesTests.cs b/tests/MongoDB.Driver.Tests/ListDatabasesTests.cs index de1418c0da0..b4922954423 100644 --- a/tests/MongoDB.Driver.Tests/ListDatabasesTests.cs +++ b/tests/MongoDB.Driver.Tests/ListDatabasesTests.cs @@ -16,7 +16,7 @@ using System; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using Xunit; @@ -30,7 +30,7 @@ public class ListDatabasesTests private string _roleName = $"listDatabases{Guid.NewGuid()}"; private string _userName = $"authorizedDatabases{Guid.NewGuid()}"; - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Execute_should_return_the_expected_result_when_AuthorizedDatabases_is_used( [Values(null, false, true)] bool? authorizedDatabases) diff --git a/tests/MongoDB.Driver.Tests/MongoClientSettingsTests.cs b/tests/MongoDB.Driver.Tests/MongoClientSettingsTests.cs index 1a8fb031a5f..ed64f7d05ea 100644 --- a/tests/MongoDB.Driver.Tests/MongoClientSettingsTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoClientSettingsTests.cs @@ -24,7 +24,7 @@ using Microsoft.Extensions.Logging; using MongoDB.Bson; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Compression; using MongoDB.Driver.Core.Configuration; @@ -1265,7 +1265,7 @@ public void TestServersWithSrvMaxHosts() settings.Servers.Should().HaveCount(2); } - [SkippableFact] + [Fact] public void TestSocketConfigurator() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/MongoClientTests.cs b/tests/MongoDB.Driver.Tests/MongoClientTests.cs index 2a943640a98..e20ade4d073 100644 --- a/tests/MongoDB.Driver.Tests/MongoClientTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoClientTests.cs @@ -21,7 +21,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Clusters.ServerSelectors; diff --git a/tests/MongoDB.Driver.Tests/MongoCollectionImplTests.cs b/tests/MongoDB.Driver.Tests/MongoCollectionImplTests.cs index c3ceaba7e4b..d26bac52729 100644 --- a/tests/MongoDB.Driver.Tests/MongoCollectionImplTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoCollectionImplTests.cs @@ -24,7 +24,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Connections; @@ -3721,7 +3721,7 @@ void assertException(Exception exception) e.ParamName.Should().Be("pipeline"); } - [SkippableFact] + [Fact] public void Watch_should_support_full_document_with_duplicate_elements() { RequireServer.Check().ClusterTypes(ClusterType.ReplicaSet, ClusterType.Sharded); diff --git a/tests/MongoDB.Driver.Tests/MongoDBRefTests.cs b/tests/MongoDB.Driver.Tests/MongoDBRefTests.cs index 2d9753d4aee..04faef99397 100644 --- a/tests/MongoDB.Driver.Tests/MongoDBRefTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoDBRefTests.cs @@ -19,7 +19,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests diff --git a/tests/MongoDB.Driver.Tests/MongoDatabaseImplTests.cs b/tests/MongoDB.Driver.Tests/MongoDatabaseImplTests.cs index 90710661ccf..b9cfbdba878 100644 --- a/tests/MongoDB.Driver.Tests/MongoDatabaseImplTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoDatabaseImplTests.cs @@ -22,7 +22,7 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.Serialization.Serializers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Misc; @@ -897,7 +897,7 @@ public void Settings_should_be_set() op.RetryRequested.Should().BeTrue(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void ListCollectionNames_should_return_expected_result( [Values(0, 1, 2, 10)] int numberOfCollections, diff --git a/tests/MongoDB.Driver.Tests/MongoIndexManagerTests.cs b/tests/MongoDB.Driver.Tests/MongoIndexManagerTests.cs index 8b34b415117..ac5fbef4289 100644 --- a/tests/MongoDB.Driver.Tests/MongoIndexManagerTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoIndexManagerTests.cs @@ -15,7 +15,7 @@ using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Operations; using Xunit; diff --git a/tests/MongoDB.Driver.Tests/MongoUrlBuilderTests.cs b/tests/MongoDB.Driver.Tests/MongoUrlBuilderTests.cs index a44a8dededf..9b16920c6e7 100644 --- a/tests/MongoDB.Driver.Tests/MongoUrlBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoUrlBuilderTests.cs @@ -19,7 +19,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Compression; using MongoDB.Driver.Core.Configuration; diff --git a/tests/MongoDB.Driver.Tests/MongoUrlTests.cs b/tests/MongoDB.Driver.Tests/MongoUrlTests.cs index 961daae3850..3f2c5759ba8 100644 --- a/tests/MongoDB.Driver.Tests/MongoUrlTests.cs +++ b/tests/MongoDB.Driver.Tests/MongoUrlTests.cs @@ -19,7 +19,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Compression; using MongoDB.Driver.Core.Configuration; diff --git a/tests/MongoDB.Driver.Tests/MongocryptdFactoryTests.cs b/tests/MongoDB.Driver.Tests/MongocryptdFactoryTests.cs index 885c7cbc579..5364e974b1c 100644 --- a/tests/MongoDB.Driver.Tests/MongocryptdFactoryTests.cs +++ b/tests/MongoDB.Driver.Tests/MongocryptdFactoryTests.cs @@ -63,7 +63,7 @@ public void ShouldMongocryptdBeSpawned_should_correctly_handle_bypassQueryAnalys shouldMongocryptdBeSpawned.Should().Be(shouldBeSpawned); } - [SkippableTheory] + [Theory] [InlineData("{ mongocryptdBypassSpawn : true }", null, null, false)] [InlineData(null, "mongocryptd#extension#", "--idleShutdownTimeoutSecs 60 --logpath #logpath# --logappend", true)] [InlineData("{ mongocryptdBypassSpawn : false }", "mongocryptd#extension#", "--idleShutdownTimeoutSecs 60 --logpath #logpath# --logappend", true)] diff --git a/tests/MongoDB.Driver.Tests/OcspIntegrationTests.cs b/tests/MongoDB.Driver.Tests/OcspIntegrationTests.cs index 9438b1b9f9e..9518f0c10f1 100644 --- a/tests/MongoDB.Driver.Tests/OcspIntegrationTests.cs +++ b/tests/MongoDB.Driver.Tests/OcspIntegrationTests.cs @@ -16,7 +16,7 @@ using System; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.TestHelpers.Logging; using MongoDB.Driver.TestHelpers; using Xunit; @@ -47,7 +47,7 @@ public OcspIntegrationTests(ITestOutputHelper testOutputHelper) * When testing on Windows, the certificate should be added to the trust store prior to each run in order to * reduce the chances of Windows pruning the certificate from the trust store prior to the test running. */ - [SkippableFact] + [Fact] public void MongoClientShouldRespectCertificateStatusAndTlsInsecure() { /* We cannot call RequireServer.Check() because this would result in a connection being made to the mongod diff --git a/tests/MongoDB.Driver.Tests/OfTypeMongoCollectionTests.cs b/tests/MongoDB.Driver.Tests/OfTypeMongoCollectionTests.cs index 6883067a401..725764b2a0f 100644 --- a/tests/MongoDB.Driver.Tests/OfTypeMongoCollectionTests.cs +++ b/tests/MongoDB.Driver.Tests/OfTypeMongoCollectionTests.cs @@ -22,7 +22,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Bindings; using MongoDB.Driver.Core.Events; @@ -1130,7 +1130,7 @@ public OfTypeCollectionIntegrationTests() }); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void UpdateOne_should_match_document_of_right_type( [Values(false, true)] bool upsert, diff --git a/tests/MongoDB.Driver.Tests/PasswordEvidenceTests.cs b/tests/MongoDB.Driver.Tests/PasswordEvidenceTests.cs index 1232fb7d9af..99ae74cea61 100644 --- a/tests/MongoDB.Driver.Tests/PasswordEvidenceTests.cs +++ b/tests/MongoDB.Driver.Tests/PasswordEvidenceTests.cs @@ -16,7 +16,7 @@ using System; using System.Security; using FluentAssertions; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests diff --git a/tests/MongoDB.Driver.Tests/PinnedShardRouterTests.cs b/tests/MongoDB.Driver.Tests/PinnedShardRouterTests.cs index 696f0953274..0395102d27b 100644 --- a/tests/MongoDB.Driver.Tests/PinnedShardRouterTests.cs +++ b/tests/MongoDB.Driver.Tests/PinnedShardRouterTests.cs @@ -18,7 +18,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Events; @@ -56,7 +56,7 @@ public PinnedShardRouterTests(ITestOutputHelper output) : base(output) /// Test that starting a new transaction on a pinned ClientSession unpins the /// session and normal server selection is performed for the next operation. /// - [SkippableTheory] + [Theory] [ParameterAttributeData] public async void Test_Unpin_For_Next_Transaction([Values(false, true)] bool async) { @@ -116,7 +116,7 @@ public async void Test_Unpin_For_Next_Transaction([Values(false, true)] bool asy /// Test non-transaction operations using a pinned ClientSession unpins the /// session and normal server selection is performed. /// - [SkippableTheory] + [Theory] [ParameterAttributeData] public async void Test_Unpin_For_Non_Transaction_Operation([Values(false, true)] bool async) { diff --git a/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs index b8b1762fc73..7a36b216c19 100644 --- a/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/PipelineDefinitionBuilderTests.cs @@ -83,7 +83,7 @@ public void ChangeStream_should_throw_when_pipeline_is_null() argumentNullException.ParamName.Should().Be("pipeline"); } - [SkippableFact] + [Fact] public void Lookup_should_throw_when_pipeline_is_null() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/PipelineStageDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/PipelineStageDefinitionBuilderTests.cs index f54a2c34902..bb1596dff10 100644 --- a/tests/MongoDB.Driver.Tests/PipelineStageDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/PipelineStageDefinitionBuilderTests.cs @@ -124,7 +124,7 @@ public void ChangeStream_should_return_the_expected_result_when_options_isNull() stage.Document.Should().Be("{ $changeStream : { } }"); } - [SkippableFact] + [Fact] public void GraphLookup_with_many_to_one_parameters_should_return_expected_result() { RequireServer.Check(); @@ -150,7 +150,7 @@ public void GraphLookup_with_many_to_one_parameters_should_return_expected_resul }"); } - [SkippableFact] + [Fact] public void GraphLookup_with_one_to_many_parameters_should_return_expected_result() { RequireServer.Check(); @@ -176,7 +176,7 @@ public void GraphLookup_with_one_to_many_parameters_should_return_expected_resul }"); } - [SkippableFact] + [Fact] public void GraphLookup_with_one_to_one_parameters_should_return_expected_result() { RequireServer.Check(); @@ -202,7 +202,7 @@ public void GraphLookup_with_one_to_one_parameters_should_return_expected_result }"); } - [SkippableFact] + [Fact] public void Lookup_with_let_should_return_the_expected_result() { RequireServer.Check(); @@ -261,7 +261,7 @@ public void Lookup_with_let_should_return_the_expected_result() }"); } - [SkippableFact] + [Fact] public void Lookup_without_optional_let_should_return_the_expected_result() { RequireServer.Check(); @@ -403,7 +403,7 @@ public class StockData public int Instock { get; set; } } - [SkippableFact] + [Fact] public void Lookup_with_entity_generic_params_should_return_the_expected_result() { RequireServer.Check(); @@ -461,7 +461,7 @@ public void Lookup_with_entity_generic_params_should_return_the_expected_result( }"); } - [SkippableFact] + [Fact] public void Lookup_with_empty_required_params_should_throw_expected_exception() { RequireServer.Check(); diff --git a/tests/MongoDB.Driver.Tests/Properties/AssemblyInfo.cs b/tests/MongoDB.Driver.Tests/Properties/AssemblyInfo.cs index 8990b3d975f..d9eef727857 100644 --- a/tests/MongoDB.Driver.Tests/Properties/AssemblyInfo.cs +++ b/tests/MongoDB.Driver.Tests/Properties/AssemblyInfo.cs @@ -14,11 +14,11 @@ */ using System.Runtime.InteropServices; -using MongoDB.Driver.Core.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; [assembly: ComVisible(false)] [assembly: CollectionBehavior(DisableTestParallelization = true)] -[assembly: TestFramework(XunitExtensionsConsts.TimeoutEnforcingXunitFramework, XunitExtensionsConsts.TimeoutEnforcingFrameworkAssembly)] +[assembly: TestFramework(XunitExtensionsConstants.TimeoutEnforcingXunitFramework, XunitExtensionsConstants.TimeoutEnforcingFrameworkAssembly)] diff --git a/tests/MongoDB.Driver.Tests/ReadPreferenceOnStandaloneTests.cs b/tests/MongoDB.Driver.Tests/ReadPreferenceOnStandaloneTests.cs index 5b6ec286fc1..14bd9987fca 100644 --- a/tests/MongoDB.Driver.Tests/ReadPreferenceOnStandaloneTests.cs +++ b/tests/MongoDB.Driver.Tests/ReadPreferenceOnStandaloneTests.cs @@ -18,7 +18,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Events; diff --git a/tests/MongoDB.Driver.Tests/RetryableWritesTests.cs b/tests/MongoDB.Driver.Tests/RetryableWritesTests.cs index e087c9ad28a..6472458726e 100644 --- a/tests/MongoDB.Driver.Tests/RetryableWritesTests.cs +++ b/tests/MongoDB.Driver.Tests/RetryableWritesTests.cs @@ -40,7 +40,7 @@ public class RetryableWritesTests : LoggableTestClass } // public methods - [SkippableFact] + [Fact] public void Insert_with_RetryWrites_true_should_work_whether_retryable_writes_are_supported_or_not() { RequireServer.Check(); @@ -54,7 +54,7 @@ public void Insert_with_RetryWrites_true_should_work_whether_retryable_writes_ar } } - [SkippableFact] + [Fact] public void Retryable_write_errorlabel_should_not_be_added_with_retryWrites_false() { if (CoreTestConfiguration.Cluster.Description.Type == ClusterType.Sharded) @@ -96,7 +96,7 @@ public void Retryable_write_errorlabel_should_not_be_added_with_retryWrites_fals } } - [SkippableFact] + [Fact] public void Retryable_write_operation_should_throw_custom_exception_on_servers_using_mmapv1() { RequireSupportForRetryableWrites(); @@ -116,7 +116,7 @@ public void Retryable_write_operation_should_throw_custom_exception_on_servers_u } } - [SkippableFact] + [Fact] public void TxnNumber_should_be_included_with_FindOneAndDelete() { RequireSupportForRetryableWrites(); @@ -135,7 +135,7 @@ public void TxnNumber_should_be_included_with_FindOneAndDelete() } } - [SkippableFact] + [Fact] public void TxnNumber_should_be_included_with_FindOneAndReplace() { RequireSupportForRetryableWrites(); @@ -154,7 +154,7 @@ public void TxnNumber_should_be_included_with_FindOneAndReplace() } } - [SkippableFact] + [Fact] public void TxnNumber_should_be_included_with_FindOneAndUpdate() { RequireSupportForRetryableWrites(); @@ -173,7 +173,7 @@ public void TxnNumber_should_be_included_with_FindOneAndUpdate() } } - [SkippableFact] + [Fact] public void TxnNumber_should_be_included_with_DeleteOne() { RequireSupportForRetryableWrites(); @@ -192,7 +192,7 @@ public void TxnNumber_should_be_included_with_DeleteOne() } } - [SkippableFact] + [Fact] public void TxnNumber_should_be_included_with_InsertOne() { RequireSupportForRetryableWrites(); @@ -211,7 +211,7 @@ public void TxnNumber_should_be_included_with_InsertOne() } } - [SkippableFact] + [Fact] public void TxnNumber_should_be_included_with_ReplaceOne() { RequireSupportForRetryableWrites(); @@ -230,7 +230,7 @@ public void TxnNumber_should_be_included_with_ReplaceOne() } } - [SkippableFact] + [Fact] public void TxnNumber_should_be_included_with_UpdateOne() { RequireSupportForRetryableWrites(); diff --git a/tests/MongoDB.Driver.Tests/Specifications/Runner/MongoClientJsonDrivenTestRunnerBase.cs b/tests/MongoDB.Driver.Tests/Specifications/Runner/MongoClientJsonDrivenTestRunnerBase.cs index 0f960caa2ee..3999f48070d 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/Runner/MongoClientJsonDrivenTestRunnerBase.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/Runner/MongoClientJsonDrivenTestRunnerBase.cs @@ -35,8 +35,9 @@ using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using MongoDB.Driver.TestHelpers; using MongoDB.Driver.Tests.JsonDrivenTests; -using Xunit; using Xunit.Abstractions; +using Xunit.Sdk; +using Reflector = MongoDB.Bson.TestHelpers.Reflector; namespace MongoDB.Driver.Tests.Specifications.Runner { diff --git a/tests/MongoDB.Driver.Tests/Specifications/atlas-data-lake-testing/AtlasDataLakeTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/atlas-data-lake-testing/AtlasDataLakeTestRunner.cs index d1fc7916ba7..dfe92b4d497 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/atlas-data-lake-testing/AtlasDataLakeTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/atlas-data-lake-testing/AtlasDataLakeTestRunner.cs @@ -16,7 +16,7 @@ using System.Collections.Generic; using MongoDB.Bson; using MongoDB.Bson.TestHelpers.JsonDrivenTests; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Tests.Specifications.Runner; using Xunit; using Xunit.Abstractions; @@ -35,7 +35,7 @@ public AtlasDataLakeTestRunner(ITestOutputHelper testOutputHelper) { } - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void Run(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/atlas-data-lake-testing/prose-tests/AtlasDataLakeProseTests.cs b/tests/MongoDB.Driver.Tests/Specifications/atlas-data-lake-testing/prose-tests/AtlasDataLakeProseTests.cs index 4fb28c4498a..f9c806259c3 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/atlas-data-lake-testing/prose-tests/AtlasDataLakeProseTests.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/atlas-data-lake-testing/prose-tests/AtlasDataLakeProseTests.cs @@ -16,7 +16,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Events; using MongoDB.Driver.Core.Misc; @@ -28,7 +28,7 @@ namespace MongoDB.Driver.Tests.Specifications.atlas_data_lake_testing.prose_test [Trait("Category", "AtlasDataLake")] public class AtlasDataLakeProseTests { - [SkippableFact] + [Fact] public void Driver_should_connect_to_AtlasDataLake_without_authentication() { RequireEnvironment.Check().EnvironmentVariable("ATLAS_DATA_LAKE_TESTS_ENABLED"); @@ -39,7 +39,7 @@ public void Driver_should_connect_to_AtlasDataLake_without_authentication() } } - [SkippableFact] + [Fact] public void Driver_should_connect_to_AtlasDataLake_with_SCRAM_SHA_1() { RequireEnvironment.Check().EnvironmentVariable("ATLAS_DATA_LAKE_TESTS_ENABLED"); @@ -59,7 +59,7 @@ public void Driver_should_connect_to_AtlasDataLake_with_SCRAM_SHA_1() } } - [SkippableFact] + [Fact] public void Driver_should_connect_to_AtlasDataLake_with_SCRAM_SHA_256() { RequireEnvironment.Check().EnvironmentVariable("ATLAS_DATA_LAKE_TESTS_ENABLED"); @@ -79,7 +79,7 @@ public void Driver_should_connect_to_AtlasDataLake_with_SCRAM_SHA_256() } } - [SkippableFact] + [Fact] public void KillCursors_should_return_expected_result() { RequireEnvironment.Check().EnvironmentVariable("ATLAS_DATA_LAKE_TESTS_ENABLED"); diff --git a/tests/MongoDB.Driver.Tests/Specifications/auth/AuthTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/auth/AuthTestRunner.cs index 069b3c218a9..d7b2e735127 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/auth/AuthTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/auth/AuthTestRunner.cs @@ -20,7 +20,7 @@ using MongoDB.Bson; using MongoDB.Bson.TestHelpers; using MongoDB.Bson.TestHelpers.JsonDrivenTests; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Authentication; using Xunit; @@ -28,7 +28,7 @@ namespace MongoDB.Driver.Tests.Specifications.auth { public class AuthTestRunner { - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void RunTestDefinition(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/bson-corpus/BsonCorpusTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/bson-corpus/BsonCorpusTestRunner.cs index b8f775d0636..be2120cbb3e 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/bson-corpus/BsonCorpusTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/bson-corpus/BsonCorpusTestRunner.cs @@ -30,7 +30,7 @@ namespace MongoDB.Driver.Tests.Specifications.bson_corpus { public class BsonCorpusTestRunner { - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void RunTestDefinition(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/change-streams/ChangeStreamUnifiedTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/change-streams/ChangeStreamUnifiedTestRunner.cs index 186d74bf6ce..2a09759e909 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/change-streams/ChangeStreamUnifiedTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/change-streams/ChangeStreamUnifiedTestRunner.cs @@ -33,7 +33,7 @@ public ChangeStreamUnifiedTestRunner(ITestOutputHelper testOutputHelper) } // public methods - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void Run(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionTestRunner.cs index f5c7e657a5e..d1e71a04f3a 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionTestRunner.cs @@ -19,7 +19,7 @@ using System.Linq; using MongoDB.Bson; using MongoDB.Bson.TestHelpers.JsonDrivenTests; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Events; using MongoDB.Driver.Encryption; using MongoDB.Driver.TestHelpers; @@ -43,7 +43,7 @@ public ClientSideEncryptionTestRunner(ITestOutputHelper testOutputHelper) { } - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void Run(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionUnifiedTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionUnifiedTestRunner.cs index 460f2dad3cf..f64d6e74713 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionUnifiedTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionUnifiedTestRunner.cs @@ -16,7 +16,7 @@ using System.Collections.Generic; using MongoDB.Bson; using MongoDB.Bson.TestHelpers.JsonDrivenTests; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.TestHelpers.Logging; using MongoDB.Driver.TestHelpers; using MongoDB.Driver.Tests.UnifiedTestOperations; @@ -35,7 +35,7 @@ public ClientSideEncryptionUnifiedTestRunner(ITestOutputHelper testOutputHelper) } // public methods - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void Run(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs index fd44d9e683b..36eecdcd55b 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs @@ -30,7 +30,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers.JsonDrivenTests; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Authentication.External; using MongoDB.Driver.Core.Bindings; @@ -85,7 +85,7 @@ public ClientEncryptionProseTests(ITestOutputHelper testOutputHelper) } // public methods - [SkippableTheory] + [Theory] [ParameterAttributeData] public void BsonSizeLimitAndBatchSizeSplittingTest( [Values(false, true)] bool async) @@ -250,7 +250,7 @@ public ClientEncryptionProseTests(ITestOutputHelper testOutputHelper) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void BypassMongocryptdClientWhenSharedLibraryTest( [Values(false, true)] bool async) @@ -319,7 +319,7 @@ void ThreadStart(object param) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void BypassSpawningMongocryptdViaMongocryptdBypassSpawnTest( [Values(false, true)] bool async) @@ -354,7 +354,7 @@ public enum BypassSpawningMongocryptd SharedLibrary } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void BypassSpawningMongocryptdTest( [Values(BypassSpawningMongocryptd.BypassQueryAnalysis, BypassSpawningMongocryptd.BypassAutoEncryption, BypassSpawningMongocryptd.SharedLibrary)] BypassSpawningMongocryptd bypassSpawning, @@ -411,7 +411,7 @@ DisposableMongoClient EnsureEnvironmentAndConfigureTestClientEncrypted() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void CorpusTest( [Values(false, true)] bool useLocalSchema, @@ -581,7 +581,7 @@ EncryptOptions CreateEncryptOptions(string algorithm, string identifier, string }; } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void CreateDataKeyAndDoubleEncryptionTest( [Values("local", "aws", "azure", "gcp", "kmip")] string kmsProvider, @@ -657,7 +657,7 @@ EncryptOptions CreateEncryptOptions(string algorithm, string identifier, string } } - [SkippableTheory] + [Theory] // aws [InlineData("aws", null, null, null)] [InlineData("aws", "kms.us-east-1.amazonaws.com", null, null)] @@ -819,7 +819,7 @@ void TestCase(ClientEncryption testCaseClientEncription, BsonDocument masterKey, } } - [SkippableTheory] + [Theory] [MemberData(nameof(DeadlockTest_MemberData))] public void DeadlockTest( string _, @@ -1022,7 +1022,7 @@ public static IEnumerable DeadlockTest_MemberData() } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void DecryptionEvents( [Range(1, 4)] int testCase, @@ -1135,7 +1135,7 @@ BsonDocument Aggregate(IMongoCollection collection, bool async) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void ExplicitEncryptionTest( [Range(1, 5)] int testCase, @@ -1264,7 +1264,7 @@ void RunTestCase(IMongoCollection explicitCollectionFromEncryptedC } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void ExternalKeyVaultTest( [Values(false, true)] bool withExternalKeyVault, @@ -1315,7 +1315,7 @@ void RunTestCase(IMongoCollection explicitCollectionFromEncryptedC } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void KmsTlsOptionsTest( [Values("aws", "azure", "gcp", "kmip")] string kmsProvider, @@ -1632,7 +1632,7 @@ void KmsProviderEndpointConfigurator(string kmsProviderName, Dictionary(); @@ -76,7 +76,7 @@ public void Heartbeat_should_work_as_expected() } } - [SkippableFact] + [Fact] public void Monitor_sleep_at_least_minHeartbeatFreqencyMS_between_checks() { var minVersion = new SemanticVersion(4, 9, 0, ""); @@ -120,7 +120,7 @@ public void Monitor_sleep_at_least_minHeartbeatFreqencyMS_between_checks() sw.ElapsedMilliseconds.Should().BeInRange(2000, 3500); } - [SkippableFact] + [Fact] public void RoundTimeTrip_test() { RequireServer.Check().Supports(Feature.StreamingHello); @@ -172,7 +172,7 @@ public void RoundTimeTrip_test() } } - [SkippableFact] + [Fact] public void ConnectionPool_cleared_on_failed_hello() { var minVersion = new SemanticVersion(4, 9, 0, ""); diff --git a/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/prose-tests/ServerDiscoveryProseTests.cs b/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/prose-tests/ServerDiscoveryProseTests.cs index 14b61086e63..05f7a3dda79 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/prose-tests/ServerDiscoveryProseTests.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/server-discovery-and-monitoring/prose-tests/ServerDiscoveryProseTests.cs @@ -19,7 +19,7 @@ using System.Threading; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Configuration; using MongoDB.Driver.Core.Misc; @@ -41,7 +41,7 @@ public ServerDiscoveryProseTests(ITestOutputHelper testOutputHelper) } // public methods - [SkippableTheory] + [Theory] [ParameterAttributeData] public void Topology_secondary_discovery_with_directConnection_false_should_work_as_expected([Values(false, true, null)] bool? directConnection) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsProseTests.cs b/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsProseTests.cs index de6da82636f..33627757869 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsProseTests.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsProseTests.cs @@ -20,7 +20,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Events; using MongoDB.Driver.Core.TestHelpers.Logging; @@ -37,7 +37,7 @@ public SessionsProseTests(ITestOutputHelper output) : base(output) { } - [SkippableFact] + [Fact] public void Snapshot_and_causal_consistent_session_is_not_allowed() { RequireServer.Check(); @@ -54,7 +54,7 @@ public void Snapshot_and_causal_consistent_session_is_not_allowed() exception.Should().BeOfType(); } - [SkippableTheory] + [Theory] [ParameterAttributeData] public async Task Ensure_server_session_are_allocated_only_on_connection_checkout([Values(true, false)]bool async) { @@ -189,7 +189,7 @@ public async Task Ensure_server_session_are_allocated_only_on_connection_checkou singleSessionUsed.Should().BeTrue("At least one iteration should use single session"); } - [SkippableFact] + [Fact] public async Task Ensure_server_session_are_allocated_only_on_connection_checkout_deterministic() { var eventCapturer = new EventCapturer() diff --git a/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsTestRunner.cs index a9b15477bee..cbebc6a67d7 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsTestRunner.cs @@ -34,7 +34,7 @@ public SessionsTestRunner(ITestOutputHelper testOutputHelper) { } - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void RunTestDefinition(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsUnifiedTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsUnifiedTestRunner.cs index 453fe8427e0..2b235945789 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsUnifiedTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/sessions/SessionsUnifiedTestRunner.cs @@ -33,7 +33,7 @@ public SessionsUnifiedTestRunner(ITestOutputHelper testOutputHelper) } // public methods - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void Run(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/transactions-convenient-api/TransactionsConvenientApiTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/transactions-convenient-api/TransactionsConvenientApiTestRunner.cs index cbc2a4b3204..befc9945a57 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/transactions-convenient-api/TransactionsConvenientApiTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/transactions-convenient-api/TransactionsConvenientApiTestRunner.cs @@ -31,7 +31,7 @@ public TransactionsConvenientApiTestRunner(ITestOutputHelper testOutputHelper) { } - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void Run(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/transactions/TransactionTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/transactions/TransactionTestRunner.cs index 3dfc44078a0..b7c94d1ebfa 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/transactions/TransactionTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/transactions/TransactionTestRunner.cs @@ -38,6 +38,7 @@ using MongoDB.Driver.Tests.JsonDrivenTests; using Xunit; using Xunit.Abstractions; +using Xunit.Sdk; namespace MongoDB.Driver.Tests.Specifications.transactions { @@ -97,7 +98,7 @@ public async Task ConfigureFailPointAsync(IServer server, ICoreSessionHandle ses _disposables.Add(failPoint); } - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void Run(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/transactions/TransactionUnifiedTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/transactions/TransactionUnifiedTestRunner.cs index ad67108169e..a09003f0407 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/transactions/TransactionUnifiedTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/transactions/TransactionUnifiedTestRunner.cs @@ -34,7 +34,7 @@ public TransactionUnifiedTestRunner(ITestOutputHelper testOutputHelper) } // public methods - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void Run(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/unified-test-format/UnifiedTestFormatValidFailTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/unified-test-format/UnifiedTestFormatValidFailTestRunner.cs index acc69ecf7a2..06990b94579 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/unified-test-format/UnifiedTestFormatValidFailTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/unified-test-format/UnifiedTestFormatValidFailTestRunner.cs @@ -17,7 +17,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.TestHelpers.JsonDrivenTests; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.TestHelpers.Logging; using MongoDB.Driver.Tests.UnifiedTestOperations; using Xunit; @@ -34,7 +34,7 @@ public UnifiedTestFormatValidFailTestRunner(ITestOutputHelper testOutputHelper) } // public methods - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void Run(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/unified-test-format/UnifiedTestFormatValidPassTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/unified-test-format/UnifiedTestFormatValidPassTestRunner.cs index a1454661a83..662040c06c2 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/unified-test-format/UnifiedTestFormatValidPassTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/unified-test-format/UnifiedTestFormatValidPassTestRunner.cs @@ -17,7 +17,7 @@ using System.Linq; using MongoDB.Bson; using MongoDB.Bson.TestHelpers.JsonDrivenTests; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.TestHelpers.Logging; using MongoDB.Driver.Tests.UnifiedTestOperations; using Xunit; @@ -34,7 +34,7 @@ public UnifiedTestFormatValidPassTestRunner(ITestOutputHelper testOutputHelper) } // public methods - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void Run(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/VersionedApiUnifiedTestRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/VersionedApiUnifiedTestRunner.cs index 21e5a20d79a..3a449ab2288 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/VersionedApiUnifiedTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/VersionedApiUnifiedTestRunner.cs @@ -34,7 +34,7 @@ public VersionedApiUnifiedTestRunner(ITestOutputHelper testOutputHelper) } // public methods - [SkippableTheory] + [Theory] [ClassData(typeof(TestCaseFactory))] public void Run(JsonDrivenTestCase testCase) { diff --git a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedErrorMatcher.cs b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedErrorMatcher.cs index 7e30a51322d..d9dc77a4d57 100644 --- a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedErrorMatcher.cs +++ b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedErrorMatcher.cs @@ -18,7 +18,7 @@ using System.Linq; using FluentAssertions; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; namespace MongoDB.Driver.Tests.UnifiedTestOperations.Matchers { diff --git a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedEventMatcher.cs b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedEventMatcher.cs index b73f6f04a39..3b178d900f4 100644 --- a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedEventMatcher.cs +++ b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedEventMatcher.cs @@ -20,7 +20,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Connections; using MongoDB.Driver.Core.Events; using Xunit.Sdk; diff --git a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedValueMatcher.cs b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedValueMatcher.cs index a143e26ebe2..7c033913638 100644 --- a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedValueMatcher.cs +++ b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/Matchers/UnifiedValueMatcher.cs @@ -19,7 +19,7 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Bson.IO; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver; using Xunit.Sdk; diff --git a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedLoopOperation.cs b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedLoopOperation.cs index 417b4bf3b65..78daf3870fb 100644 --- a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedLoopOperation.cs +++ b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedLoopOperation.cs @@ -19,7 +19,7 @@ using System.Threading; using System.Threading.Tasks; using MongoDB.Bson; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.Misc; namespace MongoDB.Driver.Tests.UnifiedTestOperations diff --git a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestRunner.cs b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestRunner.cs index 6d83c5043a2..92ec76e001d 100644 --- a/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestRunner.cs +++ b/tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestRunner.cs @@ -21,7 +21,7 @@ using Microsoft.Extensions.Logging; using MongoDB.Bson; using MongoDB.Bson.TestHelpers.JsonDrivenTests; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core; using MongoDB.Driver.Core.Logging; using MongoDB.Driver.Core.Misc; @@ -29,7 +29,7 @@ using MongoDB.Driver.Core.TestHelpers.Logging; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using MongoDB.Driver.Tests.UnifiedTestOperations.Matchers; -using Xunit; +using Xunit.Sdk; namespace MongoDB.Driver.Tests.UnifiedTestOperations { diff --git a/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs index 29d461f9715..47cfbdb4c51 100644 --- a/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs @@ -21,7 +21,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; -using MongoDB.Bson.TestHelpers.XunitExtensions; +using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using Xunit; diff --git a/tests/MongoDB.TestHelpers/MongoDB.TestHelpers.csproj b/tests/MongoDB.TestHelpers/MongoDB.TestHelpers.csproj new file mode 100644 index 00000000000..ade074a59f1 --- /dev/null +++ b/tests/MongoDB.TestHelpers/MongoDB.TestHelpers.csproj @@ -0,0 +1,15 @@ + + + + + $(StandardTargetFrameworks) + ..\..\MongoDBLegacyTest.ruleset + + + + MongoDB.TestHelpers + MongoDB.TestHelpers + Helper classes applicable to all test projects. + + + diff --git a/tests/MongoDB.TestHelpers/Properties/AssemblyInfo.cs b/tests/MongoDB.TestHelpers/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..cc39fd111c9 --- /dev/null +++ b/tests/MongoDB.TestHelpers/Properties/AssemblyInfo.cs @@ -0,0 +1,18 @@ +/* Copyright 2010-present MongoDB Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +using System.Runtime.InteropServices; + +[assembly: ComVisible(false)] diff --git a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/AssertionException.cs b/tests/MongoDB.TestHelpers/XunitExtensions/AssertionException.cs similarity index 90% rename from tests/MongoDB.Bson.TestHelpers/XunitExtensions/AssertionException.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/AssertionException.cs index a5c3a27be25..1499b69ac56 100644 --- a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/AssertionException.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/AssertionException.cs @@ -1,4 +1,4 @@ -/* Copyright 2016-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ using System; using Xunit.Sdk; -namespace MongoDB.Bson.TestHelpers.XunitExtensions +namespace MongoDB.TestHelpers.XunitExtensions { public class AssertionException : XunitException { diff --git a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/ClassValuesAttribute.cs b/tests/MongoDB.TestHelpers/XunitExtensions/ClassValuesAttribute.cs similarity index 93% rename from tests/MongoDB.Bson.TestHelpers/XunitExtensions/ClassValuesAttribute.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/ClassValuesAttribute.cs index 7925a0f05d2..64298bc2a1d 100644 --- a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/ClassValuesAttribute.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/ClassValuesAttribute.cs @@ -1,4 +1,4 @@ -/* Copyright 2020-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ using System; -namespace MongoDB.Bson.TestHelpers.XunitExtensions +namespace MongoDB.TestHelpers.XunitExtensions { [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)] public class ClassValuesAttribute : Attribute, IValueGeneratorAttribute diff --git a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/IValueGenerator.cs b/tests/MongoDB.TestHelpers/XunitExtensions/IValueGenerator.cs similarity index 87% rename from tests/MongoDB.Bson.TestHelpers/XunitExtensions/IValueGenerator.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/IValueGenerator.cs index d1b0ad98cf8..b15f3f295be 100644 --- a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/IValueGenerator.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/IValueGenerator.cs @@ -1,4 +1,4 @@ -/* Copyright 2020-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * limitations under the License. */ -namespace MongoDB.Bson.TestHelpers.XunitExtensions +namespace MongoDB.TestHelpers.XunitExtensions { public interface IValueGenerator { diff --git a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/IValueGeneratorAttribute.cs b/tests/MongoDB.TestHelpers/XunitExtensions/IValueGeneratorAttribute.cs similarity index 87% rename from tests/MongoDB.Bson.TestHelpers/XunitExtensions/IValueGeneratorAttribute.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/IValueGeneratorAttribute.cs index d9bfaffe386..0f35a840c42 100644 --- a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/IValueGeneratorAttribute.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/IValueGeneratorAttribute.cs @@ -1,4 +1,4 @@ -/* Copyright 2016-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * limitations under the License. */ -namespace MongoDB.Bson.TestHelpers.XunitExtensions +namespace MongoDB.TestHelpers.XunitExtensions { internal interface IValueGeneratorAttribute { diff --git a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/ParameterAttributeDataAttribute.cs b/tests/MongoDB.TestHelpers/XunitExtensions/ParameterAttributeDataAttribute.cs similarity index 96% rename from tests/MongoDB.Bson.TestHelpers/XunitExtensions/ParameterAttributeDataAttribute.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/ParameterAttributeDataAttribute.cs index 63136fb24e6..bc18fa1823a 100644 --- a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/ParameterAttributeDataAttribute.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/ParameterAttributeDataAttribute.cs @@ -1,4 +1,4 @@ -/* Copyright 2016-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ using System.Reflection; using Xunit.Sdk; -namespace MongoDB.Bson.TestHelpers.XunitExtensions +namespace MongoDB.TestHelpers.XunitExtensions { public class ParameterAttributeDataAttribute : DataAttribute { diff --git a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/RandomSeedAttribute.cs b/tests/MongoDB.TestHelpers/XunitExtensions/RandomSeedAttribute.cs similarity index 92% rename from tests/MongoDB.Bson.TestHelpers/XunitExtensions/RandomSeedAttribute.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/RandomSeedAttribute.cs index 194e851fce6..94dcf9341f4 100644 --- a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/RandomSeedAttribute.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/RandomSeedAttribute.cs @@ -1,4 +1,4 @@ -/* Copyright 2021-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,8 @@ using System; using System.Diagnostics; using System.Linq; -using MongoDB.Bson.TestHelpers.XunitExtensions; -namespace MongoDB.Bson.TestHelpers +namespace MongoDB.TestHelpers.XunitExtensions { [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)] public class RandomSeedAttribute : Attribute, IValueGeneratorAttribute diff --git a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/RangeAttribute.cs b/tests/MongoDB.TestHelpers/XunitExtensions/RangeAttribute.cs similarity index 94% rename from tests/MongoDB.Bson.TestHelpers/XunitExtensions/RangeAttribute.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/RangeAttribute.cs index 670398e8d81..daca4517998 100644 --- a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/RangeAttribute.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/RangeAttribute.cs @@ -1,4 +1,4 @@ -/* Copyright 2016-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ using System; using System.Collections.Generic; -namespace MongoDB.Bson.TestHelpers.XunitExtensions +namespace MongoDB.TestHelpers.XunitExtensions { [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)] public sealed class RangeAttribute : Attribute, IValueGeneratorAttribute diff --git a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/RequireEnvironment.cs b/tests/MongoDB.TestHelpers/XunitExtensions/RequireEnvironment.cs similarity index 95% rename from tests/MongoDB.Bson.TestHelpers/XunitExtensions/RequireEnvironment.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/RequireEnvironment.cs index 26b8aa29343..476dd3dc540 100644 --- a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/RequireEnvironment.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/RequireEnvironment.cs @@ -1,4 +1,4 @@ -/* Copyright 2016-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ using System.Diagnostics; using System.Net; using System.Net.Sockets; -using Xunit; +using Xunit.Sdk; -namespace MongoDB.Bson.TestHelpers.XunitExtensions +namespace MongoDB.TestHelpers.XunitExtensions { public class RequireEnvironment { diff --git a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/RequireProcess.cs b/tests/MongoDB.TestHelpers/XunitExtensions/RequireProcess.cs similarity index 91% rename from tests/MongoDB.Bson.TestHelpers/XunitExtensions/RequireProcess.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/RequireProcess.cs index a575ad5f282..87d447dc5b6 100644 --- a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/RequireProcess.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/RequireProcess.cs @@ -1,4 +1,4 @@ -/* Copyright 2016-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ */ using System; -using Xunit; +using Xunit.Sdk; -namespace MongoDB.Bson.TestHelpers.XunitExtensions +namespace MongoDB.TestHelpers.XunitExtensions { public class RequireProcess { diff --git a/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/ITestExceptionHandler.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/ITestExceptionHandler.cs new file mode 100644 index 00000000000..2383cff3e6b --- /dev/null +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/ITestExceptionHandler.cs @@ -0,0 +1,24 @@ +/* Copyright 2010-present MongoDB Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +using System; + +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing +{ + public interface ITestExceptionHandler + { + void HandleException(Exception ex); + } +} diff --git a/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/SkippableTestMessageBus.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/SkippableTestMessageBus.cs new file mode 100644 index 00000000000..733ee106159 --- /dev/null +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/SkippableTestMessageBus.cs @@ -0,0 +1,61 @@ +/* Copyright 2010-present MongoDB Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +using System; +using System.Linq; +using Xunit.Abstractions; +using Xunit.Sdk; + +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing +{ + internal sealed class SkippableTestMessageBus : IMessageBus + { + private readonly static string __skippableExceptionName = typeof(SkipException).FullName; + + private readonly IMessageBus _messageBus; + private int _skippedCount; + + public SkippableTestMessageBus(IMessageBus messageBus) + { + if (messageBus == null) + { + throw new ArgumentNullException(nameof(messageBus)); + } + + _messageBus = messageBus; + } + + public int SkippedCount => _skippedCount; + + public void Dispose() + { + _messageBus.Dispose(); + } + + /// + public bool QueueMessage(IMessageSinkMessage message) + { + var failed = message as TestFailed; + if (message is TestFailed testFailed && + testFailed.ExceptionTypes.FirstOrDefault() == __skippableExceptionName) + { + _skippedCount++; + return _messageBus.QueueMessage(new TestSkipped(failed.Test, failed.Messages[0])); + } + + return _messageBus.QueueMessage(message); + } + } +} diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestInvoker.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestInvoker.cs similarity index 59% rename from tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestInvoker.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestInvoker.cs index 351ca9c6b5f..69c16fc24d8 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestInvoker.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestInvoker.cs @@ -1,4 +1,4 @@ -/* Copyright 2021-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,18 +17,46 @@ using System.Collections.Generic; using System.Diagnostics; using System.Reflection; +using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; -using MongoDB.Driver.Core.TestHelpers.Logging; -using Xunit; using Xunit.Abstractions; using Xunit.Sdk; -namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions.TimeoutEnforcing +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing { [DebuggerStepThrough] internal sealed class TimeoutEnforcingTestInvoker : XunitTestInvoker { + // This is a copy of MongoDB.Driver.Core.Misc.TaskExtensions.YieldNoContextAwaitable struct + // Remove this copy when moving TaskExtensions to BSON level. + private struct YieldNoContextAwaitable + { + public YieldNoContextAwaiter GetAwaiter() { return new YieldNoContextAwaiter(); } + + public struct YieldNoContextAwaiter : ICriticalNotifyCompletion + { + /// Gets whether a yield is not required. + /// This property is intended for compiler user rather than use directly in code. + public bool IsCompleted { get { return false; } } // yielding is always required for YieldNoContextAwaiter, hence false + + public void OnCompleted(Action continuation) + { + Task.Factory.StartNew(continuation, default, TaskCreationOptions.PreferFairness, TaskScheduler.Default); + } + + public void UnsafeOnCompleted(Action continuation) + { + Task.Factory.StartNew(continuation, default, TaskCreationOptions.PreferFairness, TaskScheduler.Default); + } + + public void GetResult() + { + // no op + } + } + } + public TimeoutEnforcingTestInvoker( ITest test, IMessageBus messageBus, @@ -45,7 +73,7 @@ internal sealed class TimeoutEnforcingTestInvoker : XunitTestInvoker private async Task InvokeBaseOnTaskScheduler(object testClassInstance) { - await Misc.TaskExtensions.YieldNoContext(); + await new YieldNoContextAwaitable(); return await base.InvokeTestMethodAsync(testClassInstance); } @@ -56,10 +84,10 @@ protected override async Task InvokeTestMethodAsync(object testClassIns var timeoutMS = xUnitTestCase?.Timeout ?? 0; var timeout = Debugger.IsAttached ? Timeout.InfiniteTimeSpan // allow more flexible debugging expirience - : timeoutMS <= 0 ? CoreTestConfiguration.DefaultTestTimeout : TimeSpan.FromMilliseconds(timeoutMS); + : timeoutMS <= 0 ? XunitExtensionsConstants.DefaultTestTimeout : TimeSpan.FromMilliseconds(timeoutMS); - var testLoggable = testClassInstance as LoggableTestClass; + var testExceptionHandler = testClassInstance as ITestExceptionHandler; decimal result; try @@ -72,13 +100,13 @@ protected override async Task InvokeTestMethodAsync(object testClassIns throw new TestTimeoutException((int)timeout.TotalMilliseconds); } - if (Aggregator.HasExceptions && testLoggable != null) + if (Aggregator.HasExceptions && testExceptionHandler != null) { var exception = Aggregator.ToException(); if (exception is not SkipException) { - testLoggable.OnException(exception); + testExceptionHandler.HandleException(exception); } } @@ -86,7 +114,7 @@ protected override async Task InvokeTestMethodAsync(object testClassIns } catch (Exception exception) { - testLoggable?.OnException(exception); + testExceptionHandler?.HandleException(exception); throw; } diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestRunner.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestRunner.cs similarity index 93% rename from tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestRunner.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestRunner.cs index 0100333a3ab..23602b4e7b5 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestRunner.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingTestRunner.cs @@ -1,4 +1,4 @@ -/* Copyright 2021-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ using Xunit.Abstractions; using Xunit.Sdk; -namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions.TimeoutEnforcing +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing { [DebuggerStepThrough] internal sealed class TimeoutEnforcingTestRunner : XunitTestRunner diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestAssemblyRunner.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestAssemblyRunner.cs similarity index 93% rename from tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestAssemblyRunner.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestAssemblyRunner.cs index 553758b5dcf..7719fe7500e 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestAssemblyRunner.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestAssemblyRunner.cs @@ -1,4 +1,4 @@ -/* Copyright 2021-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ using Xunit.Abstractions; using Xunit.Sdk; -namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions.TimeoutEnforcing +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing { [DebuggerStepThrough] internal sealed class TimeoutEnforcingXunitTestAssemblyRunner : XunitTestAssemblyRunner diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCaseRunner.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCaseRunner.cs similarity index 94% rename from tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCaseRunner.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCaseRunner.cs index 9707b9b2466..b590b275d7b 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCaseRunner.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCaseRunner.cs @@ -1,4 +1,4 @@ -/* Copyright 2021-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ using Xunit.Abstractions; using Xunit.Sdk; -namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions.TimeoutEnforcing +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing { [DebuggerStepThrough] internal sealed class TimeoutEnforcingXunitTestCaseRunner : XunitTestCaseRunner diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestClassRunner.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestClassRunner.cs similarity index 93% rename from tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestClassRunner.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestClassRunner.cs index 15f6ea90f3f..95080257f2e 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestClassRunner.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestClassRunner.cs @@ -1,4 +1,4 @@ -/* Copyright 2021-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ using Xunit.Abstractions; using Xunit.Sdk; -namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions.TimeoutEnforcing +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing { [DebuggerStepThrough] internal sealed class TimeoutEnforcingXunitTestClassRunner : XunitTestClassRunner diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCollectionRunner.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCollectionRunner.cs similarity index 93% rename from tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCollectionRunner.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCollectionRunner.cs index c6c43384f9c..fe429789841 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCollectionRunner.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestCollectionRunner.cs @@ -1,4 +1,4 @@ -/* Copyright 2021-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ using Xunit.Abstractions; using Xunit.Sdk; -namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions.TimeoutEnforcing +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing { [DebuggerStepThrough] internal sealed class TimeoutEnforcingXunitTestCollectionRunner : XunitTestCollectionRunner diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFramework.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFramework.cs similarity index 90% rename from tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFramework.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFramework.cs index f7b035f70e9..47c7ab5b85d 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFramework.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFramework.cs @@ -1,4 +1,4 @@ -/* Copyright 2021-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ using Xunit.Abstractions; using Xunit.Sdk; -namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions.TimeoutEnforcing +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing { [DebuggerStepThrough] public sealed class TimeoutEnforcingXunitTestFramework : XunitTestFramework diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFrameworkExecutor.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFrameworkExecutor.cs similarity index 92% rename from tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFrameworkExecutor.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFrameworkExecutor.cs index 31e734bc7c6..4b724557d75 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFrameworkExecutor.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestFrameworkExecutor.cs @@ -1,4 +1,4 @@ -/* Copyright 2021-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ using Xunit.Abstractions; using Xunit.Sdk; -namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions.TimeoutEnforcing +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing { [DebuggerStepThrough] internal sealed class TimeoutEnforcingXunitTestFrameworkExecutor : XunitTestFrameworkExecutor diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestMethodRunner.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestMethodRunner.cs similarity index 90% rename from tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestMethodRunner.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestMethodRunner.cs index bbd95e563be..67f45241ff5 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestMethodRunner.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTestMethodRunner.cs @@ -1,4 +1,4 @@ -/* Copyright 2021-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,17 +17,14 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Xunit; using Xunit.Abstractions; using Xunit.Sdk; -namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions.TimeoutEnforcing +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing { [DebuggerStepThrough] internal sealed class TimeoutEnforcingXunitTestMethodRunner : XunitTestMethodRunner { - private static string[] __skippingExceptionNames = new string[] { typeof(SkipException).FullName }; - private readonly object[] _constructorArguments; private readonly IMessageSink _diagnosticMessageSink; @@ -39,7 +36,7 @@ public TimeoutEnforcingXunitTestMethodRunner(ITestMethod testMethod, IReflection protected override async Task RunTestCaseAsync(IXunitTestCase originalTestCase) { - var messageBusInterceptor = new SkippableTestMessageBus(MessageBus, __skippingExceptionNames); + var messageBusInterceptor = new SkippableTestMessageBus(MessageBus); var isTheory = originalTestCase is XunitTheoryTestCase; XunitTestCaseRunner testRunner = isTheory ? diff --git a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTheoryTestCaseRunner.cs b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTheoryTestCaseRunner.cs similarity index 94% rename from tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTheoryTestCaseRunner.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTheoryTestCaseRunner.cs index bf2a952c6f8..fe4433bf366 100644 --- a/tests/MongoDB.Driver.Core.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTheoryTestCaseRunner.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/TimeoutEnforcingXunitTheoryTestCaseRunner.cs @@ -1,4 +1,4 @@ -/* Copyright 2021-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ using Xunit.Abstractions; using Xunit.Sdk; -namespace MongoDB.Driver.Core.TestHelpers.XunitExtensions.TimeoutEnforcing +namespace MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing { [DebuggerStepThrough] internal sealed class TimeoutEnforcingXunitTheoryTestCaseRunner : XunitTheoryTestCaseRunner diff --git a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/ValuesAttribute.cs b/tests/MongoDB.TestHelpers/XunitExtensions/ValuesAttribute.cs similarity index 91% rename from tests/MongoDB.Bson.TestHelpers/XunitExtensions/ValuesAttribute.cs rename to tests/MongoDB.TestHelpers/XunitExtensions/ValuesAttribute.cs index a18d9931139..18a949b0eed 100644 --- a/tests/MongoDB.Bson.TestHelpers/XunitExtensions/ValuesAttribute.cs +++ b/tests/MongoDB.TestHelpers/XunitExtensions/ValuesAttribute.cs @@ -1,4 +1,4 @@ -/* Copyright 2016-present MongoDB Inc. +/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ using System; using System.Linq; -namespace MongoDB.Bson.TestHelpers.XunitExtensions +namespace MongoDB.TestHelpers.XunitExtensions { [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)] public sealed class ValuesAttribute : Attribute, IValueGeneratorAttribute diff --git a/tests/MongoDB.TestHelpers/XunitExtensions/XunitExtensionsConstants.cs b/tests/MongoDB.TestHelpers/XunitExtensions/XunitExtensionsConstants.cs new file mode 100644 index 00000000000..6eef51ed01e --- /dev/null +++ b/tests/MongoDB.TestHelpers/XunitExtensions/XunitExtensionsConstants.cs @@ -0,0 +1,27 @@ +/* Copyright 2010-present MongoDB Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +using System; + +namespace MongoDB.TestHelpers.XunitExtensions +{ + public static class XunitExtensionsConstants + { + public const string TimeoutEnforcingXunitFramework = "MongoDB.TestHelpers.XunitExtensions.TimeoutEnforcing.TimeoutEnforcingXunitTestFramework"; + public const string TimeoutEnforcingFrameworkAssembly = "MongoDB.TestHelpers"; + + public static readonly TimeSpan DefaultTestTimeout = TimeSpan.FromMinutes(3); + } +} diff --git a/tests/SkippableTests/FactTests.cs b/tests/SkippableTests/FactTests.cs deleted file mode 100644 index 3eebcf138a3..00000000000 --- a/tests/SkippableTests/FactTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace SkippableTests -{ - public class FactTests - { - [Fact] - public void Fact_should_fail() - { - true.Should().BeFalse(); - } - - [Fact] - public void Fact_should_pass() - { - true.Should().BeTrue(); - } - } -} diff --git a/tests/SkippableTests/SkippableFactTests.cs b/tests/SkippableTests/SkippableFactTests.cs deleted file mode 100644 index 9369907874c..00000000000 --- a/tests/SkippableTests/SkippableFactTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace SkippableTests -{ - public class SkippableFactTests - { - [SkippableFact] - public void SkippableFact_should_fail() - { - true.Should().BeFalse(); - } - - [SkippableFact] - public void SkippableFact_should_pass() - { - true.Should().BeTrue(); - } - - [SkippableFact] - public void SkippableFact_should_be_skipped() - { - throw new SkipException("test"); - } - } -} diff --git a/tests/SkippableTests/SkippableTests.csproj b/tests/SkippableTests/SkippableTests.csproj deleted file mode 100644 index b2068f846cf..00000000000 --- a/tests/SkippableTests/SkippableTests.csproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - - ..\..\MongoDBLegacyTest.ruleset - - - - TRACE - - - - - - - - - - - - - - Always - - - - diff --git a/tests/SkippableTests/SkippableTheoryTests.cs b/tests/SkippableTests/SkippableTheoryTests.cs deleted file mode 100644 index 9e66bcba3ed..00000000000 --- a/tests/SkippableTests/SkippableTheoryTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace SkippableTests -{ - public class SkippableTheoryTests - { - [SkippableTheory] - [InlineData(0)] - public void SkippableTheory_should_fail(int x) - { - x.Should().Be(1); - } - - [SkippableTheory] - [InlineData(0)] - public void SkippableTheory_should_pass(int x) - { - x.Should().Be(0); - } - - [SkippableTheory] - [InlineData(0)] - public void SkippableTheory_should_be_skipped(int x) - { - if (x == 0) - { - throw new SkipException("test"); - } - } - } -} diff --git a/tests/SkippableTests/TheoryTests.cs b/tests/SkippableTests/TheoryTests.cs deleted file mode 100644 index a8655b2be8b..00000000000 --- a/tests/SkippableTests/TheoryTests.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace SkippableTests -{ - public class TheoryTests - { - [Theory] - [InlineData(0)] - public void Theory_should_fail(int x) - { - x.Should().Be(1); - } - - [Theory] - [InlineData(0)] - public void Theory_should_pass(int x) - { - x.Should().Be(0); - } - } -} diff --git a/tests/SkippableTests/xunit.runner.json b/tests/SkippableTests/xunit.runner.json deleted file mode 100644 index 3b86d1533b9..00000000000 --- a/tests/SkippableTests/xunit.runner.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "longRunningTestSeconds": 10, - "parallelizeAssembly": false, - "parallelizeTestCollections": false -} \ No newline at end of file diff --git a/tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/MongoDB.Driver.SmokeTests.Sdk.csproj b/tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/MongoDB.Driver.SmokeTests.Sdk.csproj index 9f28db5e30f..8c56b707d69 100644 --- a/tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/MongoDB.Driver.SmokeTests.Sdk.csproj +++ b/tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/MongoDB.Driver.SmokeTests.Sdk.csproj @@ -21,7 +21,7 @@ - + From 0daabd72a73235db1d0c73951697d31e077c7d6d Mon Sep 17 00:00:00 2001 From: rstam Date: Thu, 8 Dec 2022 10:48:30 -0800 Subject: [PATCH 11/21] CSHARP-4446: MongoQueryable methods should validate that mandatory arguments are not null. --- src/MongoDB.Driver/Linq/MongoQueryable.cs | 422 ++++++++++++++++++++++ 1 file changed, 422 insertions(+) diff --git a/src/MongoDB.Driver/Linq/MongoQueryable.cs b/src/MongoDB.Driver/Linq/MongoQueryable.cs index 8f3fd2f1503..2399079f95f 100644 --- a/src/MongoDB.Driver/Linq/MongoQueryable.cs +++ b/src/MongoDB.Driver/Linq/MongoQueryable.cs @@ -41,6 +41,8 @@ public static class MongoQueryable /// public static Task AnyAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, bool>(Queryable.Any, source), @@ -60,6 +62,9 @@ public static Task AnyAsync(this IMongoQueryable source, /// public static Task AnyAsync(this IMongoQueryable source, Expression> predicate, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(predicate, nameof(predicate)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, bool>(Queryable.Any, source, predicate), @@ -82,6 +87,9 @@ public static Task AnyAsync(this IMongoQueryable source, PipelineStageDefinition stage, IBsonSerializer resultSerializer = null) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(stage, nameof(stage)); + return (IMongoQueryable)source.Provider.CreateQuery( Expression.Call( null, @@ -99,6 +107,8 @@ public static Task AnyAsync(this IMongoQueryable source, /// The average of the values in the sequence. public static Task AverageAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, decimal>(Queryable.Average, source), @@ -114,6 +124,8 @@ public static Task AverageAsync(this IMongoQueryable source, C /// The average of the values in the sequence. public static Task AverageAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, decimal?>(Queryable.Average, source), @@ -129,6 +141,8 @@ public static Task AverageAsync(this IMongoQueryable source, C /// The average of the values in the sequence. public static Task AverageAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, double>(Queryable.Average, source), @@ -144,6 +158,8 @@ public static Task AverageAsync(this IMongoQueryable source, Can /// The average of the values in the sequence. public static Task AverageAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, double?>(Queryable.Average, source), @@ -159,6 +175,8 @@ public static Task AverageAsync(this IMongoQueryable source, Can /// The average of the values in the sequence. public static Task AverageAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, float>(Queryable.Average, source), @@ -174,6 +192,8 @@ public static Task AverageAsync(this IMongoQueryable source, Cance /// The average of the values in the sequence. public static Task AverageAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, float?>(Queryable.Average, source), @@ -189,6 +209,8 @@ public static Task AverageAsync(this IMongoQueryable source, Cance /// The average of the values in the sequence. public static Task AverageAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, double>(Queryable.Average, source), @@ -204,6 +226,8 @@ public static Task AverageAsync(this IMongoQueryable source, Cancel /// The average of the values in the sequence. public static Task AverageAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, double?>(Queryable.Average, source), @@ -219,6 +243,8 @@ public static Task AverageAsync(this IMongoQueryable source, Cancel /// The average of the values in the sequence. public static Task AverageAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, double>(Queryable.Average, source), @@ -234,6 +260,8 @@ public static Task AverageAsync(this IMongoQueryable source, Cance /// The average of the values in the sequence. public static Task AverageAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, double?>(Queryable.Average, source), @@ -254,6 +282,9 @@ public static Task AverageAsync(this IMongoQueryable source, Cance /// public static Task AverageAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, decimal>(Queryable.Average, source, selector), @@ -275,6 +306,9 @@ public static Task AverageAsync(this IMongoQueryable /// public static Task AverageAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, decimal?>(Queryable.Average, source, selector), @@ -296,6 +330,9 @@ public static Task AverageAsync(this IMongoQueryable /// public static Task AverageAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, double>(Queryable.Average, source, selector), @@ -317,6 +354,9 @@ public static Task AverageAsync(this IMongoQueryable s /// public static Task AverageAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, double?>(Queryable.Average, source, selector), @@ -338,6 +378,9 @@ public static Task AverageAsync(this IMongoQueryable s /// public static Task AverageAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, float>(Queryable.Average, source, selector), @@ -359,6 +402,9 @@ public static Task AverageAsync(this IMongoQueryable so /// public static Task AverageAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, float?>(Queryable.Average, source, selector), @@ -380,6 +426,9 @@ public static Task AverageAsync(this IMongoQueryable so /// public static Task AverageAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, double>(Queryable.Average, source, selector), @@ -401,6 +450,9 @@ public static Task AverageAsync(this IMongoQueryable s /// public static Task AverageAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, double?>(Queryable.Average, source, selector), @@ -422,6 +474,9 @@ public static Task AverageAsync(this IMongoQueryable s /// public static Task AverageAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, double>(Queryable.Average, source, selector), @@ -443,6 +498,9 @@ public static Task AverageAsync(this IMongoQueryable s /// public static Task AverageAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, double?>(Queryable.Average, source, selector), @@ -462,6 +520,8 @@ public static Task AverageAsync(this IMongoQueryable s /// public static Task CountAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, int>(Queryable.Count, source), @@ -481,6 +541,9 @@ public static Task CountAsync(this IMongoQueryable source /// public static Task CountAsync(this IMongoQueryable source, Expression> predicate, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(predicate, nameof(predicate)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, int>(Queryable.Count, source, predicate), @@ -504,6 +567,10 @@ public static Task CountAsync(this IMongoQueryable source DensifyRange range, IEnumerable>> partitionByFields = null) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(field, nameof(field)); + Ensure.IsNotNull(range, nameof(range)); + return Densify(source, field, range, partitionByFields?.ToArray()); } @@ -522,6 +589,10 @@ public static Task CountAsync(this IMongoQueryable source DensifyRange range, params Expression>[] partitionByFields) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(field, nameof(field)); + Ensure.IsNotNull(range, nameof(range)); + Expression quotedPartitionByFields; if (partitionByFields?.Length > 0) { @@ -551,6 +622,8 @@ public static Task CountAsync(this IMongoQueryable source /// public static IMongoQueryable Distinct(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return (IMongoQueryable)Queryable.Distinct(source); } @@ -565,6 +638,8 @@ public static IMongoQueryable Distinct(this IMongoQueryable public static Task FirstAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, TSource>(Queryable.First, source), @@ -584,6 +659,9 @@ public static Task FirstAsync(this IMongoQueryable so /// public static Task FirstAsync(this IMongoQueryable source, Expression> predicate, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(predicate, nameof(predicate)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, TSource>(Queryable.First, source, predicate), @@ -603,6 +681,8 @@ public static Task FirstAsync(this IMongoQueryable so /// public static Task FirstOrDefaultAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, TSource>(Queryable.FirstOrDefault, source), @@ -622,6 +702,9 @@ public static Task FirstOrDefaultAsync(this IMongoQueryable public static Task FirstOrDefaultAsync(this IMongoQueryable source, Expression> predicate, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(predicate, nameof(predicate)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, TSource>(Queryable.FirstOrDefault, source, predicate), @@ -644,6 +727,9 @@ public static Task FirstOrDefaultAsync(this IMongoQueryable public static IMongoQueryable> GroupBy(this IMongoQueryable source, Expression> keySelector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(keySelector, nameof(keySelector)); + return (IMongoQueryable>)Queryable.GroupBy(source, keySelector); } @@ -663,6 +749,10 @@ public static Task FirstOrDefaultAsync(this IMongoQueryable public static IMongoQueryable GroupBy(this IMongoQueryable source, Expression> keySelector, Expression, TResult>> resultSelector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(keySelector, nameof(keySelector)); + Ensure.IsNotNull(resultSelector, nameof(resultSelector)); + return (IMongoQueryable)Queryable.GroupBy(source, keySelector, resultSelector); } @@ -683,6 +773,12 @@ public static Task FirstOrDefaultAsync(this IMongoQueryable public static IMongoQueryable GroupJoin(this IMongoQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) { + Ensure.IsNotNull(outer, nameof(outer)); + Ensure.IsNotNull(inner, nameof(inner)); + Ensure.IsNotNull(outerKeySelector, nameof(outerKeySelector)); + Ensure.IsNotNull(innerKeySelector, nameof(innerKeySelector)); + Ensure.IsNotNull(resultSelector, nameof(resultSelector)); + return (IMongoQueryable)Queryable.GroupJoin(outer, inner, outerKeySelector, innerKeySelector, resultSelector); } @@ -703,6 +799,12 @@ public static Task FirstOrDefaultAsync(this IMongoQueryable public static IMongoQueryable GroupJoin(this IMongoQueryable outer, IMongoCollection inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression, TResult>> resultSelector) { + Ensure.IsNotNull(outer, nameof(outer)); + Ensure.IsNotNull(inner, nameof(inner)); + Ensure.IsNotNull(outerKeySelector, nameof(outerKeySelector)); + Ensure.IsNotNull(innerKeySelector, nameof(innerKeySelector)); + Ensure.IsNotNull(resultSelector, nameof(resultSelector)); + return GroupJoin(outer, inner.AsQueryable(), outerKeySelector, innerKeySelector, resultSelector); } @@ -723,6 +825,12 @@ public static Task FirstOrDefaultAsync(this IMongoQueryable public static IMongoQueryable Join(this IMongoQueryable outer, IEnumerable inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { + Ensure.IsNotNull(outer, nameof(outer)); + Ensure.IsNotNull(inner, nameof(inner)); + Ensure.IsNotNull(outerKeySelector, nameof(outerKeySelector)); + Ensure.IsNotNull(innerKeySelector, nameof(innerKeySelector)); + Ensure.IsNotNull(resultSelector, nameof(resultSelector)); + return (IMongoQueryable)Queryable.Join(outer, inner.AsQueryable(), outerKeySelector, innerKeySelector, resultSelector); } @@ -743,6 +851,12 @@ public static Task FirstOrDefaultAsync(this IMongoQueryable public static IMongoQueryable Join(this IMongoQueryable outer, IMongoCollection inner, Expression> outerKeySelector, Expression> innerKeySelector, Expression> resultSelector) { + Ensure.IsNotNull(outer, nameof(outer)); + Ensure.IsNotNull(inner, nameof(inner)); + Ensure.IsNotNull(outerKeySelector, nameof(outerKeySelector)); + Ensure.IsNotNull(innerKeySelector, nameof(innerKeySelector)); + Ensure.IsNotNull(resultSelector, nameof(resultSelector)); + return Join(outer, inner.AsQueryable(), outerKeySelector, innerKeySelector, resultSelector); } @@ -757,6 +871,8 @@ public static Task FirstOrDefaultAsync(this IMongoQueryable public static Task LongCountAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, long>(Queryable.LongCount, source), @@ -776,6 +892,9 @@ public static Task LongCountAsync(this IMongoQueryable s /// public static Task LongCountAsync(this IMongoQueryable source, Expression> predicate, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(predicate, nameof(predicate)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, long>(Queryable.LongCount, source, predicate), @@ -795,6 +914,8 @@ public static Task LongCountAsync(this IMongoQueryable s /// public static Task MaxAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, TSource>(Queryable.Max, source), @@ -815,6 +936,9 @@ public static Task MaxAsync(this IMongoQueryable sour /// public static Task MaxAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, TResult>(Queryable.Max, source, selector), @@ -834,6 +958,8 @@ public static Task MaxAsync(this IMongoQueryable sour /// public static Task MinAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, TSource>(Queryable.Min, source), @@ -854,6 +980,9 @@ public static Task MinAsync(this IMongoQueryable sour /// public static Task MinAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, TResult>(Queryable.Min, source, selector), @@ -872,6 +1001,8 @@ public static Task MinAsync(this IMongoQueryable sour /// public static IMongoQueryable OfType(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return (IMongoQueryable)Queryable.OfType(source); } @@ -887,6 +1018,9 @@ public static IMongoQueryable OfType(this IMongoQueryable sour /// public static IOrderedMongoQueryable OrderBy(this IMongoQueryable source, Expression> keySelector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(keySelector, nameof(keySelector)); + return (IOrderedMongoQueryable)Queryable.OrderBy(source, keySelector); } @@ -902,6 +1036,9 @@ public static IMongoQueryable OfType(this IMongoQueryable sour /// public static IOrderedMongoQueryable OrderByDescending(this IMongoQueryable source, Expression> keySelector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(keySelector, nameof(keySelector)); + return (IOrderedMongoQueryable)Queryable.OrderByDescending(source, keySelector); } @@ -916,6 +1053,8 @@ public static IMongoQueryable OfType(this IMongoQueryable sour /// public static IMongoQueryable Sample(this IMongoQueryable source, long count) { + Ensure.IsNotNull(source, nameof(source)); + return (IMongoQueryable)source.Provider.CreateQuery( Expression.Call( null, @@ -965,6 +1104,9 @@ public static IMongoQueryable Sample(this IMongoQueryable public static IMongoQueryable Select(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return (IMongoQueryable)Queryable.Select(source, selector); } @@ -980,6 +1122,9 @@ public static IMongoQueryable Sample(this IMongoQueryable public static IMongoQueryable SelectMany(this IMongoQueryable source, Expression>> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return (IMongoQueryable)Queryable.SelectMany(source, selector); } @@ -999,6 +1144,10 @@ public static IMongoQueryable Sample(this IMongoQueryable public static IMongoQueryable SelectMany(this IMongoQueryable source, Expression>> collectionSelector, Expression> resultSelector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(collectionSelector, nameof(collectionSelector)); + Ensure.IsNotNull(resultSelector, nameof(resultSelector)); + return (IMongoQueryable)Queryable.SelectMany(source, collectionSelector, resultSelector); } @@ -1013,6 +1162,8 @@ public static IMongoQueryable Sample(this IMongoQueryable public static Task SingleAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, TSource>(Queryable.Single, source), @@ -1032,6 +1183,9 @@ public static Task SingleAsync(this IMongoQueryable s /// public static Task SingleAsync(this IMongoQueryable source, Expression> predicate, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(predicate, nameof(predicate)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, TSource>(Queryable.Single, source, predicate), @@ -1051,6 +1205,8 @@ public static Task SingleAsync(this IMongoQueryable s /// public static Task SingleOrDefaultAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, TSource>(Queryable.SingleOrDefault, source), @@ -1070,6 +1226,9 @@ public static Task SingleOrDefaultAsync(this IMongoQueryable public static Task SingleOrDefaultAsync(this IMongoQueryable source, Expression> predicate, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(predicate, nameof(predicate)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, TSource>(Queryable.SingleOrDefault, source, predicate), @@ -1091,6 +1250,8 @@ public static Task SingleOrDefaultAsync(this IMongoQueryable public static IMongoQueryable Skip(this IMongoQueryable source, int count) { + Ensure.IsNotNull(source, nameof(source)); + return (IMongoQueryable)Queryable.Skip(source, count); } @@ -1103,6 +1264,8 @@ public static IMongoQueryable Skip(this IMongoQueryable public static double StandardDeviationPopulation(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1118,6 +1281,8 @@ public static double StandardDeviationPopulation(this IMongoQueryable sourc /// public static double? StandardDeviationPopulation(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1133,6 +1298,8 @@ public static double StandardDeviationPopulation(this IMongoQueryable sourc /// public static double StandardDeviationPopulation(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1148,6 +1315,8 @@ public static double StandardDeviationPopulation(this IMongoQueryable sour /// public static double? StandardDeviationPopulation(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1163,6 +1332,8 @@ public static double StandardDeviationPopulation(this IMongoQueryable sour /// public static float StandardDeviationPopulation(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1178,6 +1349,8 @@ public static float StandardDeviationPopulation(this IMongoQueryable sour /// public static float? StandardDeviationPopulation(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1193,6 +1366,8 @@ public static float StandardDeviationPopulation(this IMongoQueryable sour /// public static double StandardDeviationPopulation(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1208,6 +1383,8 @@ public static double StandardDeviationPopulation(this IMongoQueryable so /// public static double? StandardDeviationPopulation(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1223,6 +1400,8 @@ public static double StandardDeviationPopulation(this IMongoQueryable so /// public static decimal StandardDeviationPopulation(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1238,6 +1417,8 @@ public static decimal StandardDeviationPopulation(this IMongoQueryable /// public static decimal? StandardDeviationPopulation(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1255,6 +1436,9 @@ public static decimal StandardDeviationPopulation(this IMongoQueryable /// public static double StandardDeviationPopulation(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1273,6 +1457,9 @@ public static double StandardDeviationPopulation(this IMongoQueryable public static double? StandardDeviationPopulation(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1291,6 +1478,9 @@ public static double StandardDeviationPopulation(this IMongoQueryable public static double StandardDeviationPopulation(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1309,6 +1499,9 @@ public static double StandardDeviationPopulation(this IMongoQueryable public static double? StandardDeviationPopulation(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1327,6 +1520,9 @@ public static double StandardDeviationPopulation(this IMongoQueryable public static float StandardDeviationPopulation(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1345,6 +1541,9 @@ public static float StandardDeviationPopulation(this IMongoQueryable public static float? StandardDeviationPopulation(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1363,6 +1562,9 @@ public static float StandardDeviationPopulation(this IMongoQueryable public static double StandardDeviationPopulation(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1381,6 +1583,9 @@ public static double StandardDeviationPopulation(this IMongoQueryable public static double? StandardDeviationPopulation(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1399,6 +1604,9 @@ public static double StandardDeviationPopulation(this IMongoQueryable public static decimal StandardDeviationPopulation(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1417,6 +1625,9 @@ public static decimal StandardDeviationPopulation(this IMongoQueryable< /// public static decimal? StandardDeviationPopulation(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1434,6 +1645,8 @@ public static decimal StandardDeviationPopulation(this IMongoQueryable< /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1451,6 +1664,8 @@ public static Task StandardDeviationPopulationAsync(this IMongoQueryable /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1468,6 +1683,8 @@ public static Task StandardDeviationPopulationAsync(this IMongoQueryable /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1485,6 +1702,8 @@ public static Task StandardDeviationPopulationAsync(this IMongoQueryable /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1502,6 +1721,8 @@ public static Task StandardDeviationPopulationAsync(this IMongoQueryable /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1519,6 +1740,8 @@ public static Task StandardDeviationPopulationAsync(this IMongoQueryable< /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1536,6 +1759,8 @@ public static Task StandardDeviationPopulationAsync(this IMongoQueryable< /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1553,6 +1778,8 @@ public static Task StandardDeviationPopulationAsync(this IMongoQueryable /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1570,6 +1797,8 @@ public static Task StandardDeviationPopulationAsync(this IMongoQueryable /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1587,6 +1816,8 @@ public static Task StandardDeviationPopulationAsync(this IMongoQueryabl /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source), @@ -1606,6 +1837,9 @@ public static Task StandardDeviationPopulationAsync(this IMongoQueryabl /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1626,6 +1860,9 @@ public static Task StandardDeviationPopulationAsync(this IMongo /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1646,6 +1883,9 @@ public static Task StandardDeviationPopulationAsync(this IMongo /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1666,6 +1906,9 @@ public static Task StandardDeviationPopulationAsync(this IMongo /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1686,6 +1929,9 @@ public static Task StandardDeviationPopulationAsync(this IMongo /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1706,6 +1952,9 @@ public static Task StandardDeviationPopulationAsync(this IMongoQ /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1726,6 +1975,9 @@ public static Task StandardDeviationPopulationAsync(this IMongoQ /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1746,6 +1998,9 @@ public static Task StandardDeviationPopulationAsync(this IMongo /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1766,6 +2021,9 @@ public static Task StandardDeviationPopulationAsync(this IMongo /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1786,6 +2044,9 @@ public static Task StandardDeviationPopulationAsync(this IMong /// public static Task StandardDeviationPopulationAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationPopulation, source, selector), @@ -1803,6 +2064,8 @@ public static Task StandardDeviationPopulationAsync(this IMong /// public static double StandardDeviationSample(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -1818,6 +2081,8 @@ public static double StandardDeviationSample(this IMongoQueryable source) /// public static double? StandardDeviationSample(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -1833,6 +2098,8 @@ public static double StandardDeviationSample(this IMongoQueryable source) /// public static double StandardDeviationSample(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -1848,6 +2115,8 @@ public static double StandardDeviationSample(this IMongoQueryable source) /// public static double? StandardDeviationSample(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -1863,6 +2132,8 @@ public static double StandardDeviationSample(this IMongoQueryable source) /// public static float StandardDeviationSample(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -1878,6 +2149,8 @@ public static float StandardDeviationSample(this IMongoQueryable source) /// public static float? StandardDeviationSample(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -1893,6 +2166,8 @@ public static float StandardDeviationSample(this IMongoQueryable source) /// public static double StandardDeviationSample(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -1908,6 +2183,8 @@ public static double StandardDeviationSample(this IMongoQueryable source /// public static double? StandardDeviationSample(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -1923,6 +2200,8 @@ public static double StandardDeviationSample(this IMongoQueryable source /// public static decimal StandardDeviationSample(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -1938,6 +2217,8 @@ public static decimal StandardDeviationSample(this IMongoQueryable sour /// public static decimal? StandardDeviationSample(this IMongoQueryable source) { + Ensure.IsNotNull(source, nameof(source)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -1955,6 +2236,9 @@ public static decimal StandardDeviationSample(this IMongoQueryable sour /// public static double StandardDeviationSample(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -1973,6 +2257,9 @@ public static double StandardDeviationSample(this IMongoQueryable public static double? StandardDeviationSample(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -1991,6 +2278,9 @@ public static double StandardDeviationSample(this IMongoQueryable public static double StandardDeviationSample(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2009,6 +2299,9 @@ public static double StandardDeviationSample(this IMongoQueryable public static double? StandardDeviationSample(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2027,6 +2320,9 @@ public static double StandardDeviationSample(this IMongoQueryable public static float StandardDeviationSample(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2045,6 +2341,9 @@ public static float StandardDeviationSample(this IMongoQueryable public static float? StandardDeviationSample(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2063,6 +2362,9 @@ public static float StandardDeviationSample(this IMongoQueryable public static double StandardDeviationSample(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2081,6 +2383,9 @@ public static double StandardDeviationSample(this IMongoQueryable public static double? StandardDeviationSample(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2099,6 +2404,9 @@ public static double StandardDeviationSample(this IMongoQueryable public static decimal StandardDeviationSample(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2117,6 +2425,9 @@ public static decimal StandardDeviationSample(this IMongoQueryable public static decimal? StandardDeviationSample(this IMongoQueryable source, Expression> selector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return source.Provider.Execute( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2134,6 +2445,8 @@ public static decimal StandardDeviationSample(this IMongoQueryable public static Task StandardDeviationSampleAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -2151,6 +2464,8 @@ public static Task StandardDeviationSampleAsync(this IMongoQueryable public static Task StandardDeviationSampleAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -2168,6 +2483,8 @@ public static Task StandardDeviationSampleAsync(this IMongoQueryable public static Task StandardDeviationSampleAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -2185,6 +2502,8 @@ public static Task StandardDeviationSampleAsync(this IMongoQueryable public static Task StandardDeviationSampleAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -2202,6 +2521,8 @@ public static Task StandardDeviationSampleAsync(this IMongoQueryable public static Task StandardDeviationSampleAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -2219,6 +2540,8 @@ public static Task StandardDeviationSampleAsync(this IMongoQueryable public static Task StandardDeviationSampleAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -2236,6 +2559,8 @@ public static Task StandardDeviationSampleAsync(this IMongoQueryable public static Task StandardDeviationSampleAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -2253,6 +2578,8 @@ public static Task StandardDeviationSampleAsync(this IMongoQueryable public static Task StandardDeviationSampleAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -2270,6 +2597,8 @@ public static Task StandardDeviationSampleAsync(this IMongoQueryable public static Task StandardDeviationSampleAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -2287,6 +2616,8 @@ public static Task StandardDeviationSampleAsync(this IMongoQueryable public static Task StandardDeviationSampleAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source), @@ -2306,6 +2637,9 @@ public static Task StandardDeviationSampleAsync(this IMongoQueryable public static Task StandardDeviationSampleAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2326,6 +2660,9 @@ public static Task StandardDeviationSampleAsync(this IMongoQuer /// public static Task StandardDeviationSampleAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2346,6 +2683,9 @@ public static Task StandardDeviationSampleAsync(this IMongoQuer /// public static Task StandardDeviationSampleAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2366,6 +2706,9 @@ public static Task StandardDeviationSampleAsync(this IMongoQuer /// public static Task StandardDeviationSampleAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2386,6 +2729,9 @@ public static Task StandardDeviationSampleAsync(this IMongoQuer /// public static Task StandardDeviationSampleAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2406,6 +2752,9 @@ public static Task StandardDeviationSampleAsync(this IMongoQuery /// public static Task StandardDeviationSampleAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2426,6 +2775,9 @@ public static Task StandardDeviationSampleAsync(this IMongoQuery /// public static Task StandardDeviationSampleAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2446,6 +2798,9 @@ public static Task StandardDeviationSampleAsync(this IMongoQuer /// public static Task StandardDeviationSampleAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2466,6 +2821,9 @@ public static Task StandardDeviationSampleAsync(this IMongoQuer /// public static Task StandardDeviationSampleAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2486,6 +2844,9 @@ public static Task StandardDeviationSampleAsync(this IMongoQue /// public static Task StandardDeviationSampleAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo(StandardDeviationSample, source, selector), @@ -2502,6 +2863,8 @@ public static Task StandardDeviationSampleAsync(this IMongoQue /// The sum of the values in the sequence. public static Task SumAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, decimal>(Queryable.Sum, source), @@ -2517,6 +2880,8 @@ public static Task SumAsync(this IMongoQueryable source, Cance /// The sum of the values in the sequence. public static Task SumAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, decimal?>(Queryable.Sum, source), @@ -2532,6 +2897,8 @@ public static Task SumAsync(this IMongoQueryable source, Cance /// The sum of the values in the sequence. public static Task SumAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, double>(Queryable.Sum, source), @@ -2547,6 +2914,8 @@ public static Task SumAsync(this IMongoQueryable source, Cancell /// The sum of the values in the sequence. public static Task SumAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, double?>(Queryable.Sum, source), @@ -2562,6 +2931,8 @@ public static Task SumAsync(this IMongoQueryable source, Cancell /// The sum of the values in the sequence. public static Task SumAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, float>(Queryable.Sum, source), @@ -2577,6 +2948,8 @@ public static Task SumAsync(this IMongoQueryable source, Cancellat /// The sum of the values in the sequence. public static Task SumAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, float?>(Queryable.Sum, source), @@ -2592,6 +2965,8 @@ public static Task SumAsync(this IMongoQueryable source, Cancellat /// The sum of the values in the sequence. public static Task SumAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, int>(Queryable.Sum, source), @@ -2607,6 +2982,8 @@ public static Task SumAsync(this IMongoQueryable source, CancellationT /// The sum of the values in the sequence. public static Task SumAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, int?>(Queryable.Sum, source), @@ -2622,6 +2999,8 @@ public static Task SumAsync(this IMongoQueryable source, CancellationT /// The sum of the values in the sequence. public static Task SumAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, long>(Queryable.Sum, source), @@ -2637,6 +3016,8 @@ public static Task SumAsync(this IMongoQueryable source, Cancellatio /// The sum of the values in the sequence. public static Task SumAsync(this IMongoQueryable source, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, long?>(Queryable.Sum, source), @@ -2657,6 +3038,9 @@ public static Task SumAsync(this IMongoQueryable source, Cancellatio /// public static Task SumAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, decimal>(Queryable.Sum, source, selector), @@ -2678,6 +3062,9 @@ public static Task SumAsync(this IMongoQueryable sour /// public static Task SumAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, decimal?>(Queryable.Sum, source, selector), @@ -2699,6 +3086,9 @@ public static Task SumAsync(this IMongoQueryable sour /// public static Task SumAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, double>(Queryable.Sum, source, selector), @@ -2720,6 +3110,9 @@ public static Task SumAsync(this IMongoQueryable sourc /// public static Task SumAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, double?>(Queryable.Sum, source, selector), @@ -2741,6 +3134,9 @@ public static Task SumAsync(this IMongoQueryable sourc /// public static Task SumAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, float>(Queryable.Sum, source, selector), @@ -2762,6 +3158,9 @@ public static Task SumAsync(this IMongoQueryable source /// public static Task SumAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, float?>(Queryable.Sum, source, selector), @@ -2783,6 +3182,9 @@ public static Task SumAsync(this IMongoQueryable source /// public static Task SumAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, int>(Queryable.Sum, source, selector), @@ -2804,6 +3206,9 @@ public static Task SumAsync(this IMongoQueryable source, /// public static Task SumAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, int?>(Queryable.Sum, source, selector), @@ -2825,6 +3230,9 @@ public static Task SumAsync(this IMongoQueryable source, /// public static Task SumAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, long>(Queryable.Sum, source, selector), @@ -2846,6 +3254,9 @@ public static Task SumAsync(this IMongoQueryable source, /// public static Task SumAsync(this IMongoQueryable source, Expression> selector, CancellationToken cancellationToken = default(CancellationToken)) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(selector, nameof(selector)); + return ((IMongoQueryProvider)source.Provider).ExecuteAsync( Expression.Call( GetMethodInfo, Expression>, long?>(Queryable.Sum, source, selector), @@ -2866,6 +3277,8 @@ public static Task SumAsync(this IMongoQueryable source, /// public static IMongoQueryable Take(this IMongoQueryable source, int count) { + Ensure.IsNotNull(source, nameof(source)); + return (IMongoQueryable)Queryable.Take(source, count); } @@ -2882,6 +3295,9 @@ public static IMongoQueryable Take(this IMongoQueryable public static IOrderedMongoQueryable ThenBy(this IOrderedMongoQueryable source, Expression> keySelector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(keySelector, nameof(keySelector)); + return (IOrderedMongoQueryable)Queryable.ThenBy(source, keySelector); } @@ -2898,6 +3314,9 @@ public static IMongoQueryable Take(this IMongoQueryable public static IOrderedMongoQueryable ThenByDescending(this IOrderedMongoQueryable source, Expression> keySelector) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(keySelector, nameof(keySelector)); + return (IOrderedMongoQueryable)Queryable.ThenByDescending(source, keySelector); } @@ -2913,6 +3332,9 @@ public static IMongoQueryable Take(this IMongoQueryable public static IMongoQueryable Where(this IMongoQueryable source, Expression> predicate) { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(predicate, nameof(predicate)); + return (IMongoQueryable)Queryable.Where(source, predicate); } From 4d816922c4bb133e7dfc9d5d2a60ef8b08dfc72c Mon Sep 17 00:00:00 2001 From: rstam Date: Tue, 6 Dec 2022 10:05:46 -0800 Subject: [PATCH 12/21] CSHARP-4339: Added database.AsQueryable(). --- .../IMongoDatabaseExtensions.cs | 37 ++++++++++ .../LinqProviderAdapterV2.cs | 8 +++ .../LinqProviderAdapterV3.cs | 10 +++ .../Linq3Implementation/MongoQueryProvider.cs | 11 +++ .../AllMethodToExecutableQueryTranslator.cs | 3 +- .../AnyMethodToExecutableQueryTranslator.cs | 3 +- ...verageMethodToExecutableQueryTranslator.cs | 3 +- ...ntainsMethodToExecutableQueryTranslator.cs | 3 +- .../CountMethodToExecutableQueryTranslator.cs | 3 +- ...mentAtMethodToExecutableQueryTranslator.cs | 3 +- .../ExecutableQuery.cs | 70 +++++++++++++------ .../ExpressionToExecutableQueryTranslator.cs | 3 +- .../FirstMethodToExecutableQueryTranslator.cs | 3 +- .../LastMethodToExecutableQueryTranslator.cs | 3 +- ...gCountMethodToExecutableQueryTranslator.cs | 3 +- .../MaxMethodToExecutableQueryTranslator.cs | 3 +- .../MinMethodToExecutableQueryTranslator.cs | 3 +- ...SingleMethodToExecutableQueryTranslator.cs | 3 +- ...iationMethodToExecutableQueryTranslator.cs | 3 +- .../SumMethodToExecutableQueryTranslator.cs | 3 +- .../Linq/LinqProviderAdapter.cs | 5 ++ 21 files changed, 133 insertions(+), 53 deletions(-) diff --git a/src/MongoDB.Driver/IMongoDatabaseExtensions.cs b/src/MongoDB.Driver/IMongoDatabaseExtensions.cs index 41cd63452e0..f47b65e6c03 100644 --- a/src/MongoDB.Driver/IMongoDatabaseExtensions.cs +++ b/src/MongoDB.Driver/IMongoDatabaseExtensions.cs @@ -18,6 +18,7 @@ using MongoDB.Bson; using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Core.Operations; +using MongoDB.Driver.Linq; namespace MongoDB.Driver { @@ -56,6 +57,34 @@ public static IAggregateFluent Aggregate(this IMongoDatabase da return new DatabaseAggregateFluent(session, database, emptyPipeline, options ?? new AggregateOptions()); } + /// + /// Creates a queryable source of documents. + /// + /// The database. + /// The aggregate options + /// A queryable source of documents. + public static IMongoQueryable AsQueryable(this IMongoDatabase database, AggregateOptions aggregateOptions = null) + { + Ensure.IsNotNull(database, nameof(database)); + + return AsQueryableHelper(database, session: null, aggregateOptions); + } + + /// + /// Creates a queryable source of documents. + /// + /// The collection. + /// The session. + /// The aggregate options + /// A queryable source of documents. + public static IMongoQueryable AsQueryable(this IMongoDatabase database, IClientSessionHandle session, AggregateOptions aggregateOptions = null) + { + Ensure.IsNotNull(database, nameof(database)); + Ensure.IsNotNull(session, nameof(session)); + + return AsQueryableHelper(database, session, aggregateOptions); + } + /// /// Watches changes on all collection in a database. /// @@ -137,5 +166,13 @@ public static IAggregateFluent Aggregate(this IMongoDatabase da var emptyPipeline = new EmptyPipelineDefinition>(); return database.WatchAsync(session, emptyPipeline, options, cancellationToken); } + + // private static methods + private static IMongoQueryable AsQueryableHelper(IMongoDatabase database, IClientSessionHandle session, AggregateOptions aggregateOptions) + { + var linqProvider = database.Client.Settings.LinqProvider; + aggregateOptions = aggregateOptions ?? new AggregateOptions(); + return linqProvider.GetAdapter().AsQueryable(database, session, aggregateOptions); + } } } diff --git a/src/MongoDB.Driver/Linq/Linq2Implementation/LinqProviderAdapterV2.cs b/src/MongoDB.Driver/Linq/Linq2Implementation/LinqProviderAdapterV2.cs index 2034fd74744..165f538ae41 100644 --- a/src/MongoDB.Driver/Linq/Linq2Implementation/LinqProviderAdapterV2.cs +++ b/src/MongoDB.Driver/Linq/Linq2Implementation/LinqProviderAdapterV2.cs @@ -36,6 +36,14 @@ internal sealed class LinqProviderAdapterV2 : LinqProviderAdapter return new MongoQueryableImpl(provider); } + internal override IMongoQueryable AsQueryable( + IMongoDatabase database, + IClientSessionHandle session, + AggregateOptions options) + { + throw new InvalidOperationException("LINQ2 does not support AsQueryable against a database."); + } + public override string ToString() => "V2"; internal override BsonValue TranslateExpressionToAggregateExpression( diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/LinqProviderAdapterV3.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/LinqProviderAdapterV3.cs index 798d01eeae3..b731b761926 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/LinqProviderAdapterV3.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/LinqProviderAdapterV3.cs @@ -14,6 +14,7 @@ */ using System; +using System.Collections.ObjectModel; using System.Linq; using System.Linq.Expressions; using MongoDB.Bson; @@ -38,6 +39,15 @@ internal sealed class LinqProviderAdapterV3 : LinqProviderAdapter return new MongoQuery(provider); } + internal override IMongoQueryable AsQueryable( + IMongoDatabase database, + IClientSessionHandle session, + AggregateOptions options) + { + var provider = new MongoQueryProvider(database, session, options); + return new MongoQuery(provider); + } + public override string ToString() => "V3"; internal override BsonValue TranslateExpressionToAggregateExpression( diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/MongoQueryProvider.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/MongoQueryProvider.cs index eb2c61575ba..5099e1edbbd 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/MongoQueryProvider.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/MongoQueryProvider.cs @@ -60,6 +60,7 @@ internal sealed class MongoQueryProvider : MongoQueryProvider { // private fields private readonly IMongoCollection _collection; + private readonly IMongoDatabase _database; private ExecutableQuery _mostRecentExecutableQuery; // constructors @@ -72,10 +73,20 @@ internal sealed class MongoQueryProvider : MongoQueryProvider _collection = collection; } + public MongoQueryProvider( + IMongoDatabase database, + IClientSessionHandle session, + AggregateOptions options) + : base(session, options) + { + _database = database; + } + // public properties public IMongoCollection Collection => _collection; public override CollectionNamespace CollectionNamespace => _collection.CollectionNamespace; public override IBsonSerializer CollectionDocumentSerializer => _collection.DocumentSerializer; + public IMongoDatabase Database => _database; // public methods public override IQueryable CreateQuery(Expression expression) diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AllMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AllMethodToExecutableQueryTranslator.cs index 0f82f6d0eeb..fc5f14f83c1 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AllMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AllMethodToExecutableQueryTranslator.cs @@ -60,8 +60,7 @@ internal static class AllMethodToExecutableQueryTranslator AstProject.Set("_v", BsonNull.Value))); return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, __finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AnyMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AnyMethodToExecutableQueryTranslator.cs index 3f61f2317d8..f6cd21c4820 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AnyMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AnyMethodToExecutableQueryTranslator.cs @@ -86,8 +86,7 @@ static AnyMethodToExecutableQueryTranslator() AstProject.Set("_v", BsonNull.Value))); return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, __finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AverageMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AverageMethodToExecutableQueryTranslator.cs index a08e41147a8..7522fa50ed9 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AverageMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/AverageMethodToExecutableQueryTranslator.cs @@ -156,8 +156,7 @@ static AverageMethodToExecutableQueryTranslator() AstStage.Project(AstProject.ExcludeId())); return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, __finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ContainsMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ContainsMethodToExecutableQueryTranslator.cs index b211c9f7477..fcbc7e2c23a 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ContainsMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ContainsMethodToExecutableQueryTranslator.cs @@ -79,8 +79,7 @@ internal static class ContainsMethodToExecutableQueryTranslator AstProject.Set("_v", BsonNull.Value))); return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, __finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/CountMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/CountMethodToExecutableQueryTranslator.cs index 503f9459a28..c2f8a23d44d 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/CountMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/CountMethodToExecutableQueryTranslator.cs @@ -79,8 +79,7 @@ static CountMethodToExecutableQueryTranslator() AstStage.Count("_v")); return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, _finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ElementAtMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ElementAtMethodToExecutableQueryTranslator.cs index 080d64a5f25..24d150e303a 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ElementAtMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ElementAtMethodToExecutableQueryTranslator.cs @@ -48,8 +48,7 @@ internal static class ElementAtMethodToExecutableQueryTranslator AstStage.Limit(1)); return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, __finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExecutableQuery.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExecutableQuery.cs index 41a46205605..94857acd01f 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExecutableQuery.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExecutableQuery.cs @@ -34,13 +34,14 @@ internal static class ExecutableQueryExtensions internal static class ExecutableQuery { public static ExecutableQuery Create( - IMongoCollection collection, - AggregateOptions options, + MongoQueryProvider provider, AstPipeline unoptimizedPipeline, IExecutableQueryFinalizer finalizer) { var pipeline = AstPipelineOptimizer.Optimize(unoptimizedPipeline); - return new ExecutableQuery(collection, options, unoptimizedPipeline, pipeline, finalizer); + return provider.Collection == null ? + new ExecutableQuery(provider.Database, provider.Options, unoptimizedPipeline, pipeline, finalizer) : + new ExecutableQuery(provider.Collection, provider.Options, unoptimizedPipeline, pipeline, finalizer); } } @@ -60,6 +61,7 @@ internal class ExecutableQuery : ExecutableQuery _collection; + private readonly IMongoDatabase _database; private readonly IExecutableQueryFinalizer _finalizer; private readonly AggregateOptions _options; private readonly AstPipeline _pipeline; @@ -72,8 +74,28 @@ internal class ExecutableQuery : ExecutableQuery finalizer) + : this(options, unoptimizedPipeline, pipeline, finalizer) { _collection = collection; + } + + public ExecutableQuery( + IMongoDatabase database, + AggregateOptions options, + AstPipeline unoptimizedPipeline, + AstPipeline pipeline, + IExecutableQueryFinalizer finalizer) + : this(options, unoptimizedPipeline, pipeline, finalizer) + { + _database = database; + } + + private ExecutableQuery( + AggregateOptions options, + AstPipeline unoptimizedPipeline, + AstPipeline pipeline, + IExecutableQueryFinalizer finalizer) + { _options = options; _unoptimizedPipeline = unoptimizedPipeline; _pipeline = pipeline; @@ -87,44 +109,46 @@ internal class ExecutableQuery : ExecutableQuery cursor; - if (session == null) - { - cursor = _collection.Aggregate(pipelineDefinition, _options, cancellationToken); - } - else + var cursor = (_collection, session) switch { - cursor = _collection.Aggregate(session, pipelineDefinition, _options, cancellationToken); - } + (null, null) => _database.Aggregate(CreateDatabasePipelineDefinition(), _options, cancellationToken), + (null, _) => _database.Aggregate(session, CreateDatabasePipelineDefinition(), _options, cancellationToken), + (_, null) => _collection.Aggregate(CreateCollectionPipelineDefinition(), _options, cancellationToken), + (_, _) => _collection.Aggregate(session, CreateCollectionPipelineDefinition(), _options, cancellationToken) + }; + return _finalizer.Finalize(cursor, cancellationToken); } public override async Task ExecuteAsync(IClientSessionHandle session, CancellationToken cancellationToken) { - var pipelineDefinition = CreatePipelineDefinition(); - IAsyncCursor cursor; - if (session == null) + var cursor = (_collection, session) switch { - cursor = await _collection.AggregateAsync(pipelineDefinition, _options, cancellationToken).ConfigureAwait(false); - } - else - { - cursor = await _collection.AggregateAsync(session, pipelineDefinition, _options, cancellationToken).ConfigureAwait(false); - } + (null, null) => await _database.AggregateAsync(CreateDatabasePipelineDefinition(), _options, cancellationToken).ConfigureAwait(false), + (null, _) => await _database.AggregateAsync(session, CreateDatabasePipelineDefinition(), _options, cancellationToken).ConfigureAwait(false), + (_, null) => await _collection.AggregateAsync(CreateCollectionPipelineDefinition(), _options, cancellationToken).ConfigureAwait(false), + (_, _) => await _collection.AggregateAsync(session, CreateCollectionPipelineDefinition(), _options, cancellationToken).ConfigureAwait(false) + }; + return await _finalizer.FinalizeAsync(cursor, cancellationToken).ConfigureAwait(false); } public override string ToString() { - return $"{_collection.CollectionNamespace}.Aggregate({_pipeline})"; + return $"{(_collection == null ? _database.DatabaseNamespace : _collection.CollectionNamespace)}.Aggregate({_pipeline})"; } // private methods - private BsonDocumentStagePipelineDefinition CreatePipelineDefinition() + private BsonDocumentStagePipelineDefinition CreateCollectionPipelineDefinition() { var stages = _pipeline.Stages.Select(s => (BsonDocument)s.Render()); return new BsonDocumentStagePipelineDefinition(stages, (IBsonSerializer)_pipeline.OutputSerializer); } + + private BsonDocumentStagePipelineDefinition CreateDatabasePipelineDefinition() + { + var stages = _pipeline.Stages.Select(s => (BsonDocument)s.Render()); + return new BsonDocumentStagePipelineDefinition(stages, (IBsonSerializer)_pipeline.OutputSerializer); + } } } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExpressionToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExpressionToExecutableQueryTranslator.cs index 0cf5e7b6c3a..7ed4b5524b6 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExpressionToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExpressionToExecutableQueryTranslator.cs @@ -34,8 +34,7 @@ internal static class ExpressionToExecutableQueryTranslator var pipeline = ExpressionToPipelineTranslator.Translate(context, expression); return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, IdentityFinalizer.Instance); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/FirstMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/FirstMethodToExecutableQueryTranslator.cs index 59bd56ffcd2..f22bb94e094 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/FirstMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/FirstMethodToExecutableQueryTranslator.cs @@ -84,8 +84,7 @@ static FirstMethodToExecutableQueryTranslator() var finalizer = method.Name == "FirstOrDefault" ? __firstOrDefaultFinalizer : __firstFinalizer; return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/LastMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/LastMethodToExecutableQueryTranslator.cs index 4a02ac576d3..42b65bd2203 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/LastMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/LastMethodToExecutableQueryTranslator.cs @@ -82,8 +82,7 @@ static LastMethodToExecutableQueryTranslator() var finalizer = method.Name == "LastOrDefault" ? __singleOrDefaultFinalizer : __singleFinalizer; return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/LongCountMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/LongCountMethodToExecutableQueryTranslator.cs index 71d1300ab88..0de239b9e5c 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/LongCountMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/LongCountMethodToExecutableQueryTranslator.cs @@ -79,8 +79,7 @@ static LongCountMethodToExecutableQueryTranslator() AstStage.Count("_v")); return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, _finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/MaxMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/MaxMethodToExecutableQueryTranslator.cs index a8c8679b0e5..99f5ab20975 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/MaxMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/MaxMethodToExecutableQueryTranslator.cs @@ -97,8 +97,7 @@ static MaxMethodToExecutableQueryTranslator() AstStage.ReplaceRoot(AstExpression.GetField(root, "_max"))); return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, __finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/MinMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/MinMethodToExecutableQueryTranslator.cs index 14f54766c69..8b9ca579129 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/MinMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/MinMethodToExecutableQueryTranslator.cs @@ -97,8 +97,7 @@ static MinMethodToExecutableQueryTranslator() AstStage.ReplaceRoot(AstExpression.GetField(root, "_min"))); return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, __finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/SingleMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/SingleMethodToExecutableQueryTranslator.cs index de87b7e78cc..f432b98435a 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/SingleMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/SingleMethodToExecutableQueryTranslator.cs @@ -93,8 +93,7 @@ static SingleMethodToExecutableQueryTranslator() var finalizer = method.IsOneOf(__singleOrDefaultMethods) ? __singleOrDefaultFinalizer : __singleFinalizer; return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/StandardDeviationMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/StandardDeviationMethodToExecutableQueryTranslator.cs index 095432802c6..843e38907f1 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/StandardDeviationMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/StandardDeviationMethodToExecutableQueryTranslator.cs @@ -297,8 +297,7 @@ static StandardDeviationMethodToExecutableQueryTranslator() var finalizer = method.IsOneOf(__standardDeviationNullableMethods) ? __singleOrDefaultFinalizer : __singleFinalizer; return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, finalizer); } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/SumMethodToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/SumMethodToExecutableQueryTranslator.cs index 7c929864a27..ecd3d5094ce 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/SumMethodToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/SumMethodToExecutableQueryTranslator.cs @@ -146,8 +146,7 @@ static SumMethodToExecutableQueryTranslator() AstStage.Project(AstProject.ExcludeId())); return ExecutableQuery.Create( - provider.Collection, - provider.Options, + provider, pipeline, __finalizer); } diff --git a/src/MongoDB.Driver/Linq/LinqProviderAdapter.cs b/src/MongoDB.Driver/Linq/LinqProviderAdapter.cs index 603e1a185ea..1901f19f51b 100644 --- a/src/MongoDB.Driver/Linq/LinqProviderAdapter.cs +++ b/src/MongoDB.Driver/Linq/LinqProviderAdapter.cs @@ -35,6 +35,11 @@ internal abstract class LinqProviderAdapter IClientSessionHandle session, AggregateOptions options); + internal abstract IMongoQueryable AsQueryable( + IMongoDatabase database, + IClientSessionHandle session, + AggregateOptions options); + internal abstract BsonValue TranslateExpressionToAggregateExpression( Expression> expression, IBsonSerializer sourceSerializer, From 43d893944056daff7d215c203577dee799abd896 Mon Sep 17 00:00:00 2001 From: rstam Date: Tue, 13 Dec 2022 16:32:31 -0800 Subject: [PATCH 13/21] CSHARP-4339: Add support for $documents in LINQ. --- .../IMongoDatabaseExtensions.cs | 1 - .../Linq/IMongoQueryProvider.cs | 4 +- .../MongoQueryProviderImpl.cs | 3 +- .../Processors/Pipeline/PipelineBinder.cs | 4 +- .../Processors/SerializationBinder.cs | 2 +- .../Linq3Implementation/Ast/AstNodeType.cs | 1 + .../Ast/Stages/AstDocumentsStage.cs | 55 ++++++ .../Ast/Stages/AstStage.cs | 6 + .../Ast/Visitors/AstNodeVisitor.cs | 5 + .../ExtensionMethods/ExpressionExtensions.cs | 12 +- .../GroupExpressionStageDefinitions.cs | 3 +- .../LinqProviderAdapterV3.cs | 1 - .../Linq3Implementation/MongoQueryProvider.cs | 11 +- .../Reflection/MongoQueryableMethod.cs | 7 + .../ExecutableQuery.cs | 6 +- .../ExpressionToExecutableQueryTranslator.cs | 6 +- .../DocumentsMethodToPipelineTranslator.cs | 65 +++++++ .../ExpressionToPipelineTranslator.cs | 4 +- src/MongoDB.Driver/Linq/MongoQueryable.cs | 47 +++++ src/MongoDB.Driver/NoPipelineInput.cs | 9 +- .../Jira/CSharp4339Tests.cs | 166 ++++++++++++++++++ .../Linq3IntegrationTest.cs | 6 + 22 files changed, 394 insertions(+), 30 deletions(-) create mode 100644 src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Stages/AstDocumentsStage.cs create mode 100644 src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/DocumentsMethodToPipelineTranslator.cs create mode 100644 tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4339Tests.cs diff --git a/src/MongoDB.Driver/IMongoDatabaseExtensions.cs b/src/MongoDB.Driver/IMongoDatabaseExtensions.cs index f47b65e6c03..e8a41affbe0 100644 --- a/src/MongoDB.Driver/IMongoDatabaseExtensions.cs +++ b/src/MongoDB.Driver/IMongoDatabaseExtensions.cs @@ -17,7 +17,6 @@ using System.Threading.Tasks; using MongoDB.Bson; using MongoDB.Driver.Core.Misc; -using MongoDB.Driver.Core.Operations; using MongoDB.Driver.Linq; namespace MongoDB.Driver diff --git a/src/MongoDB.Driver/Linq/IMongoQueryProvider.cs b/src/MongoDB.Driver/Linq/IMongoQueryProvider.cs index 6978e7974f7..751114e28a6 100644 --- a/src/MongoDB.Driver/Linq/IMongoQueryProvider.cs +++ b/src/MongoDB.Driver/Linq/IMongoQueryProvider.cs @@ -32,9 +32,9 @@ internal interface IMongoQueryProvider : IQueryProvider CollectionNamespace CollectionNamespace { get; } /// - /// Gets the collection document serializer. + /// Gets the pipeline input serializer (the DocumentSerializer for collection queries and NoPipelineInputSerializer for database queries). /// - IBsonSerializer CollectionDocumentSerializer { get; } + IBsonSerializer PipelineInputSerializer { get; } /// /// Gets the execution model. diff --git a/src/MongoDB.Driver/Linq/Linq2Implementation/MongoQueryProviderImpl.cs b/src/MongoDB.Driver/Linq/Linq2Implementation/MongoQueryProviderImpl.cs index 3cb4676a7dc..783b6a31e19 100644 --- a/src/MongoDB.Driver/Linq/Linq2Implementation/MongoQueryProviderImpl.cs +++ b/src/MongoDB.Driver/Linq/Linq2Implementation/MongoQueryProviderImpl.cs @@ -21,7 +21,6 @@ using System.Threading.Tasks; using MongoDB.Bson.Serialization; using MongoDB.Driver.Core.Misc; -using MongoDB.Driver.Linq; using MongoDB.Driver.Linq.Linq2Implementation.Processors; using MongoDB.Driver.Linq.Linq2Implementation.Processors.Pipeline; using MongoDB.Driver.Linq.Linq2Implementation.Translators; @@ -44,7 +43,7 @@ public MongoQueryProviderImpl(IMongoCollection collection, IClientSes public CollectionNamespace CollectionNamespace => _collection.CollectionNamespace; - public IBsonSerializer CollectionDocumentSerializer => _collection.DocumentSerializer; + public IBsonSerializer PipelineInputSerializer => _collection.DocumentSerializer; public IQueryable CreateQuery(Expression expression) { diff --git a/src/MongoDB.Driver/Linq/Linq2Implementation/Processors/Pipeline/PipelineBinder.cs b/src/MongoDB.Driver/Linq/Linq2Implementation/Processors/Pipeline/PipelineBinder.cs index 7a33ac08ceb..50fe969ee4c 100644 --- a/src/MongoDB.Driver/Linq/Linq2Implementation/Processors/Pipeline/PipelineBinder.cs +++ b/src/MongoDB.Driver/Linq/Linq2Implementation/Processors/Pipeline/PipelineBinder.cs @@ -80,8 +80,8 @@ protected override Expression BindNonMethodCall(Expression node) var queryable = (IMongoQueryable)((ConstantExpression)node).Value; var provider = (IMongoQueryProvider)queryable.Provider; return new PipelineExpression( - new CollectionExpression(provider.CollectionNamespace, provider.CollectionDocumentSerializer), - new DocumentExpression(provider.CollectionDocumentSerializer)); + new CollectionExpression(provider.CollectionNamespace, provider.PipelineInputSerializer), + new DocumentExpression(provider.PipelineInputSerializer)); } var message = string.Format("The expression tree is not supported: {0}", diff --git a/src/MongoDB.Driver/Linq/Linq2Implementation/Processors/SerializationBinder.cs b/src/MongoDB.Driver/Linq/Linq2Implementation/Processors/SerializationBinder.cs index 7187c157060..f5984633917 100644 --- a/src/MongoDB.Driver/Linq/Linq2Implementation/Processors/SerializationBinder.cs +++ b/src/MongoDB.Driver/Linq/Linq2Implementation/Processors/SerializationBinder.cs @@ -96,7 +96,7 @@ protected override Expression VisitConstant(ConstantExpression node) var provider = (IMongoQueryProvider)queryable.Provider; return new CollectionExpression( provider.CollectionNamespace, - provider.CollectionDocumentSerializer); + provider.PipelineInputSerializer); } return base.VisitConstant(node); diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/AstNodeType.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/AstNodeType.cs index d8f3a3b1864..5aed9e20b53 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/AstNodeType.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/AstNodeType.cs @@ -53,6 +53,7 @@ internal enum AstNodeType DateTruncExpression, DensifyStage, DerivativeOrIntegralWindowExpression, + DocumentsStage, ElemMatchFilterOperation, ExistsFilterOperation, ExponentialMovingAverageWindowExpression, diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Stages/AstDocumentsStage.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Stages/AstDocumentsStage.cs new file mode 100644 index 00000000000..390337f9071 --- /dev/null +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Stages/AstDocumentsStage.cs @@ -0,0 +1,55 @@ +/* Copyright 2010-present MongoDB Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +using MongoDB.Bson; +using MongoDB.Driver.Core.Misc; +using MongoDB.Driver.Linq.Linq3Implementation.Ast.Expressions; +using MongoDB.Driver.Linq.Linq3Implementation.Ast.Visitors; + +namespace MongoDB.Driver.Linq.Linq3Implementation.Ast.Stages +{ + internal sealed class AstDocumentsStage : AstStage + { + private readonly AstExpression _documents; + + public AstDocumentsStage(AstExpression documents) + { + _documents = Ensure.IsNotNull(documents, nameof(documents)); + } + + public new AstExpression Documents => _documents; + public override AstNodeType NodeType => AstNodeType.DocumentsStage; + + public override AstNode Accept(AstNodeVisitor visitor) + { + return visitor.VisitDocumentsStage(this); + } + + public override BsonValue Render() + { + return new BsonDocument("$documents", _documents.Render()); + } + + public AstDocumentsStage Update(AstExpression documents) + { + if (documents == _documents) + { + return this; + } + + return new AstDocumentsStage(documents); + } + } +} diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Stages/AstStage.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Stages/AstStage.cs index 9eed0df438f..4273e22dec7 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Stages/AstStage.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Stages/AstStage.cs @@ -77,6 +77,12 @@ public static AstStage Count(string outputField) return new AstDensifyStage(fieldPath, range, partitionByFieldPaths); } + public static AstStage Documents( + AstExpression documents) + { + return new AstDocumentsStage(documents); + } + public static AstStage Facet(IEnumerable facets) { return new AstFacetStage(facets); diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Visitors/AstNodeVisitor.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Visitors/AstNodeVisitor.cs index d9d3e98298a..04486e84174 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Visitors/AstNodeVisitor.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Ast/Visitors/AstNodeVisitor.cs @@ -299,6 +299,11 @@ public virtual AstNode VisitDerivativeOrIntegralWindowExpression(AstDerivativeOr return node.Update(node.Operator, VisitAndConvert(node.Arg), node.Unit, node.Window); } + public virtual AstNode VisitDocumentsStage(AstDocumentsStage node) + { + return node.Update(VisitAndConvert(node.Documents)); + } + public virtual AstNode VisitElemMatchFilterOperation(AstElemMatchFilterOperation node) { return node.Update(VisitAndConvert(node.Filter)); diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/ExtensionMethods/ExpressionExtensions.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/ExtensionMethods/ExpressionExtensions.cs index c4d43590ab0..1634ce60c99 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/ExtensionMethods/ExpressionExtensions.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/ExtensionMethods/ExpressionExtensions.cs @@ -13,7 +13,6 @@ * limitations under the License. */ -using System.Linq; using System.Linq.Expressions; using MongoDB.Bson.Serialization; @@ -24,14 +23,15 @@ internal static class ExpressionExtensions public static (string CollectionName, IBsonSerializer DocumentSerializer) GetCollectionInfo(this Expression innerExpression, Expression containerExpression) { if (innerExpression is ConstantExpression constantExpression && - constantExpression.Value is IQueryable queryable && - queryable.Provider is MongoQueryProvider queryProvider) + constantExpression.Value is IMongoQueryable mongoQueryable && + mongoQueryable.Provider is IMongoQueryProvider mongoQueryProvider && + mongoQueryProvider.CollectionNamespace != null) { - return (queryProvider.CollectionNamespace.CollectionName, queryProvider.CollectionDocumentSerializer); + return (mongoQueryProvider.CollectionNamespace.CollectionName, mongoQueryProvider.PipelineInputSerializer); } - var message = $"Expression inner must be a MongoDB queryable representing a collection: {innerExpression} in {containerExpression}."; - throw new ExpressionNotSupportedException(message); + var message = $"inner expression is not an IMongoQueryable representing a collection"; + throw new ExpressionNotSupportedException(innerExpression, containerExpression, because: message); } public static TValue GetConstantValue(this Expression expression, Expression containingExpression) diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/GroupExpressionStageDefinitions.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/GroupExpressionStageDefinitions.cs index 2d4790fa3e2..39b30e36762 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/GroupExpressionStageDefinitions.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/GroupExpressionStageDefinitions.cs @@ -123,8 +123,7 @@ public PseudoQueryProvider(IBsonSerializer inputSerializer) } public CollectionNamespace CollectionNamespace => throw new NotImplementedException(); - - public IBsonSerializer CollectionDocumentSerializer => _inputSerializer; + public IBsonSerializer PipelineInputSerializer => _inputSerializer; public IQueryable CreateQuery(Expression expression) => throw new NotImplementedException(); public IQueryable CreateQuery(Expression expression) => throw new NotImplementedException(); diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/LinqProviderAdapterV3.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/LinqProviderAdapterV3.cs index b731b761926..72746d808fd 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/LinqProviderAdapterV3.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/LinqProviderAdapterV3.cs @@ -14,7 +14,6 @@ */ using System; -using System.Collections.ObjectModel; using System.Linq; using System.Linq.Expressions; using MongoDB.Bson; diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/MongoQueryProvider.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/MongoQueryProvider.cs index 5099e1edbbd..b90003aa6bf 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/MongoQueryProvider.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/MongoQueryProvider.cs @@ -20,6 +20,7 @@ using System.Threading.Tasks; using MongoDB.Bson; using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToExecutableQueryTranslators; using MongoDB.Driver.Support; @@ -41,9 +42,9 @@ internal abstract class MongoQueryProvider : IMongoQueryProvider } // public properties - public abstract IBsonSerializer CollectionDocumentSerializer { get; } public abstract CollectionNamespace CollectionNamespace { get; } public AggregateOptions Options => _options; + public abstract IBsonSerializer PipelineInputSerializer { get; } public IClientSessionHandle Session => _session; // public methods @@ -70,7 +71,7 @@ internal sealed class MongoQueryProvider : MongoQueryProvider AggregateOptions options) : base(session, options) { - _collection = collection; + _collection = Ensure.IsNotNull(collection, nameof(collection)); } public MongoQueryProvider( @@ -79,14 +80,14 @@ internal sealed class MongoQueryProvider : MongoQueryProvider AggregateOptions options) : base(session, options) { - _database = database; + _database = Ensure.IsNotNull(database, nameof(database)); } // public properties public IMongoCollection Collection => _collection; - public override CollectionNamespace CollectionNamespace => _collection.CollectionNamespace; - public override IBsonSerializer CollectionDocumentSerializer => _collection.DocumentSerializer; + public override CollectionNamespace CollectionNamespace => _collection == null ? null : _collection.CollectionNamespace; public IMongoDatabase Database => _database; + public override IBsonSerializer PipelineInputSerializer => _collection == null ? NoPipelineInputSerializer.Instance : _collection.DocumentSerializer; // public methods public override IQueryable CreateQuery(Expression expression) diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Reflection/MongoQueryableMethod.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Reflection/MongoQueryableMethod.cs index d093f35ffd2..8e794508fe4 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Reflection/MongoQueryableMethod.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Reflection/MongoQueryableMethod.cs @@ -14,6 +14,7 @@ */ using System; +using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; using System.Threading; @@ -50,6 +51,8 @@ internal static class MongoQueryableMethod private static readonly MethodInfo __countAsync; private static readonly MethodInfo __countWithPredicateAsync; private static readonly MethodInfo __densifyWithArrayPartitionByFields; + private static readonly MethodInfo __documents; + private static readonly MethodInfo __documentsWithSerializer; private static readonly MethodInfo __firstAsync; private static readonly MethodInfo __firstOrDefaultAsync; private static readonly MethodInfo __firstOrDefaultWithPredicateAsync; @@ -195,6 +198,8 @@ static MongoQueryableMethod() __countAsync = ReflectionInfo.Method((IMongoQueryable source, CancellationToken cancellationToken) => source.CountAsync(cancellationToken)); __countWithPredicateAsync = ReflectionInfo.Method((IMongoQueryable source, Expression> predicate, CancellationToken cancellationToken) => source.CountAsync(predicate, cancellationToken)); __densifyWithArrayPartitionByFields = ReflectionInfo.Method((IMongoQueryable source, Expression> field, DensifyRange range, Expression>[] partitionByFields) => source.Densify(field, range, partitionByFields)); + __documents = ReflectionInfo.Method((IMongoQueryable source, object[] documents) => source.Documents(documents)); + __documentsWithSerializer = ReflectionInfo.Method((IMongoQueryable source, IEnumerable documents, IBsonSerializer serializer) => source.Documents(documents, serializer)); __firstAsync = ReflectionInfo.Method((IMongoQueryable source, CancellationToken cancellationToken) => source.FirstAsync(cancellationToken)); __firstOrDefaultAsync = ReflectionInfo.Method((IMongoQueryable source, CancellationToken cancellationToken) => source.FirstOrDefaultAsync(cancellationToken)); __firstOrDefaultWithPredicateAsync = ReflectionInfo.Method((IMongoQueryable source, Expression> predicate, CancellationToken cancellationToken) => source.FirstOrDefaultAsync(predicate, cancellationToken)); @@ -339,6 +344,8 @@ static MongoQueryableMethod() public static MethodInfo CountAsync => __countAsync; public static MethodInfo CountWithPredicateAsync => __countWithPredicateAsync; public static MethodInfo DensifyWithArrayPartitionByFields => __densifyWithArrayPartitionByFields; + public static MethodInfo Documents => __documents; + public static MethodInfo DocumentsWithSerializer => __documentsWithSerializer; public static MethodInfo FirstAsync => __firstAsync; public static MethodInfo FirstOrDefaultAsync => __firstOrDefaultAsync; public static MethodInfo FirstOrDefaultWithPredicateAsync => __firstOrDefaultWithPredicateAsync; diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExecutableQuery.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExecutableQuery.cs index 94857acd01f..31e078ab672 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExecutableQuery.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExecutableQuery.cs @@ -18,6 +18,7 @@ using System.Threading.Tasks; using MongoDB.Bson; using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Linq.Linq3Implementation.Ast; using MongoDB.Driver.Linq.Linq3Implementation.Ast.Optimizers; @@ -76,7 +77,7 @@ internal class ExecutableQuery : ExecutableQuery finalizer) : this(options, unoptimizedPipeline, pipeline, finalizer) { - _collection = collection; + _collection = Ensure.IsNotNull(collection, nameof(collection)); } public ExecutableQuery( @@ -87,7 +88,7 @@ internal class ExecutableQuery : ExecutableQuery finalizer) : this(options, unoptimizedPipeline, pipeline, finalizer) { - _database = database; + _database = Ensure.IsNotNull(database, nameof(database)); } private ExecutableQuery( @@ -135,6 +136,7 @@ public override async Task ExecuteAsync(IClientSessionHandle session, C public override string ToString() { + var x = (object)_database?.DatabaseNamespace ?? _collection.CollectionNamespace; return $"{(_collection == null ? _database.DatabaseNamespace : _collection.CollectionNamespace)}.Aggregate({_pipeline})"; } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExpressionToExecutableQueryTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExpressionToExecutableQueryTranslator.cs index 7ed4b5524b6..f42bc3b4e75 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExpressionToExecutableQueryTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToExecutableQueryTranslators/ExpressionToExecutableQueryTranslator.cs @@ -16,9 +16,7 @@ using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; -using MongoDB.Bson.Serialization; using MongoDB.Driver.Linq.Linq3Implementation.Misc; -using MongoDB.Driver.Linq.Linq3Implementation.Serializers.KnownSerializers; using MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToPipelineTranslators; namespace MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToExecutableQueryTranslators @@ -30,7 +28,7 @@ internal static class ExpressionToExecutableQueryTranslator { expression = PartialEvaluator.EvaluatePartially(expression); - var context = TranslationContext.Create(expression, provider.CollectionDocumentSerializer); + var context = TranslationContext.Create(expression, provider.PipelineInputSerializer); var pipeline = ExpressionToPipelineTranslator.Translate(context, expression); return ExecutableQuery.Create( @@ -43,7 +41,7 @@ internal static class ExpressionToExecutableQueryTranslator { expression = PartialEvaluator.EvaluatePartially(expression); - var context = TranslationContext.Create(expression, provider.CollectionDocumentSerializer); + var context = TranslationContext.Create(expression, provider.PipelineInputSerializer); var methodCallExpression = (MethodCallExpression)expression; switch (methodCallExpression.Method.Name) { diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/DocumentsMethodToPipelineTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/DocumentsMethodToPipelineTranslator.cs new file mode 100644 index 00000000000..03506a5d613 --- /dev/null +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/DocumentsMethodToPipelineTranslator.cs @@ -0,0 +1,65 @@ +/* Copyright 2010-present MongoDB Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +using System.Collections; +using System.Linq.Expressions; +using MongoDB.Bson.Serialization; +using MongoDB.Driver.Linq.Linq3Implementation.Ast; +using MongoDB.Driver.Linq.Linq3Implementation.Ast.Stages; +using MongoDB.Driver.Linq.Linq3Implementation.ExtensionMethods; +using MongoDB.Driver.Linq.Linq3Implementation.Misc; +using MongoDB.Driver.Linq.Linq3Implementation.Reflection; + +namespace MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToPipelineTranslators +{ + internal static class DocumentsMethodToPipelineTranslator + { + // public static methods + public static AstPipeline Translate(TranslationContext context, MethodCallExpression expression) + { + var method = expression.Method; + var arguments = expression.Arguments; + + if (method.IsOneOf(MongoQueryableMethod.Documents, MongoQueryableMethod.DocumentsWithSerializer)) + { + var sourceExpression = ConvertHelper.RemoveConvertToMongoQueryable(arguments[0]); + var pipeline = ExpressionToPipelineTranslator.Translate(context, sourceExpression); + + var documentsExpression = arguments[1]; + var documents = documentsExpression.GetConstantValue(expression); + + IBsonSerializer documentSerializer; + if (method.Is(MongoQueryableMethod.DocumentsWithSerializer)) + { + var documentSerializerExpression = arguments[2]; + documentSerializer = documentSerializerExpression.GetConstantValue(expression); + } + else + { + var documentType = method.GetGenericArguments()[0]; + documentSerializer = BsonSerializer.LookupSerializer(documentType); + } + + var serializedDocuments = SerializationHelper.SerializeValues(documentSerializer, documents); + var documentsStage = AstStage.Documents(serializedDocuments); + pipeline = pipeline.AddStages(documentSerializer, documentsStage); + + return pipeline; + } + + throw new ExpressionNotSupportedException(expression); + } + } +} diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/ExpressionToPipelineTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/ExpressionToPipelineTranslator.cs index 8ec544f2da5..2857fc37c81 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/ExpressionToPipelineTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/ExpressionToPipelineTranslator.cs @@ -28,7 +28,7 @@ public static AstPipeline Translate(TranslationContext context, Expression expre { var query = (IQueryable)((ConstantExpression)expression).Value; var provider = (IMongoQueryProvider)query.Provider; - return AstPipeline.Empty(provider.CollectionDocumentSerializer); + return AstPipeline.Empty(provider.PipelineInputSerializer); } var methodCallExpression = (MethodCallExpression)expression; @@ -40,6 +40,8 @@ public static AstPipeline Translate(TranslationContext context, Expression expre return DensifyMethodToPipelineTranslator.Translate(context, methodCallExpression); case "Distinct": return DistinctMethodToPipelineTranslator.Translate(context, methodCallExpression); + case "Documents": + return DocumentsMethodToPipelineTranslator.Translate(context, methodCallExpression); case "GroupBy": return GroupByMethodToPipelineTranslator.Translate(context, methodCallExpression); case "GroupJoin": diff --git a/src/MongoDB.Driver/Linq/MongoQueryable.cs b/src/MongoDB.Driver/Linq/MongoQueryable.cs index 2399079f95f..c67658673e3 100644 --- a/src/MongoDB.Driver/Linq/MongoQueryable.cs +++ b/src/MongoDB.Driver/Linq/MongoQueryable.cs @@ -627,6 +627,53 @@ public static IMongoQueryable Distinct(this IMongoQueryable)Queryable.Distinct(source); } + /// + /// Injects a sequence of documents at the beginning of a pipeline. + /// + /// The type of the documents. + /// An IMongoQueryable with no other input. + /// The documents. + /// + /// An whose elements are the documents. + /// + public static IMongoQueryable Documents(this IMongoQueryable source, params TDocument[] documents) + { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(documents, nameof(documents)); + + return (IMongoQueryable)source.Provider.CreateQuery( + Expression.Call( + null, + GetMethodInfo(Documents, source, documents), + Expression.Convert(source.Expression, typeof(IMongoQueryable)), + Expression.Constant(documents, typeof(TDocument[])))); + } + + /// + /// Injects a sequence of documents at the beginning of a pipeline. + /// + /// The type of the documents. + /// An IMongoQueryable with no other input. + /// The documents. + /// The document serializer. + /// + /// An whose elements are the documents. + /// + public static IMongoQueryable Documents(this IMongoQueryable source, IEnumerable documents, IBsonSerializer documentSerializer) + { + Ensure.IsNotNull(source, nameof(source)); + Ensure.IsNotNull(documents, nameof(documents)); + Ensure.IsNotNull(documentSerializer, nameof(documentSerializer)); + + return (IMongoQueryable)source.Provider.CreateQuery( + Expression.Call( + null, + GetMethodInfo(Documents, source, documents, documentSerializer), + Expression.Convert(source.Expression, typeof(IMongoQueryable)), + Expression.Constant(documents, typeof(IEnumerable)), + Expression.Constant(documentSerializer, typeof(IBsonSerializer)))); + } + /// /// Returns the first element of a sequence. /// diff --git a/src/MongoDB.Driver/NoPipelineInput.cs b/src/MongoDB.Driver/NoPipelineInput.cs index 787fe340cbf..2285d989a91 100644 --- a/src/MongoDB.Driver/NoPipelineInput.cs +++ b/src/MongoDB.Driver/NoPipelineInput.cs @@ -31,7 +31,7 @@ private NoPipelineInput() /// /// The serializer for NoPipelineInput. /// - internal sealed class NoPipelineInputSerializer : IBsonSerializer + internal sealed class NoPipelineInputSerializer : IBsonSerializer, IBsonDocumentSerializer { #region static // private static fields @@ -70,5 +70,12 @@ public void Serialize(BsonSerializationContext context, BsonSerializationArgs ar { throw new NotSupportedException(); } + + /// + public bool TryGetMemberSerializationInfo(string memberName, out BsonSerializationInfo serializationInfo) + { + serializationInfo = null; + return false; + } } } diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4339Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4339Tests.cs new file mode 100644 index 00000000000..1d9bf9e7617 --- /dev/null +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4339Tests.cs @@ -0,0 +1,166 @@ +/* Copyright 2010-present MongoDB Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +using System; +using System.Linq; +using FluentAssertions; +using MongoDB.Bson.IO; +using MongoDB.Bson.Serialization; +using MongoDB.Bson.Serialization.Serializers; +using MongoDB.Driver.Core.Misc; +using MongoDB.Driver.Core.TestHelpers.XunitExtensions; +using MongoDB.Driver.Linq; +using Xunit; + +namespace MongoDB.Driver.Tests.Linq.Linq3ImplementationTests.Jira +{ + public class CSharp4339Tests : Linq3IntegrationTest + { + [Fact] + public void Documents_should_work() + { + RequireServer.Check().Supports(Feature.DocumentsStage); + var database = GetDatabase(); + var documents = new[] { new C { X = 1 }, new C { X = 2 }, new C { X = 3 } }; + + var queryable = database + .AsQueryable() + .Documents(documents); + + var stages = Translate(database, queryable); + AssertStages( + stages, + "{ $documents : [{ X : 1 }, { X : 2 }, { X : 3 }] }"); + + var results = queryable.ToList(); + results.Select(x => x.X).Should().Equal(1, 2, 3); + } + + [Fact] + public void Documents_should_throw_when_source_is_null() + { + var source = (IMongoQueryable)null; + var documents = new C[0]; + + var exception = Record.Exception(() => source.Documents(documents)); + + var argumentNullException = exception.Should().BeOfType().Subject; + argumentNullException.ParamName.Should().Be("source"); + } + + [Fact] + public void Documents_should_throw_when_documents_is_null() + { + var database = GetDatabase(); + var source = database.AsQueryable(); + var documents = (C[])null; + + var exception = Record.Exception(() => source.Documents(documents)); + + var argumentNullException = exception.Should().BeOfType().Subject; + argumentNullException.ParamName.Should().Be("documents"); + } + + [Fact] + public void Documents_with_documentSerializer_should_work() + { + RequireServer.Check().Supports(Feature.DocumentsStage); + var database = GetDatabase(); + var documents = new[] { new C { X = 1 }, new C { X = 2 }, new C { X = 3 } }; + var documentSerializer = new CSerializer(); + + var queryable = database + .AsQueryable() + .Documents(documents, documentSerializer); + + var stages = Translate(database, queryable); + AssertStages( + stages, + "{ $documents : [{ X : '1' }, { X : '2' }, { X : '3' }] }"); + + var results = queryable.ToList(); + results.Select(x => x.X).Should().Equal(1, 2, 3); + } + + [Fact] + public void Documents_with_documentSerializer_should_throw_when_source_is_null() + { + var source = (IMongoQueryable)null; + var documents = new C[0]; + var documentSerializer = BsonSerializer.LookupSerializer(); + + var exception = Record.Exception(() => source.Documents(documents, documentSerializer)); + + var argumentNullException = exception.Should().BeOfType().Subject; + argumentNullException.ParamName.Should().Be("source"); + } + + [Fact] + public void Documents_with_documentSerializer_should_throw_when_documents_is_null() + { + var database = GetDatabase(); + var source = database.AsQueryable(); + var documents = (C[])null; + var documentSerializer = BsonSerializer.LookupSerializer(); + + var exception = Record.Exception(() => source.Documents(documents, documentSerializer)); + + var argumentNullException = exception.Should().BeOfType().Subject; + argumentNullException.ParamName.Should().Be("documents"); + } + + [Fact] + public void Documents_with_documentSerializer_should_throw_when_documentSerializer_is_null() + { + var database = GetDatabase(); + var source = database.AsQueryable(); + var documents = new C[0]; + var documentSerializer = (IBsonSerializer)null; + + var exception = Record.Exception(() => source.Documents(documents, documentSerializer)); + + var argumentNullException = exception.Should().BeOfType().Subject; + argumentNullException.ParamName.Should().Be("documentSerializer"); + } + + public class C + { + public int X { get; set; } + } + + public class CSerializer : ClassSerializerBase + { + public override C Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) + { + var reader = context.Reader; + reader.ReadStartDocument(); + reader.ReadName("X"); + var x = int.Parse(reader.ReadString()); + reader.ReadEndDocument(); + + return new C { X = x }; + } + + public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, C value) + { + var writer = context.Writer; + writer.WriteStartDocument(); + writer.WriteName("X"); + writer.WriteString(value.X.ToString()); + writer.WriteEndDocument(); + } + } + } +} diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Linq3IntegrationTest.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Linq3IntegrationTest.cs index 707e6b5447e..354a627949e 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Linq3IntegrationTest.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Linq3IntegrationTest.cs @@ -112,6 +112,12 @@ protected static List Translate(IMongoDatabase database, return Translate(pipelineDefinition, NoPipelineInputSerializer.Instance, linqProvider); } + // in this overload the database argument is used only to infer the NoPipelineInput type + protected List Translate(IMongoDatabase database, IQueryable queryable) + { + return Translate(queryable); + } + protected List Translate(IQueryable queryable) { return Translate(queryable, out _); From 5ce4903e0b16362ff1cd6c019222c3ae32881223 Mon Sep 17 00:00:00 2001 From: rstam Date: Sat, 10 Dec 2022 12:46:40 -0800 Subject: [PATCH 14/21] CSHARP-4358: Update tests that only test against LINQ2 to test against LINQ3 instead of or in addition to LINQ2. --- .../DriverTestConfiguration.cs | 5 + .../AggregateFluentBucketTests.cs | 6 +- ...nBuilderEnumComparedToNullableEnumTests.cs | 12 +-- ...llableEnumWithStringRepresentationTests.cs | 12 +-- .../IAggregateFluentExtensionsTests.cs | 30 ++++-- .../MongoQueryableTests.cs | 2 +- .../LegacyPredicateTranslatorTests.cs | 2 +- .../Jira/CSharp3933Tests.cs | 2 +- .../Linq3IntegrationTest.cs | 12 +-- .../ProjectionDefinitionBuilderTests.cs | 20 ++-- .../Samples/AggregationSample.cs | 92 ++++++++++++++----- .../UpdateDefinitionBuilderTests.cs | 57 +++++------- 12 files changed, 155 insertions(+), 97 deletions(-) diff --git a/tests/MongoDB.Driver.TestHelpers/DriverTestConfiguration.cs b/tests/MongoDB.Driver.TestHelpers/DriverTestConfiguration.cs index 809d68455f9..ca180abd692 100644 --- a/tests/MongoDB.Driver.TestHelpers/DriverTestConfiguration.cs +++ b/tests/MongoDB.Driver.TestHelpers/DriverTestConfiguration.cs @@ -225,6 +225,11 @@ public static MongoClientSettings GetClientSettings() return clientSettings; } + public static MongoClient GetLinqClient(LinqProvider linqProvider) + { + return linqProvider == LinqProvider.V2 ? Linq2Client : Linq3Client; + } + public static bool IsReplicaSet(IMongoClient client) { var clusterTypeIsKnown = SpinWait.SpinUntil(() => client.Cluster.Description.Type != ClusterType.Unknown, TimeSpan.FromSeconds(10)); diff --git a/tests/MongoDB.Driver.Tests/AggregateFluentBucketTests.cs b/tests/MongoDB.Driver.Tests/AggregateFluentBucketTests.cs index f1c0c27205a..25b1ac8fa7e 100644 --- a/tests/MongoDB.Driver.Tests/AggregateFluentBucketTests.cs +++ b/tests/MongoDB.Driver.Tests/AggregateFluentBucketTests.cs @@ -40,7 +40,7 @@ public class AggregateFluentBucketTests static AggregateFluentBucketTests() { var databaseNamespace = DriverTestConfiguration.DatabaseNamespace; - __database = DriverTestConfiguration.Linq2Client.GetDatabase(databaseNamespace.DatabaseName); + __database = DriverTestConfiguration.Client.GetDatabase(databaseNamespace.DatabaseName); __collectionNamespace = DriverTestConfiguration.CollectionNamespace; __ensureTestData = new Lazy(CreateTestData); } @@ -156,7 +156,7 @@ public void Bucket_typed_should_add_expected_stage() var stage = result.Stages.Single(); var serializerRegistry = BsonSerializer.SerializerRegistry; var exhibitSerializer = serializerRegistry.GetSerializer(); - var renderedStage = stage.Render(exhibitSerializer, serializerRegistry, LinqProvider.V2); + var renderedStage = stage.Render(exhibitSerializer, serializerRegistry); renderedStage.Document.Should().Be("{ $bucket : { groupBy : \"$year\", boundaries : [ 1900, 1920, 1950 ], default : \"Unknown\" } }"); } @@ -196,7 +196,7 @@ public void Bucket_typed_with_output_should_add_expected_stage() var stage = result.Stages.Single(); var serializerRegistry = BsonSerializer.SerializerRegistry; var exhibitSerializer = serializerRegistry.GetSerializer(); - var renderedStage = stage.Render(exhibitSerializer, serializerRegistry, LinqProvider.V2); + var renderedStage = stage.Render(exhibitSerializer, serializerRegistry); renderedStage.Document.Should().Be("{ $bucket : { groupBy : \"$year\", boundaries : [ 1900, 1920, 1950 ], default : \"Unknown\", output : { Years : { $push : \"$year\" }, Count : { $sum : 1 } } } }"); } diff --git a/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderEnumComparedToNullableEnumTests.cs b/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderEnumComparedToNullableEnumTests.cs index badb429efe6..4855b953238 100644 --- a/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderEnumComparedToNullableEnumTests.cs +++ b/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderEnumComparedToNullableEnumTests.cs @@ -160,7 +160,7 @@ public void Where_operator_equals_should_render_correctly(E? value, string expec { var filter = __subject.Where(x => x.E == value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } [Theory] @@ -170,7 +170,7 @@ public void Where_operator_greater_than_should_render_correctly(E? value, string { var filter = __subject.Where(x => x.E > value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } [Theory] @@ -180,7 +180,7 @@ public void Where_operator_greater_than_or_equal_should_render_correctly(E? valu { var filter = __subject.Where(x => x.E >= value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } [Theory] @@ -190,7 +190,7 @@ public void Where_operator_less_than_should_render_correctly(E? value, string ex { var filter = __subject.Where(x => x.E < value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } [Theory] @@ -200,7 +200,7 @@ public void Where_operator_less_than_or_equal_should_render_correctly(E? value, { var filter = __subject.Where(x => x.E <= value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } [Theory] @@ -210,7 +210,7 @@ public void Where_operator_not_equal_should_render_correctly(E? value, string ex { var filter = __subject.Where(x => x.E != value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } } } diff --git a/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderEnumComparedToNullableEnumWithStringRepresentationTests.cs b/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderEnumComparedToNullableEnumWithStringRepresentationTests.cs index 7d7f5dc04bd..ebafb08a130 100644 --- a/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderEnumComparedToNullableEnumWithStringRepresentationTests.cs +++ b/tests/MongoDB.Driver.Tests/FilterDefinitionBuilderEnumComparedToNullableEnumWithStringRepresentationTests.cs @@ -163,7 +163,7 @@ public void Where_operator_equals_should_render_correctly(E? value, string expec { var filter = __subject.Where(x => x.E == value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } [Theory] @@ -173,7 +173,7 @@ public void Where_operator_greater_than_should_render_correctly(E? value, string { var filter = __subject.Where(x => x.E > value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } [Theory] @@ -183,7 +183,7 @@ public void Where_operator_greater_than_or_equal_should_render_correctly(E? valu { var filter = __subject.Where(x => x.E >= value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } [Theory] @@ -193,7 +193,7 @@ public void Where_operator_less_than_should_render_correctly(E? value, string ex { var filter = __subject.Where(x => x.E < value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } [Theory] @@ -203,7 +203,7 @@ public void Where_operator_less_than_or_equal_should_render_correctly(E? value, { var filter = __subject.Where(x => x.E <= value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } [Theory] @@ -213,7 +213,7 @@ public void Where_operator_not_equal_should_render_correctly(E? value, string ex { var filter = __subject.Where(x => x.E != value); - filter.Render(__serializer, __registry, LinqProvider.V2).Should().Be(expectedFilter); + filter.Render(__serializer, __registry).Should().Be(expectedFilter); } } } diff --git a/tests/MongoDB.Driver.Tests/IAggregateFluentExtensionsTests.cs b/tests/MongoDB.Driver.Tests/IAggregateFluentExtensionsTests.cs index 17377ed835c..55d01b4b666 100644 --- a/tests/MongoDB.Driver.Tests/IAggregateFluentExtensionsTests.cs +++ b/tests/MongoDB.Driver.Tests/IAggregateFluentExtensionsTests.cs @@ -20,6 +20,7 @@ using MongoDB.TestHelpers.XunitExtensions; using MongoDB.Driver.Core.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; +using MongoDB.Driver.Tests.Linq.Linq3ImplementationTests; using Moq; using System; using System.Collections.Generic; @@ -30,7 +31,7 @@ namespace MongoDB.Driver.Tests { - public class IAggregateFluentExtensionsTests + public class IAggregateFluentExtensionsTests : Linq3IntegrationTest { // public methods #if WINDOWS @@ -166,15 +167,29 @@ public void Group_should_generate_the_correct_group_when_a_result_type_is_not_sp AssertLast(subject, expectedGroup); } - [Fact] - public void Group_should_generate_the_correct_document_using_expressions() + [Theory] + [ParameterAttributeData] + public void Group_should_generate_the_correct_document_using_expressions( + [Values(LinqProvider.V2, LinqProvider.V3)] LinqProvider linqProvider) { - var subject = CreateSubject() + var collection = GetCollection(linqProvider: linqProvider); + var subject = collection.Aggregate() .Group(x => x.Age, g => new { Name = g.Select(x => x.FirstName + " " + x.LastName).First() }); - var expectedGroup = BsonDocument.Parse("{$group: {_id: '$Age', Name: {'$first': { '$concat': ['$FirstName', ' ', '$LastName']}}}}"); + var stages = Translate(collection, subject); + var expectedStages = linqProvider == LinqProvider.V2 ? + new[] + { + "{ $group : { _id : '$Age', Name : { $first : { $concat : ['$FirstName', ' ', '$LastName'] } } } }" + } + : + new[] + { + "{ $group : { _id : '$Age', __agg0 : { $first : { $concat : ['$FirstName', ' ', '$LastName'] } } } }", + "{ $project : { Name : '$__agg0', _id : 0 } }" + }; - AssertLast(subject, expectedGroup); + AssertStages(stages, expectedStages); } [Fact] @@ -622,7 +637,7 @@ public void Unwind_with_options_with_includeArrayIndex_set_and_preserveNullAndEm private void AssertLast(IAggregateFluent fluent, BsonDocument expectedLast) { var pipeline = new PipelineStagePipelineDefinition(fluent.Stages); - var renderedPipeline = pipeline.Render(BsonSerializer.SerializerRegistry.GetSerializer(), BsonSerializer.SerializerRegistry, LinqProvider.V2); + var renderedPipeline = pipeline.Render(BsonSerializer.SerializerRegistry.GetSerializer(), BsonSerializer.SerializerRegistry); var last = renderedPipeline.Documents.Last(); Assert.Equal(expectedLast, last); @@ -638,7 +653,6 @@ private IMongoClient CreateClient() { var mockClient = new Mock(); var settings = new MongoClientSettings(); - settings.LinqProvider = LinqProvider.V2; mockClient.SetupGet(x => x.Settings).Returns(settings); return mockClient.Object; } diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/MongoQueryableTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/MongoQueryableTests.cs index a8ca9fecff6..a40cc7cc3ac 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/MongoQueryableTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/MongoQueryableTests.cs @@ -1827,7 +1827,7 @@ public void AsQueryable_in_transaction() RequireServer.Check().Supports(Feature.ShardedTransactions); } - using (var session = DriverTestConfiguration.Client.StartSession()) + using (var session = DriverTestConfiguration.Linq3Client.StartSession()) { session.StartTransaction(); try diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/LegacyPredicateTranslatorTests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/LegacyPredicateTranslatorTests.cs index 0300c0239ff..b38475a8610 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/LegacyPredicateTranslatorTests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq2ImplementationTestsOnLinq3/Translators/LegacyPredicateTranslatorTests.cs @@ -53,7 +53,7 @@ public LegacyPredicateTranslatorTests() public bool OneTimeSetup() { - __database = DriverTestConfiguration.Client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName); + __database = DriverTestConfiguration.Linq3Client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName); __collection = __database.GetCollection(DriverTestConfiguration.CollectionNamespace.CollectionName); // documents inserted deliberately out of order to test sorting diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3933Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3933Tests.cs index 422fc3f4f3b..81813cc458b 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3933Tests.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp3933Tests.cs @@ -258,7 +258,7 @@ public void PipelineStageDefinitionBuilderGroupForLinq3_with_expressions_should_ private IMongoCollection GetCollection(LinqProvider linqProvider) { - var client = linqProvider == LinqProvider.V2 ? DriverTestConfiguration.Linq2Client : DriverTestConfiguration.Linq3Client; + var client = DriverTestConfiguration.GetLinqClient(linqProvider); var database = client.GetDatabase("test"); return database.GetCollection("test"); } diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Linq3IntegrationTest.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Linq3IntegrationTest.cs index 354a627949e..b60dd8e0aec 100644 --- a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Linq3IntegrationTest.cs +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Linq3IntegrationTest.cs @@ -58,16 +58,6 @@ protected void CreateCollection(IMongoCollection collectio CreateCollection(collection, (IEnumerable)documents); ; } - protected IMongoClient GetClient(LinqProvider linqProvider = LinqProvider.V3) - { - return linqProvider switch - { - LinqProvider.V2 => DriverTestConfiguration.Linq2Client, - LinqProvider.V3 => DriverTestConfiguration.Linq3Client, - _ => throw new ArgumentException($"Invalid linqProvider: {linqProvider}.", nameof(linqProvider)) - }; - } - protected IMongoCollection GetCollection(string collectionName = null, LinqProvider linqProvider = LinqProvider.V3) { return GetCollection(databaseName: null, collectionName, linqProvider); @@ -81,7 +71,7 @@ protected IMongoCollection GetCollection(string databaseNa protected IMongoDatabase GetDatabase(string databaseName = null, LinqProvider linqProvider = LinqProvider.V3) { - var client = GetClient(linqProvider); + var client = DriverTestConfiguration.GetLinqClient(linqProvider); return client.GetDatabase(databaseName ?? DriverTestConfiguration.DatabaseNamespace.DatabaseName); } diff --git a/tests/MongoDB.Driver.Tests/ProjectionDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/ProjectionDefinitionBuilderTests.cs index 530d6f6c633..2bdbe788b36 100644 --- a/tests/MongoDB.Driver.Tests/ProjectionDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/ProjectionDefinitionBuilderTests.cs @@ -18,6 +18,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using Xunit; @@ -86,13 +87,20 @@ public void ElemMatch_from_filter() Assert(subject.Include("a.$"), "{'a.$': 1}"); } - [Fact] - public void ElemMatch_from_filter_Typed() + [Theory] + [ParameterAttributeData] + public void ElemMatch_from_filter_Typed( + [Values(LinqProvider.V2, LinqProvider.V3)] LinqProvider linqProvider) { var subject = CreateSubject(); - Assert(subject.Include(x => x.Pets.ElementAt(-1)), "{'pets.$': 1}"); - Assert(subject.Include("Pets.$"), "{'pets.$': 1}"); + var projection = linqProvider == LinqProvider.V2 ? + subject.Include(x => x.Pets.ElementAt(-1)) : + subject.Include(x => x.Pets.FirstMatchingElement()); + Assert(projection, "{ 'pets.$' : 1 }", linqProvider); + + projection = subject.Include("Pets.$"); + Assert(projection, "{ 'pets.$' : 1 }", linqProvider); } [Fact] @@ -188,10 +196,10 @@ public void Slice_Typed_with_limit() Assert(subject.Slice("Pets", 10, 20), "{pets: {$slice: [10, 20]}}"); } - private void Assert(ProjectionDefinition projection, string expectedJson) + private void Assert(ProjectionDefinition projection, string expectedJson, LinqProvider linqProvider = LinqProvider.V3) { var documentSerializer = BsonSerializer.SerializerRegistry.GetSerializer(); - var renderedProjection = projection.Render(documentSerializer, BsonSerializer.SerializerRegistry, LinqProvider.V2); + var renderedProjection = projection.Render(documentSerializer, BsonSerializer.SerializerRegistry, linqProvider); renderedProjection.Should().Be(expectedJson); } diff --git a/tests/MongoDB.Driver.Tests/Samples/AggregationSample.cs b/tests/MongoDB.Driver.Tests/Samples/AggregationSample.cs index 09953406655..223282d6526 100644 --- a/tests/MongoDB.Driver.Tests/Samples/AggregationSample.cs +++ b/tests/MongoDB.Driver.Tests/Samples/AggregationSample.cs @@ -17,6 +17,7 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using MongoDB.Driver.Tests.Linq.Linq3ImplementationTests; using Xunit; @@ -39,7 +40,7 @@ public AggregationSample() public bool OneTimeSetup() { - var client = DriverTestConfiguration.Linq2Client; + var client = DriverTestConfiguration.Client; var db = client.GetDatabase(DriverTestConfiguration.DatabaseNamespace.DatabaseName); db.DropCollection(DriverTestConfiguration.CollectionNamespace.CollectionName); __collection = db.GetCollection(DriverTestConfiguration.CollectionNamespace.CollectionName); @@ -60,26 +61,40 @@ public bool OneTimeSetup() return true; } - [Fact] - public async Task States_with_pops_over_20000() + [Theory] + [ParameterAttributeData] + public async Task States_with_pops_over_20000( + [Values(LinqProvider.V2, LinqProvider.V3)] LinqProvider linqProvider) { - var pipeline = __collection.Aggregate() + var collection = GetCollection(linqProvider); + var pipeline = collection.Aggregate() .Group(x => x.State, g => new { State = g.Key, TotalPopulation = g.Sum(x => x.Population) }) .Match(x => x.TotalPopulation > 20000); - pipeline.ToString().Should().Be("aggregate([" + - "{ \"$group\" : { \"_id\" : \"$state\", \"TotalPopulation\" : { \"$sum\" : \"$pop\" } } }, " + - "{ \"$match\" : { \"TotalPopulation\" : { \"$gt\" : 20000 } } }])"); + var pipelineTranslation = pipeline.ToString(); + var expectedTranslation = linqProvider == LinqProvider.V2 ? + "aggregate([" + + "{ \"$group\" : { \"_id\" : \"$state\", \"TotalPopulation\" : { \"$sum\" : \"$pop\" } } }, " + + "{ \"$match\" : { \"TotalPopulation\" : { \"$gt\" : 20000 } } }])" + : + "aggregate([" + + "{ \"$group\" : { \"_id\" : \"$state\", \"__agg0\" : { \"$sum\" : \"$pop\" } } }, " + + "{ \"$project\" : { \"State\" : \"$_id\", \"TotalPopulation\" : \"$__agg0\", \"_id\" : 0 } }, " + + "{ \"$match\" : { \"TotalPopulation\" : { \"$gt\" : 20000 } } }])"; + pipelineTranslation.Should().Be(expectedTranslation); var result = await pipeline.ToListAsync(); result.Count.Should().Be(1); } - [Fact] - public async Task States_with_pops_over_20000_queryable_method() + [Theory] + [ParameterAttributeData] + public async Task States_with_pops_over_20000_queryable_method( + [Values(LinqProvider.V2, LinqProvider.V3)] LinqProvider linqProvider) { - var pipeline = __collection.AsQueryable() + var collection = GetCollection(linqProvider); + var pipeline = collection.AsQueryable() .GroupBy(x => x.State, (k, s) => new { State = k, TotalPopulation = s.Sum(x => x.Population) }) .Where(x => x.TotalPopulation > 20000); @@ -94,7 +109,7 @@ public async Task States_with_pops_over_20000_queryable_method() [InlineData(LinqProvider.V3)] public void States_with_pops_over_20000_queryable_syntax(LinqProvider linqProvider) { - var client = linqProvider == LinqProvider.V2 ? DriverTestConfiguration.Linq2Client : DriverTestConfiguration.Linq3Client; + var client = DriverTestConfiguration.GetLinqClient(linqProvider); var database = client.GetDatabase(__collection.CollectionNamespace.DatabaseNamespace.DatabaseName); var collection = database.GetCollection(__collection.CollectionNamespace.CollectionName); @@ -125,18 +140,31 @@ public void States_with_pops_over_20000_queryable_syntax(LinqProvider linqProvid } #endif - [Fact] - public async Task Average_city_population_by_state() + [Theory] + [ParameterAttributeData] + public async Task Average_city_population_by_state( + [Values(LinqProvider.V2, LinqProvider.V3)] LinqProvider linqProvider) { - var pipeline = __collection.Aggregate() + var collection = GetCollection(linqProvider); + var pipeline = collection.Aggregate() .Group(x => new { State = x.State, City = x.City }, g => new { StateAndCity = g.Key, Population = g.Sum(x => x.Population) }) .Group(x => x.StateAndCity.State, g => new { State = g.Key, AverageCityPopulation = g.Average(x => x.Population) }) .SortBy(x => x.State); - pipeline.ToString().Should().Be("aggregate([" + + var pipelineTranslation = pipeline.ToString(); + var expectedTranslation = linqProvider == LinqProvider.V2 ? + "aggregate([" + "{ \"$group\" : { \"_id\" : { \"State\" : \"$state\", \"City\" : \"$city\" }, \"Population\" : { \"$sum\" : \"$pop\" } } }, " + "{ \"$group\" : { \"_id\" : \"$_id.State\", \"AverageCityPopulation\" : { \"$avg\" : \"$Population\" } } }, " + - "{ \"$sort\" : { \"_id\" : 1 } }])"); + "{ \"$sort\" : { \"_id\" : 1 } }])" + : + "aggregate([" + + "{ \"$group\" : { \"_id\" : { \"State\" : \"$state\", \"City\" : \"$city\" }, \"__agg0\" : { \"$sum\" : \"$pop\" } } }, " + + "{ \"$project\" : { \"StateAndCity\" : \"$_id\", \"Population\" : \"$__agg0\", \"_id\" : 0 } }, " + + "{ \"$group\" : { \"_id\" : \"$StateAndCity.State\", \"__agg0\" : { \"$avg\" : \"$Population\" } } }, " + + "{ \"$project\" : { \"State\" : \"$_id\", \"AverageCityPopulation\" : \"$__agg0\", \"_id\" : 0 } }, " + + "{ \"$sort\" : { \"State\" : 1 } }])"; + pipelineTranslation.Should().Be(expectedTranslation); var result = await pipeline.ToListAsync(); @@ -146,10 +174,13 @@ public async Task Average_city_population_by_state() result[1].State.Should().Be("MA"); } - [Fact] - public async Task Largest_and_smallest_cities_by_state() + [Theory] + [ParameterAttributeData] + public async Task Largest_and_smallest_cities_by_state( + [Values(LinqProvider.V2, LinqProvider.V3)] LinqProvider linqProvider) { - var pipeline = __collection.Aggregate() + var collection = GetCollection(linqProvider); + var pipeline = collection.Aggregate() .Group(x => new { State = x.State, City = x.City }, g => new { StateAndCity = g.Key, Population = g.Sum(x => x.Population) }) .SortBy(x => x.Population) .Group(x => x.StateAndCity.State, g => new @@ -168,12 +199,24 @@ public async Task Largest_and_smallest_cities_by_state() }) .SortBy(x => x.State); - pipeline.ToString().Should().Be("aggregate([" + + var pipelineTranslation = pipeline.ToString(); + var expectedTranslation = linqProvider == LinqProvider.V2 ? + "aggregate([" + "{ \"$group\" : { \"_id\" : { \"State\" : \"$state\", \"City\" : \"$city\" }, \"Population\" : { \"$sum\" : \"$pop\" } } }, " + "{ \"$sort\" : { \"Population\" : 1 } }, " + "{ \"$group\" : { \"_id\" : \"$_id.State\", \"BiggestCity\" : { \"$last\" : \"$_id.City\" }, \"BiggestPopulation\" : { \"$last\" : \"$Population\" }, \"SmallestCity\" : { \"$first\" : \"$_id.City\" }, \"SmallestPopulation\" : { \"$first\" : \"$Population\" } } }, " + "{ \"$project\" : { \"State\" : \"$_id\", \"BiggestCity\" : { \"Name\" : \"$BiggestCity\", \"Population\" : \"$BiggestPopulation\" }, \"SmallestCity\" : { \"Name\" : \"$SmallestCity\", \"Population\" : \"$SmallestPopulation\" }, \"_id\" : 0 } }, " + - "{ \"$sort\" : { \"State\" : 1 } }])"); + "{ \"$sort\" : { \"State\" : 1 } }])" + : + "aggregate([" + + "{ \"$group\" : { \"_id\" : { \"State\" : \"$state\", \"City\" : \"$city\" }, \"__agg0\" : { \"$sum\" : \"$pop\" } } }, " + + "{ \"$project\" : { \"StateAndCity\" : \"$_id\", \"Population\" : \"$__agg0\", \"_id\" : 0 } }, " + + "{ \"$sort\" : { \"Population\" : 1 } }, " + + "{ \"$group\" : { \"_id\" : \"$StateAndCity.State\", \"__agg0\" : { \"$last\" : \"$$ROOT\" }, \"__agg1\" : { \"$first\" : \"$$ROOT\" } } }, " + + "{ \"$project\" : { \"State\" : \"$_id\", \"BiggestCity\" : \"$__agg0.StateAndCity.City\", \"BiggestPopulation\" : \"$__agg0.Population\", \"SmallestCity\" : \"$__agg1.StateAndCity.City\", \"SmallestPopulation\" : \"$__agg1.Population\", \"_id\" : 0 } }, " + + "{ \"$project\" : { \"State\" : \"$State\", \"BiggestCity\" : { \"Name\" : \"$BiggestCity\", \"Population\" : \"$BiggestPopulation\" }, \"SmallestCity\" : { \"Name\" : \"$SmallestCity\", \"Population\" : \"$SmallestPopulation\" }, \"_id\" : 0 } }, " + + "{ \"$sort\" : { \"State\" : 1 } }])"; + pipelineTranslation.Should().Be(expectedTranslation); var result = await pipeline.ToListAsync(); @@ -224,6 +267,13 @@ select new } #endif + private IMongoCollection GetCollection(LinqProvider linqProvider) + { + var client = DriverTestConfiguration.GetLinqClient(linqProvider); + var database = client.GetDatabase(__collection.Database.DatabaseNamespace.DatabaseName); + return database.GetCollection(__collection.CollectionNamespace.CollectionName); + } + [BsonIgnoreExtraElements] private class ZipEntry { diff --git a/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs index 47cfbdb4c51..d142e8ca17d 100644 --- a/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/UpdateDefinitionBuilderTests.cs @@ -253,16 +253,27 @@ public void Incorrect_index_should_throw_expected_exception_with_set() AssertThrow(subject.Set(x => x.Pets.ElementAt(-2).Name, "Fluffencutters"), expectedErrorMessage, LinqProvider.V3); } - [Fact] - public void Indexed_Positional_Typed() + [Theory] + [ParameterAttributeData] + public void Indexed_Positional_Typed( + [Values(LinqProvider.V2, LinqProvider.V3)] LinqProvider linqProvider) { var subject = CreateSubject(); + if (linqProvider == LinqProvider.V2) + { #pragma warning disable - Assert(subject.Set(x => x.FavoriteColors[-1], "yellow"), "{$set: {'colors.$': 'yellow'}}"); + Assert(subject.Set(x => x.FavoriteColors[-1], "yellow"), "{$set: {'colors.$': 'yellow'}}", linqProvider); #pragma warning restore - Assert(subject.Set(x => x.Pets[-1].Name, "Fluffencutters"), "{$set: {'pets.$.name': 'Fluffencutters'}}"); - Assert(subject.Set(x => x.Pets.ElementAt(-1).Name, "Fluffencutters"), "{$set: {'pets.$.name': 'Fluffencutters'}}"); + Assert(subject.Set(x => x.Pets[-1].Name, "Fluffencutters"), "{$set: {'pets.$.name': 'Fluffencutters'}}", linqProvider); + Assert(subject.Set(x => x.Pets.ElementAt(-1).Name, "Fluffencutters"), "{$set: {'pets.$.name': 'Fluffencutters'}}", linqProvider); + } + else + { + Assert(subject.Set(x => x.FavoriteColors.FirstMatchingElement(), "yellow"), "{$set: {'colors.$': 'yellow'}}", linqProvider); + Assert(subject.Set(x => x.Pets.FirstMatchingElement().Name, "Fluffencutters"), "{$set: {'pets.$.name': 'Fluffencutters'}}", linqProvider); + Assert(subject.Set(x => x.Pets.FirstMatchingElement().Name, "Fluffencutters"), "{$set: {'pets.$.name': 'Fluffencutters'}}", linqProvider); + } } [Fact] @@ -596,11 +607,11 @@ public void Set_Typed_with_cast() { var subject = CreateSubject(); - Assert(subject.Set(x => ((SmsMessage)x).PhoneNumber, "1234567890"), "{$set: {pn: '1234567890'}}", LinqProvider.V3); + Assert(subject.Set(x => ((SmsMessage)x).PhoneNumber, "1234567890"), "{$set: {pn: '1234567890'}}"); var subject2 = CreateSubject(); - Assert(subject2.Set(x => ((SmsMessage)x.Message).PhoneNumber, "1234567890"), "{$set: {'m.pn': '1234567890'}}", LinqProvider.V3); + Assert(subject2.Set(x => ((SmsMessage)x.Message).PhoneNumber, "1234567890"), "{$set: {'m.pn': '1234567890'}}"); } [Fact] @@ -608,11 +619,11 @@ public void Set_Typed_with_type_as() { var subject = CreateSubject(); - Assert(subject.Set(x => (x as SmsMessage).PhoneNumber, "1234567890"), "{$set: {pn: '1234567890'}}", LinqProvider.V3); + Assert(subject.Set(x => (x as SmsMessage).PhoneNumber, "1234567890"), "{$set: {pn: '1234567890'}}"); var subject2 = CreateSubject(); - Assert(subject2.Set(x => (x.Message as SmsMessage).PhoneNumber, "1234567890"), "{$set: {'m.pn': '1234567890'}}", LinqProvider.V3); + Assert(subject2.Set(x => (x.Message as SmsMessage).PhoneNumber, "1234567890"), "{$set: {'m.pn': '1234567890'}}"); } [Fact] @@ -649,12 +660,7 @@ public void Unset_Typed() Assert(subject.Unset("Age"), "{$unset: {age: 1}}"); } - private void Assert(UpdateDefinition update, BsonDocument expected) - { - Assert(update, expected, LinqProvider.V2); - } - - private void Assert(UpdateDefinition update, BsonDocument expected, LinqProvider linqProvider) + private void Assert(UpdateDefinition update, BsonDocument expected, LinqProvider linqProvider = LinqProvider.V3) { var renderedUpdate = Render(update, linqProvider).AsBsonDocument; @@ -669,22 +675,12 @@ private void Assert(UpdateDefinition update, string[] expe renderedUpdate.Should().Be(bsonArray); } - private void Assert(UpdateDefinition update, string expected) - { - Assert(update, expected, LinqProvider.V2); - } - - private void Assert(UpdateDefinition update, string expected, LinqProvider linqProvider) + private void Assert(UpdateDefinition update, string expected, LinqProvider linqProvider = LinqProvider.V3) { Assert(update, BsonDocument.Parse(expected), linqProvider); } - private void AssertThrow(UpdateDefinition update, string errorMessage) where TException : Exception - { - AssertThrow(update, errorMessage, LinqProvider.V2); - } - - private void AssertThrow(UpdateDefinition update, string errorMessage, LinqProvider linqProvider) where TException : Exception + private void AssertThrow(UpdateDefinition update, string errorMessage, LinqProvider linqProvider = LinqProvider.V3) where TException : Exception { var exception = Record.Exception(() => { Render(update, linqProvider); }); exception.Should().BeOfType(); @@ -696,12 +692,7 @@ private UpdateDefinitionBuilder CreateSubject() return new UpdateDefinitionBuilder(); } - private BsonValue Render(UpdateDefinition update) - { - return Render(update, LinqProvider.V2); - } - - private BsonValue Render(UpdateDefinition update, LinqProvider linqProvider) + private BsonValue Render(UpdateDefinition update, LinqProvider linqProvider = LinqProvider.V3) { var documentSerializer = BsonSerializer.SerializerRegistry.GetSerializer(); return update.Render(documentSerializer, BsonSerializer.SerializerRegistry, linqProvider); From cc9a8954239ef8ec7b69016bd8490c1b5ddd9958 Mon Sep 17 00:00:00 2001 From: rstam Date: Mon, 12 Dec 2022 16:42:34 -0800 Subject: [PATCH 15/21] CSHARP-4445: Support 64-bit values for Skip and Limit/Take. --- src/MongoDB.Driver/AggregateFluent.cs | 4 +- src/MongoDB.Driver/AggregateFluentBase.cs | 4 +- src/MongoDB.Driver/IAggregateFluent.cs | 4 +- .../Reflection/MongoQueryableMethod.cs | 6 + .../SkipMethodToPipelineTranslator.cs | 10 +- .../TakeMethodToPipelineTranslator.cs | 10 +- src/MongoDB.Driver/Linq/MongoQueryable.cs | 41 +++ .../PipelineDefinitionBuilder.cs | 4 +- .../PipelineStageDefinitionBuilder.cs | 4 +- .../Jira/CSharp4445Tests.cs | 271 ++++++++++++++++++ 10 files changed, 344 insertions(+), 14 deletions(-) create mode 100644 tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4445Tests.cs diff --git a/src/MongoDB.Driver/AggregateFluent.cs b/src/MongoDB.Driver/AggregateFluent.cs index a2c44a32e37..2140a71ddd0 100644 --- a/src/MongoDB.Driver/AggregateFluent.cs +++ b/src/MongoDB.Driver/AggregateFluent.cs @@ -147,7 +147,7 @@ public override IAggregateFluent Group(ProjectionDefinit return WithPipeline(_pipeline.Group(group)); } - public override IAggregateFluent Limit(int limit) + public override IAggregateFluent Limit(long limit) { return WithPipeline(_pipeline.Limit(limit)); } @@ -278,7 +278,7 @@ public override IAggregateFluent ReplaceWith(AggregateEx return WithPipeline(_pipeline.SetWindowFields(partitionBy, sortBy, output)); } - public override IAggregateFluent Skip(int skip) + public override IAggregateFluent Skip(long skip) { return WithPipeline(_pipeline.Skip(skip)); } diff --git a/src/MongoDB.Driver/AggregateFluentBase.cs b/src/MongoDB.Driver/AggregateFluentBase.cs index 4f61a2ebf83..7a5b0547e9d 100644 --- a/src/MongoDB.Driver/AggregateFluentBase.cs +++ b/src/MongoDB.Driver/AggregateFluentBase.cs @@ -142,7 +142,7 @@ public virtual IAggregateFluent Count() public abstract IAggregateFluent Group(ProjectionDefinition group); /// - public abstract IAggregateFluent Limit(int limit); + public abstract IAggregateFluent Limit(long limit); /// public virtual IAggregateFluent Lookup(string foreignCollectionName, FieldDefinition localField, FieldDefinition foreignField, FieldDefinition @as, AggregateLookupOptions options) @@ -261,7 +261,7 @@ public virtual IAggregateFluent ReplaceWith(AggregateExp } /// - public abstract IAggregateFluent Skip(int skip); + public abstract IAggregateFluent Skip(long skip); /// public abstract IAggregateFluent Sort(SortDefinition sort); diff --git a/src/MongoDB.Driver/IAggregateFluent.cs b/src/MongoDB.Driver/IAggregateFluent.cs index 1747fb96f21..c70dc82327e 100644 --- a/src/MongoDB.Driver/IAggregateFluent.cs +++ b/src/MongoDB.Driver/IAggregateFluent.cs @@ -216,7 +216,7 @@ public interface IAggregateFluent : IAsyncCursorSource /// /// The limit. /// The fluent aggregate interface. - IAggregateFluent Limit(int limit); + IAggregateFluent Limit(long limit); /// /// Appends a lookup stage to the pipeline. @@ -416,7 +416,7 @@ public interface IAggregateFluent : IAsyncCursorSource /// /// The number of documents to skip. /// The fluent aggregate interface. - IAggregateFluent Skip(int skip); + IAggregateFluent Skip(long skip); /// /// Appends a sort stage to the pipeline. diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Reflection/MongoQueryableMethod.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Reflection/MongoQueryableMethod.cs index 8e794508fe4..074b183b844 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Reflection/MongoQueryableMethod.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Reflection/MongoQueryableMethod.cs @@ -68,6 +68,7 @@ internal static class MongoQueryableMethod private static readonly MethodInfo __singleOrDefaultAsync; private static readonly MethodInfo __singleOrDefaultWithPredicateAsync; private static readonly MethodInfo __singleWithPredicateAsync; + private static readonly MethodInfo __skipWithLong; private static readonly MethodInfo __standardDeviationPopulationDecimal; private static readonly MethodInfo __standardDeviationPopulationDecimalAsync; private static readonly MethodInfo __standardDeviationPopulationDecimalWithSelector; @@ -168,6 +169,7 @@ internal static class MongoQueryableMethod private static readonly MethodInfo __sumNullableSingleWithSelectorAsync; private static readonly MethodInfo __sumSingleAsync; private static readonly MethodInfo __sumSingleWithSelectorAsync; + private static readonly MethodInfo __takeWithLong; // static constructor static MongoQueryableMethod() @@ -215,6 +217,7 @@ static MongoQueryableMethod() __singleOrDefaultAsync = ReflectionInfo.Method((IMongoQueryable source, CancellationToken cancellationToken) => source.SingleOrDefaultAsync(cancellationToken)); __singleOrDefaultWithPredicateAsync = ReflectionInfo.Method((IMongoQueryable source, Expression> predicate, CancellationToken cancellationToken) => source.SingleOrDefaultAsync(predicate, cancellationToken)); __singleWithPredicateAsync = ReflectionInfo.Method((IMongoQueryable source, Expression> predicate, CancellationToken cancellationToken) => source.SingleAsync(predicate, cancellationToken)); + __skipWithLong = ReflectionInfo.Method((IMongoQueryable source, long count) => source.Skip(count)); __standardDeviationPopulationDecimal = ReflectionInfo.Method((IMongoQueryable source) => source.StandardDeviationPopulation()); __standardDeviationPopulationDecimalAsync = ReflectionInfo.Method((IMongoQueryable source, CancellationToken cancellationToken) => source.StandardDeviationPopulationAsync(cancellationToken)); __standardDeviationPopulationDecimalWithSelector = ReflectionInfo.Method((IMongoQueryable source, Expression> selector) => source.StandardDeviationPopulation(selector)); @@ -315,6 +318,7 @@ static MongoQueryableMethod() __sumNullableSingleWithSelectorAsync = ReflectionInfo.Method((IMongoQueryable source, Expression> selector, CancellationToken cancellationToken) => source.SumAsync(selector, cancellationToken)); __sumSingleAsync = ReflectionInfo.Method((IMongoQueryable source, CancellationToken cancellationToken) => source.SumAsync(cancellationToken)); __sumSingleWithSelectorAsync = ReflectionInfo.Method((IMongoQueryable source, Expression> selector, CancellationToken cancellationToken) => source.SumAsync(selector, cancellationToken)); + __takeWithLong = ReflectionInfo.Method((IMongoQueryable source, long count) => source.Take(count)); } // public properties @@ -361,6 +365,7 @@ static MongoQueryableMethod() public static MethodInfo SingleOrDefaultAsync => __singleOrDefaultAsync; public static MethodInfo SingleOrDefaultWithPredicateAsync => __singleOrDefaultWithPredicateAsync; public static MethodInfo SingleWithPredicateAsync => __singleWithPredicateAsync; + public static MethodInfo SkipWithLong => __skipWithLong; public static MethodInfo StandardDeviationPopulationDecimal => __standardDeviationPopulationDecimal; public static MethodInfo StandardDeviationPopulationDecimalAsync => __standardDeviationPopulationDecimalAsync; public static MethodInfo StandardDeviationPopulationDecimalWithSelector => __standardDeviationPopulationDecimalWithSelector; @@ -461,5 +466,6 @@ static MongoQueryableMethod() public static MethodInfo SumNullableSingleWithSelectorAsync => __sumNullableSingleWithSelectorAsync; public static MethodInfo SumSingleAsync => __sumSingleAsync; public static MethodInfo SumSingleWithSelectorAsync => __sumSingleWithSelectorAsync; + public static MethodInfo TakeWithLong => __takeWithLong; } } diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/SkipMethodToPipelineTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/SkipMethodToPipelineTranslator.cs index 0449a1d0ef3..baf3662ac0c 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/SkipMethodToPipelineTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/SkipMethodToPipelineTranslator.cs @@ -30,13 +30,19 @@ public static AstPipeline Translate(TranslationContext context, MethodCallExpres var method = expression.Method; var arguments = expression.Arguments; - if (method.Is(QueryableMethod.Skip)) + if (method.IsOneOf(QueryableMethod.Skip, MongoQueryableMethod.SkipWithLong)) { var sourceExpression = arguments[0]; + if (method.Is(MongoQueryableMethod.SkipWithLong)) + { + sourceExpression = ConvertHelper.RemoveConvertToMongoQueryable(arguments[0]); + } var pipeline = ExpressionToPipelineTranslator.Translate(context, sourceExpression); var countExpression = arguments[1]; - var count = countExpression.GetConstantValue(containingExpression: expression); + var count = method.Is(MongoQueryableMethod.SkipWithLong) ? + countExpression.GetConstantValue(containingExpression: expression) : + countExpression.GetConstantValue(containingExpression: expression); pipeline = pipeline.AddStages( pipeline.OutputSerializer, diff --git a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/TakeMethodToPipelineTranslator.cs b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/TakeMethodToPipelineTranslator.cs index 5ddc32c7185..1fd99416e92 100644 --- a/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/TakeMethodToPipelineTranslator.cs +++ b/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToPipelineTranslators/TakeMethodToPipelineTranslator.cs @@ -30,13 +30,19 @@ public static AstPipeline Translate(TranslationContext context, MethodCallExpres var method = expression.Method; var arguments = expression.Arguments; - if (method.Is(QueryableMethod.Take)) + if (method.IsOneOf(QueryableMethod.Take, MongoQueryableMethod.TakeWithLong)) { var sourceExpression = arguments[0]; + if (method.Is(MongoQueryableMethod.TakeWithLong)) + { + sourceExpression = ConvertHelper.RemoveConvertToMongoQueryable(arguments[0]); + } var pipeline = ExpressionToPipelineTranslator.Translate(context, sourceExpression); var countExpression = arguments[1]; - var count = countExpression.GetConstantValue(containingExpression: expression); + var count = method.Is(MongoQueryableMethod.TakeWithLong) ? + countExpression.GetConstantValue(containingExpression: expression) : + countExpression.GetConstantValue(containingExpression: expression); pipeline = pipeline.AddStages( pipeline.OutputSerializer, diff --git a/src/MongoDB.Driver/Linq/MongoQueryable.cs b/src/MongoDB.Driver/Linq/MongoQueryable.cs index c67658673e3..23095b3b755 100644 --- a/src/MongoDB.Driver/Linq/MongoQueryable.cs +++ b/src/MongoDB.Driver/Linq/MongoQueryable.cs @@ -1302,6 +1302,27 @@ public static IMongoQueryable Skip(this IMongoQueryable)Queryable.Skip(source, count); } + /// + /// Bypasses a specified number of elements in a sequence and then returns the + /// remaining elements. + /// + /// The type of the elements of source + /// An to return elements from. + /// The number of elements to skip before returning the remaining elements. + /// + /// An that contains elements that occur after the + /// specified index in the input sequence. + /// + public static IMongoQueryable Skip(this IMongoQueryable source, long count) + { + return (IMongoQueryable)source.Provider.CreateQuery( + Expression.Call( + null, + GetMethodInfo(Skip, source, count), + Expression.Convert(source.Expression, typeof(IMongoQueryable)), + Expression.Constant(count))); + } + /// /// Computes the population standard deviation of a sequence of values. /// @@ -3329,6 +3350,26 @@ public static IMongoQueryable Take(this IMongoQueryable)Queryable.Take(source, count); } + /// + /// Returns a specified number of contiguous elements from the start of a sequence. + /// + /// The type of the elements of . + /// The sequence to return elements from. + /// The number of elements to return. + /// + /// An that contains the specified number of elements + /// from the start of source. + /// + public static IMongoQueryable Take(this IMongoQueryable source, long count) + { + return (IMongoQueryable)source.Provider.CreateQuery( + Expression.Call( + null, + GetMethodInfo(Take, source, count), + Expression.Convert(source.Expression, typeof(IMongoQueryable)), + Expression.Constant(count))); + } + /// /// Performs a subsequent ordering of the elements in a sequence in ascending /// order according to a key. diff --git a/src/MongoDB.Driver/PipelineDefinitionBuilder.cs b/src/MongoDB.Driver/PipelineDefinitionBuilder.cs index 158caf03131..eb5731ecd2a 100644 --- a/src/MongoDB.Driver/PipelineDefinitionBuilder.cs +++ b/src/MongoDB.Driver/PipelineDefinitionBuilder.cs @@ -794,7 +794,7 @@ public static class PipelineDefinitionBuilder /// public static PipelineDefinition Limit( this PipelineDefinition pipeline, - int limit) + long limit) { Ensure.IsNotNull(pipeline, nameof(pipeline)); return pipeline.AppendStage(PipelineStageDefinitionBuilder.Limit(limit)); @@ -1351,7 +1351,7 @@ public static class PipelineDefinitionBuilder /// public static PipelineDefinition Skip( this PipelineDefinition pipeline, - int skip) + long skip) { Ensure.IsNotNull(pipeline, nameof(pipeline)); return pipeline.AppendStage(PipelineStageDefinitionBuilder.Skip(skip)); diff --git a/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs b/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs index d448b578c2e..d00d9942948 100644 --- a/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs +++ b/src/MongoDB.Driver/PipelineStageDefinitionBuilder.cs @@ -898,7 +898,7 @@ public static class PipelineStageDefinitionBuilder /// The limit. /// The stage. public static PipelineStageDefinition Limit( - int limit) + long limit) { Ensure.IsGreaterThanZero(limit, nameof(limit)); return new BsonDocumentPipelineStageDefinition(new BsonDocument("$limit", limit)); @@ -1653,7 +1653,7 @@ public static class PipelineStageDefinitionBuilder /// The skip. /// The stage. public static PipelineStageDefinition Skip( - int skip) + long skip) { Ensure.IsGreaterThanOrEqualToZero(skip, nameof(skip)); return new BsonDocumentPipelineStageDefinition(new BsonDocument("$skip", skip)); diff --git a/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4445Tests.cs b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4445Tests.cs new file mode 100644 index 00000000000..10eda6fc2ca --- /dev/null +++ b/tests/MongoDB.Driver.Tests/Linq/Linq3ImplementationTests/Jira/CSharp4445Tests.cs @@ -0,0 +1,271 @@ +/* Copyright 2010-present MongoDB Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +using System.Linq; +using FluentAssertions; +using MongoDB.Bson; +using MongoDB.Driver.Linq; +using Xunit; + +namespace MongoDB.Driver.Tests.Linq.Linq3ImplementationTests.Jira +{ + public class CSharp4445Tests : Linq3IntegrationTest + { + [Fact] + public void AggregateFluent_Limit_with_int_should_work() + { + var collection = CreateCollection(); + int limit = 1; + + var aggregate = + collection.Aggregate() + .Limit(limit); + + var stages = Translate(collection, aggregate); + + AssertStages(stages, "{ $limit : 1 }"); + stages[0]["$limit"].BsonType.Should().Be(BsonType.Int64); + + var results = aggregate.ToList(); + results.Select(x => x.Id).Should().Equal(1); + } + + [Fact] + public void AggregateFluent_Limit_with_long_should_work() + { + var collection = CreateCollection(); + long limit = 1; + + var aggregate = + collection.Aggregate() + .Limit(limit); + + var stages = Translate(collection, aggregate); + + AssertStages(stages, "{ $limit : 1 }"); + stages[0]["$limit"].BsonType.Should().Be(BsonType.Int64); + + var results = aggregate.ToList(); + results.Select(x => x.Id).Should().Equal(1); + } + + [Fact] + public void AggregateFluent_Skip_with_int_should_work() + { + var collection = CreateCollection(); + int skip = 1; + + var aggregate = + collection.Aggregate() + .Skip(skip); + + var stages = Translate(collection, aggregate); + + AssertStages(stages, "{ $skip : 1 }"); + stages[0]["$skip"].BsonType.Should().Be(BsonType.Int64); + + var results = aggregate.ToList(); + results.Select(x => x.Id).Should().Equal(2); + } + + [Fact] + public void AggregateFluent_Skip_with_long_should_work() + { + var collection = CreateCollection(); + long limit = 1; + + var aggregate = + collection.Aggregate() + .Skip(limit); + + var stages = Translate(collection, aggregate); + + AssertStages(stages, "{ $skip : 1 }"); + stages[0]["$skip"].BsonType.Should().Be(BsonType.Int64); + + var results = aggregate.ToList(); + results.Select(x => x.Id).Should().Equal(2); + } + + [Fact] + public void PipelineDefinitionBuilder_Limit_with_int_should_work() + { + var collection = CreateCollection(); + int limit = 1; + + var pipeline = + new EmptyPipelineDefinition() + .Limit(limit); + + var stages = Translate(pipeline); + + AssertStages(stages, "{ $limit : 1 }"); + stages[0]["$limit"].BsonType.Should().Be(BsonType.Int64); + + var results = collection.Aggregate(pipeline).ToList(); + results.Select(x => x.Id).Should().Equal(1); + } + + [Fact] + public void PipelineDefinitionBuilder_Limit_with_long_should_work() + { + var collection = CreateCollection(); + long limit = 1; + + var pipeline = + new EmptyPipelineDefinition() + .Limit(limit); + + var stages = Translate(pipeline); + + AssertStages(stages, "{ $limit : 1 }"); + stages[0]["$limit"].BsonType.Should().Be(BsonType.Int64); + + var results = collection.Aggregate(pipeline).ToList(); + results.Select(x => x.Id).Should().Equal(1); + } + + [Fact] + public void PipelineDefinitionBuilder_Skip_with_int_should_work() + { + var collection = CreateCollection(); + int skip = 1; + + var pipeline = + new EmptyPipelineDefinition() + .Skip(skip); + + var stages = Translate(pipeline); + + AssertStages(stages, "{ $skip : 1 }"); + stages[0]["$skip"].BsonType.Should().Be(BsonType.Int64); + + var results = collection.Aggregate(pipeline).ToList(); + results.Select(x => x.Id).Should().Equal(2); + } + + [Fact] + public void PipelineDefinitionBuilder_Skip_with_long_should_work() + { + var collection = CreateCollection(); + long skip = 1; + + var pipeline = + new EmptyPipelineDefinition() + .Skip(skip); + + var stages = Translate(pipeline); + + AssertStages(stages, "{ $skip : 1 }"); + stages[0]["$skip"].BsonType.Should().Be(BsonType.Int64); + + var results = collection.Aggregate(pipeline).ToList(); + results.Select(x => x.Id).Should().Equal(2); + } + + [Fact] + public void Queryable_Skip_with_int_should_work() + { + var collection = CreateCollection(); + int count = 1; + + var queryable = + collection.AsQueryable() + .Skip(count); + + var stages = Translate(collection, queryable); + + AssertStages(stages, "{ $skip : 1 }"); + stages[0]["$skip"].BsonType.Should().Be(BsonType.Int64); + + var results = queryable.ToList(); + results.Select(x => x.Id).Should().Equal(2); + } + + [Fact] + public void Queryable_Skip_with_long_should_work() + { + var collection = CreateCollection(); + long count = 1; + + var queryable = + collection.AsQueryable() + .Skip(count); + + var stages = Translate(collection, queryable); + + AssertStages(stages, "{ $skip : 1 }"); + stages[0]["$skip"].BsonType.Should().Be(BsonType.Int64); + + var results = queryable.ToList(); + results.Select(x => x.Id).Should().Equal(2); + } + + [Fact] + public void Queryable_Take_with_int_should_work() + { + var collection = CreateCollection(); + int count = 1; + + var queryable = + collection.AsQueryable() + .Take(count); + + var stages = Translate(collection, queryable); + + AssertStages(stages, "{ $limit : 1 }"); + stages[0]["$limit"].BsonType.Should().Be(BsonType.Int64); + + var results = queryable.ToList(); + results.Select(x => x.Id).Should().Equal(1); + } + + [Fact] + public void Queryable_Take_with_long_should_work() + { + var collection = CreateCollection(); + long count = 1; + + var queryable = + collection.AsQueryable() + .Take(count); + + var stages = Translate(collection, queryable); + + AssertStages(stages, "{ $limit : 1 }"); + stages[0]["$limit"].BsonType.Should().Be(BsonType.Int64); + + var results = queryable.ToList(); + results.Select(x => x.Id).Should().Equal(1); + } + + private IMongoCollection CreateCollection() + { + var collection = GetCollection("C"); + + CreateCollection( + collection, + new C { Id = 1 }, + new C { Id = 2 }); + + return collection; + } + + private class C + { + public int Id { get; set; } + } + } +} From 586b2cca446b0f1918a08b59873426f0ff766eae Mon Sep 17 00:00:00 2001 From: rstam Date: Wed, 14 Dec 2022 09:18:05 -0800 Subject: [PATCH 16/21] Fix compilation errors resulting from merge. --- tests/MongoDB.Driver.Tests/ProjectionDefinitionBuilderTests.cs | 2 +- tests/MongoDB.Driver.Tests/Samples/AggregationSample.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/MongoDB.Driver.Tests/ProjectionDefinitionBuilderTests.cs b/tests/MongoDB.Driver.Tests/ProjectionDefinitionBuilderTests.cs index 2bdbe788b36..bc13efb3b01 100644 --- a/tests/MongoDB.Driver.Tests/ProjectionDefinitionBuilderTests.cs +++ b/tests/MongoDB.Driver.Tests/ProjectionDefinitionBuilderTests.cs @@ -18,8 +18,8 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; -using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests diff --git a/tests/MongoDB.Driver.Tests/Samples/AggregationSample.cs b/tests/MongoDB.Driver.Tests/Samples/AggregationSample.cs index 223282d6526..74efd2619b5 100644 --- a/tests/MongoDB.Driver.Tests/Samples/AggregationSample.cs +++ b/tests/MongoDB.Driver.Tests/Samples/AggregationSample.cs @@ -17,9 +17,9 @@ using System.Threading.Tasks; using FluentAssertions; using MongoDB.Bson.Serialization.Attributes; -using MongoDB.Bson.TestHelpers.XunitExtensions; using MongoDB.Driver.Linq; using MongoDB.Driver.Tests.Linq.Linq3ImplementationTests; +using MongoDB.TestHelpers.XunitExtensions; using Xunit; namespace MongoDB.Driver.Tests.Samples From f159956e32874eb63216c3a749c9cf040e1fe0b2 Mon Sep 17 00:00:00 2001 From: Dmitry Lukyanov Date: Wed, 14 Dec 2022 22:17:48 +0400 Subject: [PATCH 17/21] CSHARP-4255: Automatically create Queryable Encryption keys. (#961) --- .../Encryption/EncryptedCollectionHelper.cs | 24 +++++ .../Encryption/ClientEncryption.cs | 59 ++++++++++ .../Encryption/LibMongoCryptControllerBase.cs | 3 + .../prose-tests/ClientEncryptionProseTests.cs | 101 +++++++++++++++++- 4 files changed, 184 insertions(+), 3 deletions(-) diff --git a/src/MongoDB.Driver.Core/Core/Encryption/EncryptedCollectionHelper.cs b/src/MongoDB.Driver.Core/Core/Encryption/EncryptedCollectionHelper.cs index 0e66ad36641..7fc13b4a363 100644 --- a/src/MongoDB.Driver.Core/Core/Encryption/EncryptedCollectionHelper.cs +++ b/src/MongoDB.Driver.Core/Core/Encryption/EncryptedCollectionHelper.cs @@ -76,6 +76,30 @@ public static BsonDocument GetEffectiveEncryptedFields(CollectionNamespace colle } } + public static IEnumerable IterateEmptyKeyIds(CollectionNamespace collectionNamespace, BsonDocument encryptedFields) + { + if (!EncryptedCollectionHelper.TryGetEffectiveEncryptedFields(collectionNamespace, encryptedFields, encryptedFieldsMap: null, out var storedEncryptedFields)) + { + throw new InvalidOperationException("There are no encrypted fields defined for the collection."); + } + + if (storedEncryptedFields.TryGetValue("fields", out var fields) && fields is BsonArray fieldsArray) + { + foreach (var field in fieldsArray.OfType()) // If `F` is not a document element, skip it. + { + if (field.TryGetElement("keyId", out var keyId) && keyId.Value == BsonNull.Value) + { + yield return field; + } + } + } + } + + public static void ModifyEncryptedFields(BsonDocument fieldDocument, Guid dataKey) + { + fieldDocument["keyId"] = new BsonBinaryData(dataKey, GuidRepresentation.Standard); + } + public enum HelperCollectionForEncryption { Esc, diff --git a/src/MongoDB.Driver/Encryption/ClientEncryption.cs b/src/MongoDB.Driver/Encryption/ClientEncryption.cs index ce01732ff5b..7dfadcb36b5 100644 --- a/src/MongoDB.Driver/Encryption/ClientEncryption.cs +++ b/src/MongoDB.Driver/Encryption/ClientEncryption.cs @@ -20,6 +20,7 @@ using MongoDB.Bson; using MongoDB.Driver.Core.Clusters; using MongoDB.Driver.Core.Configuration; +using MongoDB.Driver.Core.Misc; using MongoDB.Libmongocrypt; namespace MongoDB.Driver.Encryption @@ -78,6 +79,64 @@ public ClientEncryption(ClientEncryptionOptions clientEncryptionOptions) public Task AddAlternateKeyNameAsync(Guid id, string alternateKeyName, CancellationToken cancellationToken = default) => _libMongoCryptController.AddAlternateKeyNameAsync(id, alternateKeyName, cancellationToken); + /// + /// Create encrypted collection. + /// + /// The collection namespace. + /// The create collection options. + /// The kms provider. + /// The datakey options. + /// The cancellation token. + /// + /// if EncryptionFields contains a keyId with a null value, a data key will be automatically generated and assigned to keyId value. + /// + public void CreateEncryptedCollection(CollectionNamespace collectionNamespace, CreateCollectionOptions createCollectionOptions, string kmsProvider, DataKeyOptions dataKeyOptions, CancellationToken cancellationToken = default) + { + Ensure.IsNotNull(collectionNamespace, nameof(collectionNamespace)); + Ensure.IsNotNull(createCollectionOptions, nameof(createCollectionOptions)); + Ensure.IsNotNull(dataKeyOptions, nameof(dataKeyOptions)); + Ensure.IsNotNull(kmsProvider, nameof(kmsProvider)); + + foreach (var fieldDocument in EncryptedCollectionHelper.IterateEmptyKeyIds(collectionNamespace, createCollectionOptions.EncryptedFields)) + { + var dataKey = CreateDataKey(kmsProvider, dataKeyOptions, cancellationToken); + EncryptedCollectionHelper.ModifyEncryptedFields(fieldDocument, dataKey); + } + + var database = _libMongoCryptController.KeyVaultClient.GetDatabase(collectionNamespace.DatabaseNamespace.DatabaseName); + + database.CreateCollection(collectionNamespace.CollectionName, createCollectionOptions, cancellationToken); + } + + /// + /// Create encrypted collection. + /// + /// The collection namespace. + /// The create collection options. + /// The kms provider. + /// The datakey options. + /// The cancellation token. + /// + /// if EncryptionFields contains a keyId with a null value, a data key will be automatically generated and assigned to keyId value. + /// + public async Task CreateEncryptedCollectionAsync(CollectionNamespace collectionNamespace, CreateCollectionOptions createCollectionOptions, string kmsProvider, DataKeyOptions dataKeyOptions, CancellationToken cancellationToken = default) + { + Ensure.IsNotNull(collectionNamespace, nameof(collectionNamespace)); + Ensure.IsNotNull(createCollectionOptions, nameof(createCollectionOptions)); + Ensure.IsNotNull(dataKeyOptions, nameof(dataKeyOptions)); + Ensure.IsNotNull(kmsProvider, nameof(kmsProvider)); + + foreach (var fieldDocument in EncryptedCollectionHelper.IterateEmptyKeyIds(collectionNamespace, createCollectionOptions.EncryptedFields)) + { + var dataKey = await CreateDataKeyAsync(kmsProvider, dataKeyOptions, cancellationToken).ConfigureAwait(false); + EncryptedCollectionHelper.ModifyEncryptedFields(fieldDocument, dataKey); + } + + var database = _libMongoCryptController.KeyVaultClient.GetDatabase(collectionNamespace.DatabaseNamespace.DatabaseName); + + await database.CreateCollectionAsync(collectionNamespace.CollectionName, createCollectionOptions, cancellationToken).ConfigureAwait(false); + } + /// /// An alias function equivalent to createKey. /// diff --git a/src/MongoDB.Driver/Encryption/LibMongoCryptControllerBase.cs b/src/MongoDB.Driver/Encryption/LibMongoCryptControllerBase.cs index 8c5a0d68515..e7464d3d8ee 100644 --- a/src/MongoDB.Driver/Encryption/LibMongoCryptControllerBase.cs +++ b/src/MongoDB.Driver/Encryption/LibMongoCryptControllerBase.cs @@ -61,6 +61,9 @@ internal abstract class LibMongoCryptControllerBase _tlsOptions = Ensure.IsNotNull(encryptionOptions.TlsOptions, nameof(encryptionOptions.TlsOptions)); } + // public properties + public IMongoClient KeyVaultClient => _keyVaultClient; + // protected methods protected void FeedResult(CryptContext context, BsonDocument document) { diff --git a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs index 36eecdcd55b..aa5329faa07 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs @@ -87,6 +87,76 @@ public ClientEncryptionProseTests(ITestOutputHelper testOutputHelper) // public methods [Theory] [ParameterAttributeData] + public void AutomaticDataEncryptionKeysTest( + [Range(1, 4)] int testCase, + [Values(false, true)] bool async) + { + RequireServer.Check().Supports(Feature.Csfle2).ClusterTypes(ClusterType.ReplicaSet, ClusterType.Sharded, ClusterType.LoadBalanced); + + var kmsProvider = "local"; + using (var client = ConfigureClient()) + using (var clientEncryption = ConfigureClientEncryption(client, kmsProviderFilter: kmsProvider)) + { + var encryptedFields = BsonDocument.Parse($@" + {{ + fields: + [ + {{ + path: ""ssn"", + bsonType: ""string"", + keyId: null + }} + ] + }}"); + + DropCollection(__collCollectionNamespace, encryptedFields); + + RunTestCase(testCase); + + void RunTestCase(int testCase) + { + switch (testCase) + { + case 1: // Case 1: Simple Creation and Validation + { + var collection = CreateEncryptedCollection(client, clientEncryption, __collCollectionNamespace, encryptedFields, kmsProvider, async); + + var exception = Record.Exception(() => Insert(collection, async, new BsonDocument("ssn", "123-45-6789"))); + exception.Should().BeOfType>().Which.Message.Should().Contain("Document failed validation"); + } + break; + case 2: // Case 2: Missing ``encryptedFields`` + { + var exception = Record.Exception(() => CreateEncryptedCollection(client, clientEncryption, __collCollectionNamespace, encryptedFields: null, kmsProvider, async)); + + exception.Should().BeOfType().Which.Message.Should().Contain("There are no encrypted fields defined for the collection.") ; + } + break; + case 3: // Case 3: Invalid ``keyId`` + { + var effectiveEncryptedFields = encryptedFields.DeepClone(); + effectiveEncryptedFields["fields"].AsBsonArray[0].AsBsonDocument["keyId"] = false; + var exception = Record.Exception(() => CreateEncryptedCollection(client, clientEncryption, __collCollectionNamespace, effectiveEncryptedFields.AsBsonDocument, kmsProvider, async)); + exception.Should().BeOfType().Which.Message.Should().Contain("BSON field 'create.encryptedFields.fields.keyId' is the wrong type 'bool', expected type 'binData'"); + } + break; + case 4: // Case 4: Insert encrypted value + { + var createCollectionOptions = new CreateCollectionOptions { EncryptedFields = encryptedFields }; + var collection = CreateEncryptedCollection(client, clientEncryption, __collCollectionNamespace, createCollectionOptions, kmsProvider, async); + var dataKey = createCollectionOptions.EncryptedFields["fields"].AsBsonArray[0].AsBsonDocument["keyId"].AsGuid; // get generated datakey + var encryptedValue = ExplicitEncrypt(clientEncryption, new EncryptOptions(algorithm: EncryptionAlgorithm.Unindexed, keyId: dataKey), "123-45-6789", async); // use explicit encryption to encrypt data before inserting + Insert(collection, async, new BsonDocument("ssn", encryptedValue)); + } + break; + default: throw new Exception($"Unexpected test case {testCase}."); + } + } + } + } + + [SkippableTheory] + [ParameterAttributeData] public void BsonSizeLimitAndBatchSizeSplittingTest( [Values(false, true)] bool async) { @@ -1123,6 +1193,7 @@ void RunTestCase(IMongoCollection decryptionEventsCollection, int reply["cursor"]["firstBatch"].AsBsonArray.Single()["encrypted"].AsBsonBinaryData.SubType.Should().Be(BsonBinarySubType.Encrypted); } break; + default: throw new Exception($"Unexpected test case {testCase}."); } } @@ -1875,6 +1946,8 @@ HttpClientWrapperWithModifiedRequest CreateHttpClientWrapperWithModifiedRequest( } } + [SkippableTheory] + [ParameterAttributeData] public void RewrapTest( [Values("local", "aws", "azure", "gcp", "kmip")] string srcProvider, [Values("local", "aws", "azure", "gcp", "kmip")] string dstProvider, @@ -1929,7 +2002,7 @@ public void ViewAreProhibitedTest([Values(false, true)] bool async) using (var client = ConfigureClient(false)) using (var clientEncrypted = ConfigureClientEncrypted(kmsProviderFilter: "local")) { - DropView(viewName); + DropCollection(viewName); client .GetDatabase(viewName.DatabaseNamespace.DatabaseName) .CreateView( @@ -2257,6 +2330,28 @@ private void CreateCollection(IMongoClient client, CollectionNamespace collectio }); } + private IMongoCollection CreateEncryptedCollection(IMongoClient client, ClientEncryption clientEncryption, CollectionNamespace collectionNamespace, BsonDocument encryptedFields, string kmsProvider, bool async) + { + var createCollectionOptions = new CreateCollectionOptions { EncryptedFields = encryptedFields }; + return CreateEncryptedCollection(client, clientEncryption, collectionNamespace, createCollectionOptions, kmsProvider, async); + } + + private IMongoCollection CreateEncryptedCollection(IMongoClient client, ClientEncryption clientEncryption, CollectionNamespace collectionNamespace, CreateCollectionOptions createCollectionOptions, string kmsProvider, bool async) + { + var datakeyOptions = CreateDataKeyOptions(kmsProvider); + + if (async) + { + clientEncryption.CreateEncryptedCollectionAsync(collectionNamespace, createCollectionOptions, kmsProvider, datakeyOptions, cancellationToken: default).GetAwaiter().GetResult(); + } + else + { + clientEncryption.CreateEncryptedCollection(collectionNamespace, createCollectionOptions, kmsProvider, datakeyOptions, cancellationToken: default); + } + + return client.GetDatabase(collectionNamespace.DatabaseNamespace.DatabaseName).GetCollection(collectionNamespace.CollectionName); + } + private Guid CreateDataKey( ClientEncryption clientEncryption, string kmsProvider, @@ -2407,9 +2502,9 @@ private RewrapManyDataKeyOptions CreateRewrapManyDataKeyOptions(string kmsProvid return mongoClientSettings; } - private void DropView(CollectionNamespace viewNamespace) + private void DropCollection(CollectionNamespace collectionNamespace, BsonDocument encryptedFields = null) { - var operation = new DropCollectionOperation(viewNamespace, CoreTestConfiguration.MessageEncoderSettings); + var operation = DropCollectionOperation.CreateEncryptedDropCollectionOperationIfConfigured(collectionNamespace, encryptedFields, CoreTestConfiguration.MessageEncoderSettings, configureDropCollectionConfigurator: null); using (var session = CoreTestConfiguration.StartSession(_cluster)) using (var binding = new WritableServerBinding(_cluster, session.Fork())) using (var bindingHandle = new ReadWriteBindingHandle(binding)) From 454f37c0add49479e374ea261883cf565dcef74d Mon Sep 17 00:00:00 2001 From: Dmitry Lukyanov Date: Thu, 15 Dec 2022 00:29:44 +0400 Subject: [PATCH 18/21] CSHARP-4255: Fix merge conflict. (#992) --- .../prose-tests/ClientEncryptionProseTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs index aa5329faa07..4610051a939 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs @@ -155,7 +155,7 @@ void RunTestCase(int testCase) } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void BsonSizeLimitAndBatchSizeSplittingTest( [Values(false, true)] bool async) @@ -1946,7 +1946,7 @@ HttpClientWrapperWithModifiedRequest CreateHttpClientWrapperWithModifiedRequest( } } - [SkippableTheory] + [Theory] [ParameterAttributeData] public void RewrapTest( [Values("local", "aws", "azure", "gcp", "kmip")] string srcProvider, From b3ca62272afe689f998c4c93b13e7d0b19e2917e Mon Sep 17 00:00:00 2001 From: Dmitry Lukyanov Date: Sat, 17 Dec 2022 04:52:58 +0400 Subject: [PATCH 19/21] CSHARP-4455: Fix test assertation. (#994) --- .../prose-tests/ClientEncryptionProseTests.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs index 4610051a939..cc71ce2294a 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/prose-tests/ClientEncryptionProseTests.cs @@ -1737,7 +1737,17 @@ void AssertException(Exception ex) // AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must not be configured case "aws": { - AssertInnerEncryptionException(ex, "Unable to get IAM security credentials from EC2 Instance Metadata Service."); + try + { + AssertInnerEncryptionException(ex, "Unable to get IAM security credentials from EC2 Instance Metadata Service."); + } + catch (XunitException) + { + // In rare cases, the thrown error is "CryptException exception: AcceessDeniedException". That means you don't have authorization to perform the requested action. + // It more or less corresponds to the expected behavior here, but it's unclear why the same scenario triggers different exceptions. + // However, it looks harmless to slightly update the test assertion to avoid assertion failures on EG. + AssertInnerEncryptionException(ex, "Error in KMS response. HTTP status=400. Response body=\n{\"__type\":\"AccessDeniedException\"}"); + } } break; case "azure": From cb8a4be121c036a315f31eb7c43dda712e12116a Mon Sep 17 00:00:00 2001 From: BorisDog Date: Thu, 22 Dec 2022 10:30:48 -0800 Subject: [PATCH 20/21] CSHARP-4420: EG tests for Atlas Search --- build.cake | 7 + evergreen/evergreen.yml | 20 + evergreen/run-atlas-search-test.sh | 14 + src/MongoDB.Driver/Linq/MongoQueryable.cs | 1 + src/MongoDB.Driver/Search/Highlight.cs | 79 +++ src/MongoDB.Driver/Search/HighlightOptions.cs | 23 + .../Search/AtlasSearchTest.cs | 504 ++++++++++++++++++ 7 files changed, 648 insertions(+) create mode 100644 evergreen/run-atlas-search-test.sh create mode 100644 src/MongoDB.Driver/Search/Highlight.cs create mode 100644 tests/MongoDB.Driver.Tests/Search/AtlasSearchTest.cs diff --git a/build.cake b/build.cake index d18483f8d70..eb277fe4fe0 100644 --- a/build.cake +++ b/build.cake @@ -240,6 +240,13 @@ Task("TestAtlasDataLake") action: (BuildConfig buildConfig, Path testProject) => RunTests(buildConfig, testProject, filter: "Category=\"AtlasDataLake\"")); +Task("TestAtlasSearch") + .IsDependentOn("Build") + .DoesForEach( + items: GetFiles("./**/MongoDB.Driver.Tests.csproj"), + action: (BuildConfig buildConfig, Path testProject) => + RunTests(buildConfig, testProject, filter: "Category=\"AtlasSearch\"")); + Task("TestOcsp") .IsDependentOn("Build") .DoesForEach( diff --git a/evergreen/evergreen.yml b/evergreen/evergreen.yml index 0965d68e9a9..a711d945256 100644 --- a/evergreen/evergreen.yml +++ b/evergreen/evergreen.yml @@ -684,6 +684,15 @@ functions: ${PREPARE_SHELL} evergreen/run-atlas-data-lake-test.sh + run-atlas-search-test: + - command: shell.exec + type: test + params: + working_dir: mongo-csharp-driver + script: | + ${PREPARE_SHELL} + ATLAS_SEARCH="${ATLAS_SEARCH}" evergreen/run-atlas-search-test.sh + run-ocsp-test: - command: shell.exec type: test @@ -1202,6 +1211,10 @@ tasks: - func: bootstrap-mongohoused - func: run-atlas-data-lake-test + - name: atlas-search-test + commands: + - func: run-atlas-search-test + - name: test-serverless-net472 exec_timeout_secs: 2700 # 45 minutes: 15 for setup + 30 for tests commands: @@ -2068,6 +2081,13 @@ buildvariants: tasks: - name: atlas-data-lake-test +- name: atlas-search-test + display_name: "Atlas Search Tests" + run_on: + - windows-64-vs2017-test + tasks: + - name: atlas-search-test + - name: gssapi-auth-tests-windows run_on: - windows-64-vs2017-test diff --git a/evergreen/run-atlas-search-test.sh b/evergreen/run-atlas-search-test.sh new file mode 100644 index 00000000000..1e55b90feea --- /dev/null +++ b/evergreen/run-atlas-search-test.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -o xtrace +set -o errexit # Exit the script with error if any of the commands fail + +############################################ +# Main Program # +############################################ + +echo "Running Atlas Search driver tests" + +export ATLAS_SEARCH_TESTS_ENABLED=true + +powershell.exe .\\build.ps1 --target TestAtlasSearch \ No newline at end of file diff --git a/src/MongoDB.Driver/Linq/MongoQueryable.cs b/src/MongoDB.Driver/Linq/MongoQueryable.cs index 23095b3b755..cb34191ca30 100644 --- a/src/MongoDB.Driver/Linq/MongoQueryable.cs +++ b/src/MongoDB.Driver/Linq/MongoQueryable.cs @@ -21,6 +21,7 @@ using System.Threading; using System.Threading.Tasks; using MongoDB.Bson.Serialization; +using MongoDB.Driver.Core.Misc; using MongoDB.Driver.Search; namespace MongoDB.Driver.Linq diff --git a/src/MongoDB.Driver/Search/Highlight.cs b/src/MongoDB.Driver/Search/Highlight.cs new file mode 100644 index 00000000000..6b453a15d15 --- /dev/null +++ b/src/MongoDB.Driver/Search/Highlight.cs @@ -0,0 +1,79 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; + +namespace MongoDB.Driver.Search +{ + /// + /// Represents a result of highlighting. + /// + public sealed class Highlight + { + /// + /// Gets or sets the document field which returned a match. + /// + [BsonElement("path")] + public string Path { get; private set; } + + /// + /// Gets or sets one or more objects containing the matching text and the surrounding text + /// (if any). + /// + [BsonElement("texts")] + public HighlightText[] Texts { get; private set; } + + /// + /// Gets or sets the score assigned to this result. + /// + [BsonElement("score")] + public double Score { get; private set; } + } + + /// + /// Represents the matching text or the surrounding text of a highlighting result. + /// + public class HighlightText + { + /// + /// Gets or sets the text from the field which returned a match. + /// + [BsonElement("value")] + public string Value { get; private set; } + + /// + /// Gets or sets the type of text, matching or surrounding. + /// + [BsonElement("type")] + [BsonRepresentation(BsonType.String)] + public HighlightTextType Type { get; private set; } + } + + /// + /// Represents the type of text in a highlighting result, matching or surrounding. + /// + public enum HighlightTextType + { + /// + /// Indicates that the text contains a match. + /// + Hit, + + /// + /// Indicates that the text contains the text content adjacent to a matching string. + /// + Text + } +} diff --git a/src/MongoDB.Driver/Search/HighlightOptions.cs b/src/MongoDB.Driver/Search/HighlightOptions.cs index 39b025772d2..ae79348c240 100644 --- a/src/MongoDB.Driver/Search/HighlightOptions.cs +++ b/src/MongoDB.Driver/Search/HighlightOptions.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; +using System.Linq.Expressions; using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Driver.Core.Misc; @@ -42,6 +44,27 @@ public HighlightOptions(PathDefinition path, int? maxCharsToExamine = _maxNumPassages = maxNumPassages; } + /// + /// Creates highlighting options. + /// + /// The document field to search. + /// + /// The maximum number of characters to examine on a document when performing highlighting + /// for a field. + /// + /// + /// The number of high-scoring passages to return per document in the highlighting results + /// for each field. + /// + /// Highlighting options. + public HighlightOptions( + Expression> path, + int? maxCharsToExamine = null, + int? maxNumPassages = null) : + this(new ExpressionFieldDefinition(path), maxCharsToExamine, maxNumPassages) + { + } + /// /// Gets or sets the document field to search. /// diff --git a/tests/MongoDB.Driver.Tests/Search/AtlasSearchTest.cs b/tests/MongoDB.Driver.Tests/Search/AtlasSearchTest.cs new file mode 100644 index 00000000000..50b217339d9 --- /dev/null +++ b/tests/MongoDB.Driver.Tests/Search/AtlasSearchTest.cs @@ -0,0 +1,504 @@ +// Copyright 2010-present MongoDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System; +using System.Collections.Generic; +using System.Linq; +using FluentAssertions; +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver.Core.Misc; +using MongoDB.Driver.Core.TestHelpers.Logging; +using MongoDB.Driver.GeoJsonObjectModel; +using MongoDB.Driver.Search; +using MongoDB.Driver.TestHelpers; +using MongoDB.TestHelpers.XunitExtensions; +using Xunit; +using Xunit.Abstractions; +using Builders = MongoDB.Driver.Builders; +using GeoBuilders = MongoDB.Driver.Builders; + +namespace MongoDB.Driver.Tests.Search +{ + [Trait("Category", "AtlasSearch")] + public class AtlasSearchTest : LoggableTestClass + { + private static readonly GeoJsonPolygon __testPolygon = + new(new(new(new GeoJson2DGeographicCoordinates[] + { + new(-8.6131, 41.14), + new(-8.6131, 41.145), + new(-8.60308, 41.145), + new(-8.60308, 41.14), + new(-8.6131, 41.14), + }))); + + private static readonly GeoWithinBox __testBox = + new(new(new(-8.6131, 41.14)), new(new(-8.60308, 41.145))); + + private static readonly GeoWithinCircle __testCircle = + new(new(new(-8.61308, 41.1413)), 273); + + private readonly DisposableMongoClient _disposableMongoClient; + + public AtlasSearchTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + RequireEnvironment.Check().EnvironmentVariable("ATLAS_SEARCH_TESTS_ENABLED"); + + var atlasSearchUri = Environment.GetEnvironmentVariable("ATLAS_SEARCH"); + Ensure.IsNotNullOrEmpty(atlasSearchUri, nameof(atlasSearchUri)); + + _disposableMongoClient = new(new MongoClient(atlasSearchUri), CreateLogger()); + } + + protected override void DisposeInternal() => + _disposableMongoClient.Dispose(); + + [Fact] + public void Autocomplete() + { + var result = SearchSingle(Builders.Search.Autocomplete("Declaration of Ind", x => x.Title)); + + result.Title.Should().Be("Declaration of Independence"); + } + + [Fact] + public void Compound() + { + var result = SearchSingle(Builders.Search.Compound() + .Must(Builders.Search.Text("life", x => x.Body), Builders.Search.Text("liberty", x => x.Body)) + .MustNot(Builders.Search.Text("property", x => x.Body)) + .Must(Builders.Search.Text("pursuit of happiness", x => x.Body))); + + result.Title.Should().Be("Declaration of Independence"); + } + + [Fact] + public void Count_total() + { + var results = GetTestCollection().Aggregate() + .Search( + Builders.Search.Phrase("life, liberty, and the pursuit of happiness", x => x.Body), + count: new SearchCountOptions() + { + Type = SearchCountType.Total + }) + .Project(Builders.Projection.SearchMeta(x => x.MetaResult)) + .Limit(1) + .ToList(); + results.Should().ContainSingle().Which.MetaResult.Count.Total.Should().Be(108); + } + + [Fact] + public void Exists() + { + var result = SearchSingle(Builders.Search.Compound() + .Must(Builders.Search.Text("life, liberty, and the pursuit of happiness", x => x.Body), + Builders.Search.Exists(x => x.Title))); + + result.Title.Should().Be("Declaration of Independence"); + } + + [Fact] + public void Filter() + { + var result = SearchSingle(Builders.Search.Compound().Filter( + Builders.Search.Phrase("life, liberty", x => x.Body), + Builders.Search.Wildcard("happ*", x => x.Body, true))); + + result.Title.Should().Be("Declaration of Independence"); + } + + [Theory] + [InlineData("add")] + [InlineData("constant")] + [InlineData("gauss")] + [InlineData("log")] + [InlineData("log1p")] + [InlineData("multiply")] + [InlineData("path")] + [InlineData("relevance")] + public void FunctionScore(string functionScoreType) + { + var scoreFunction = functionScoreType switch + { + "add" => Builders.ScoreFunction.Add(Constant(1), Constant(2)), + "constant" => Constant(1), + "gauss" => Builders.ScoreFunction.Gauss(x => x.Score, 100, 1, 0.1, 1), + "log" => Builders.ScoreFunction.Log(Constant(1)), + "log1p" => Builders.ScoreFunction.Log1p(Constant(1)), + "multiply" => Builders.ScoreFunction.Multiply(Constant(1), Constant(2)), + "path" => Builders.ScoreFunction.Path(x => x.Score, 1), + "relevance" => Builders.ScoreFunction.Relevance(), + _ => throw new ArgumentOutOfRangeException(nameof(functionScoreType), functionScoreType, "Invalid score function") + }; + + var result = SearchSingle(Builders.Search.Phrase( + "life, liberty, and the pursuit of happiness", + x => x.Body, + score: Builders.Score.Function(scoreFunction))); + + result.Title.Should().Be("Declaration of Independence"); + + ScoreFunction Constant(double value) => + Builders.ScoreFunction.Constant(value); + } + + [Fact] + public void GeoShape() + { + var results = GeoSearch(GeoBuilders.Search.GeoShape( + __testPolygon, + x => x.Address.Location, + GeoShapeRelation.Intersects)); + + results.Count.Should().Be(25); + results.First().Name.Should().Be("Ribeira Charming Duplex"); + } + + [Theory] + [InlineData("box")] + [InlineData("circle")] + [InlineData("polygon")] + public void GeoWithin(string geometryType) + { + GeoWithin geoWithin = geometryType switch + { + "box" => __testBox, + "circle" => __testCircle, + "polygon" => new GeoWithinGeometry(__testPolygon), + _ => throw new ArgumentOutOfRangeException(nameof(geometryType), geometryType, "Invalid geometry type") + }; + + var results = GeoSearch(GeoBuilders.Search.GeoWithin(geoWithin, x => x.Address.Location)); + + results.Count.Should().Be(25); + results.First().Name.Should().Be("Ribeira Charming Duplex"); + } + + [Fact] + public void MoreLikeThis() + { + var likeThisDocument = new HistoricalDocument + { + Title = "Declaration of Independence", + Body = "We hold these truths to be self-evident that all men are created equal..." + }; + var result = SearchSingle(Builders.Search.MoreLikeThis(likeThisDocument)); + + result.Title.Should().Be("Declaration of Independence"); + } + + [Fact] + public void Must() + { + var result = SearchSingle(Builders.Search.Compound().Must( + Builders.Search.Phrase("life, liberty", x => x.Body), + Builders.Search.Wildcard("happ*", x => x.Body, true))); + + result.Title.Should().Be("Declaration of Independence"); + } + + [Fact] + public void MustNot() + { + var result = SearchSingle(Builders.Search.Compound() + .MustNot(Builders.Search.Phrase("life, liberty", x => x.Body))); + + result.Title.Should().Be("US Constitution"); + } + + [Fact] + public void Near() + { + var results = GetGeoTestCollection().Aggregate() + .Search(GeoBuilders.Search.Near(x => x.Address.Location, __testCircle.Center, 1000)) + .Limit(1) + .ToList(); + + results.Should().ContainSingle().Which.Name.Should().Be("Ribeira Charming Duplex"); + } + + [Fact] + public void Phrase() + { + // This test case exercises the indexName and returnStoredSource arguments. The + // remaining test cases omit them. + var coll = GetTestCollection(); + var results = GetTestCollection().Aggregate() + .Search(Builders.Search.Phrase("life, liberty, and the pursuit of happiness", x => x.Body), + new HighlightOptions(x => x.Body), + indexName: "default", + returnStoredSource: true) + .Limit(1) + .Project(Builders.Projection + .Include(x => x.Title) + .Include(x => x.Body) + .MetaSearchScore("score") + .MetaSearchHighlights("highlights")) + .ToList(); + + var result = results.Should().ContainSingle().Subject; + result.Title.Should().Be("Declaration of Independence"); + result.Score.Should().NotBe(0); + + var highlightTexts = result.Highlights.Should().ContainSingle().Subject.Texts; + highlightTexts.Should().HaveCount(15); + + foreach (var highlight in highlightTexts) + { + var expectedType = char.IsLetter(highlight.Value[0]) ? HighlightTextType.Hit : HighlightTextType.Text; + highlight.Type.Should().Be(expectedType); + } + + var highlightRangeStr = string.Join(string.Empty, highlightTexts.Skip(1).Select(x => x.Value)); + highlightRangeStr.Should().Be("Life, Liberty and the pursuit of Happiness."); + } + + [Fact] + public void PhraseMultiPath() + { + var result = SearchSingle(Builders.Search.Phrase( + "life, liberty, and the pursuit of happiness", + Builders.Path.Multi(x => x.Title, x => x.Body))); + + result.Title.Should().Be("Declaration of Independence"); + } + + [Fact] + public void PhraseAnalyzerPath() + { + var result = SearchSingle(Builders.Search.Phrase( + "life, liberty, and the pursuit of happiness", + Builders.Path.Analyzer(x => x.Body, "english"))); + + result.Title.Should().Be("Declaration of Independence"); + } + + [Fact] + public void PhraseWildcardPath() + { + var result = SearchSingle(Builders.Search.Phrase( + "life, liberty, and the pursuit of happiness", + Builders.Path.Wildcard("b*"))); + + result.Title.Should().Be("Declaration of Independence"); + } + + [Fact] + public void QueryString() + { + var result = SearchSingle(Builders.Search.QueryString(x => x.Body, "life, liberty, and the pursuit of happiness")); + + result.Title.Should().Be("Declaration of Independence"); + } + + [Fact] + public void Range() + { + var results = GeoSearch(GeoBuilders.Search.Compound().Must( + GeoBuilders.Search.Range(SearchRangeBuilder.Gt(2).Lt(4), x => x.Bedrooms), + GeoBuilders.Search.Range(SearchRangeBuilder.Gte(14).Lte(14), x => x.Beds))); + + results.Should().ContainSingle().Which.Name.Should().Be("House close to station & direct to opera house...."); + } + + [Fact] + public void Search_count_lowerBound() + { + var results = GetTestCollection().Aggregate() + .Search( + Builders.Search.Phrase("life, liberty, and the pursuit of happiness", x => x.Body), + count: new SearchCountOptions() + { + Type = SearchCountType.LowerBound, + Threshold = 128 + }) + .Project(Builders.Projection.SearchMeta(x => x.MetaResult)) + .Limit(1) + .ToList(); + results.Should().ContainSingle().Which.MetaResult.Count.LowerBound.Should().Be(108); + } + + [Fact] + public void SearchMeta_count() + { + var result = GetTestCollection().Aggregate() + .SearchMeta( + Builders.Search.Phrase("life, liberty, and the pursuit of happiness", x => x.Body), + "default", + new SearchCountOptions() { Type = SearchCountType.Total }) + .Single(); + + result.Should().NotBeNull(); + result.Count.Should().NotBeNull(); + result.Count.Total.Should().Be(108); + } + + [Fact] + public void SearchMeta_facet() + { + var result = GetTestCollection().Aggregate() + .SearchMeta(Builders.Search.Facet( + Builders.Search.Phrase("life, liberty, and the pursuit of happiness", x => x.Body), + Builders.Facet.String("string", x => x.Author, 100), + Builders.Facet.Number("number", x => x.Index, 0, 100), + Builders.Facet.Date("date", x => x.Date, DateTime.MinValue, DateTime.MaxValue))) + .Single(); + + result.Should().NotBeNull(); + result.Facet.Should().NotBeNull().And.ContainKeys("date", "number", "string"); + + var bucket = result.Facet["string"].Buckets.Should().NotBeNull().And.ContainSingle().Subject; + bucket.Id.Should().Be((BsonString)"machine"); + bucket.Count.Should().Be(108); + + bucket = result.Facet["number"].Buckets.Should().NotBeNull().And.ContainSingle().Subject; + bucket.Id.Should().Be((BsonInt32)0); + bucket.Count.Should().Be(0); + + bucket = result.Facet["date"].Buckets.Should().NotBeNull().And.ContainSingle().Subject; + bucket.Id.Should().Be((BsonDateTime)DateTime.MinValue); + bucket.Count.Should().Be(108); + } + + [Fact] + public void Should() + { + var result = SearchSingle(Builders.Search.Compound() + .Should(Builders.Search.Phrase("life, liberty", x => x.Body), + Builders.Search.Wildcard("happ*", x => x.Body, true)) + .MinimumShouldMatch(2)); + result.Title.Should().Be("Declaration of Independence"); + } + + [Theory] + [InlineData("first")] + [InlineData("near")] + [InlineData("or")] + [InlineData("subtract")] + public void Span(string spanType) + { + var spanDefinition = spanType switch + { + "first" => Builders.Span.First(Term("happiness"), 250), + "near" => Builders.Span.Near(new[] { Term("life"), Term("liberty"), Term("pursuit"), Term("happiness") }, 3, true), + "or" => Builders.Span.Or(Term("unalienable"), Term("inalienable")), + "subtract" => Builders.Span.Subtract(Term("unalienable"), Term("inalienable")), + _ => throw new ArgumentOutOfRangeException(nameof(spanType), spanType, "Invalid span type") + }; + + var result = SearchSingle(Builders.Search.Span(spanDefinition)); + result.Title.Should().Be("Declaration of Independence"); + + SpanDefinition Term(string term) => Builders.Span.Term(term, x => x.Body); + } + + [Fact] + public void Text() + { + var result = SearchSingle(Builders.Search.Text("life, liberty, and the pursuit of happiness", x => x.Body)); + + result.Title.Should().Be("Declaration of Independence"); + } + + [Fact] + public void Wildcard() + { + var result = SearchSingle(Builders.Search.Wildcard("tranquil*", x => x.Body, true)); + + result.Title.Should().Be("US Constitution"); + } + + private List GeoSearch(SearchDefinition searchDefintion) => + GetGeoTestCollection().Aggregate().Search(searchDefintion).ToList(); + + private HistoricalDocument SearchSingle(SearchDefinition searchDefintion) => + GetTestCollection().Aggregate().Search(searchDefintion) + .Limit(1) + .ToList() + .Single(); + + private IMongoCollection GetTestCollection() => _disposableMongoClient + .GetDatabase("sample_training") + .GetCollection("posts"); + + private IMongoCollection GetGeoTestCollection() => _disposableMongoClient + .GetDatabase("sample_airbnb") + .GetCollection("listingsAndReviews"); + + [BsonIgnoreExtraElements] + public class HistoricalDocument + { + [BsonId] + public ObjectId Id { get; set; } + + [BsonElement("body")] + public string Body { get; set; } + + [BsonElement("author")] + public string Author { get; set; } + + [BsonElement("title")] + public string Title { get; set; } + + [BsonElement("highlights")] + public List Highlights { get; set; } + + [BsonElement("score")] + public double Score { get; set; } + + [BsonElement("date")] + public DateTime Date { get; set; } + + [BsonElement("index")] + public int Index { get; set; } + + [BsonElement("metaResult")] + public SearchMetaResult MetaResult { get; set; } + } + + [BsonIgnoreExtraElements] + public class Address + { + [BsonElement("location")] + public GeoJsonObject Location { get; set; } + + [BsonElement("street")] + public string Street { get; set; } + } + + [BsonIgnoreExtraElements] + public class AirbnbListing + { + [BsonElement("address")] + public Address Address { get; set; } + + [BsonElement("bedrooms")] + public int Bedrooms { get; set; } + + [BsonElement("beds")] + public int Beds { get; set; } + + [BsonElement("description")] + public string Description { get; set; } + + [BsonElement("space")] + public string Space { get; set; } + + [BsonElement("name")] + public string Name { get; set; } + } + } +} From 150dd8a0c2f935468831cc6ffadafd3a98d839b8 Mon Sep 17 00:00:00 2001 From: BorisDog Date: Fri, 6 Jan 2023 15:29:24 -0800 Subject: [PATCH 21/21] - PR comments --- evergreen/run-atlas-search-test.sh | 3 + src/MongoDB.Driver/Search/Highlight.cs | 27 +++-- .../Search/AtlasSearchTest.cs | 111 ++++++++++-------- 3 files changed, 80 insertions(+), 61 deletions(-) diff --git a/evergreen/run-atlas-search-test.sh b/evergreen/run-atlas-search-test.sh index 1e55b90feea..1ca936d24de 100644 --- a/evergreen/run-atlas-search-test.sh +++ b/evergreen/run-atlas-search-test.sh @@ -3,6 +3,9 @@ set -o xtrace set -o errexit # Exit the script with error if any of the commands fail +# Environment variables produced as output +# ATLAS_SEARCH_TESTS_ENABLED Enable atlas search tests. + ############################################ # Main Program # ############################################ diff --git a/src/MongoDB.Driver/Search/Highlight.cs b/src/MongoDB.Driver/Search/Highlight.cs index 6b453a15d15..33efa5124ad 100644 --- a/src/MongoDB.Driver/Search/Highlight.cs +++ b/src/MongoDB.Driver/Search/Highlight.cs @@ -1,16 +1,17 @@ -// Copyright 2010-present MongoDB Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* Copyright 2010-present MongoDB Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; diff --git a/tests/MongoDB.Driver.Tests/Search/AtlasSearchTest.cs b/tests/MongoDB.Driver.Tests/Search/AtlasSearchTest.cs index 50b217339d9..707c95e96f6 100644 --- a/tests/MongoDB.Driver.Tests/Search/AtlasSearchTest.cs +++ b/tests/MongoDB.Driver.Tests/Search/AtlasSearchTest.cs @@ -1,16 +1,17 @@ -// Copyright 2010-present MongoDB Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* Copyright 2010-present MongoDB Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ using System; using System.Collections.Generic; @@ -34,6 +35,8 @@ namespace MongoDB.Driver.Tests.Search [Trait("Category", "AtlasSearch")] public class AtlasSearchTest : LoggableTestClass { + #region static + private static readonly GeoJsonPolygon __testPolygon = new(new(new(new GeoJson2DGeographicCoordinates[] { @@ -50,6 +53,8 @@ public class AtlasSearchTest : LoggableTestClass private static readonly GeoWithinCircle __testCircle = new(new(new(-8.61308, 41.1413)), 273); + #endregion + private readonly DisposableMongoClient _disposableMongoClient; public AtlasSearchTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper) @@ -62,8 +67,7 @@ public AtlasSearchTest(ITestOutputHelper testOutputHelper) : base(testOutputHelp _disposableMongoClient = new(new MongoClient(atlasSearchUri), CreateLogger()); } - protected override void DisposeInternal() => - _disposableMongoClient.Dispose(); + protected override void DisposeInternal() => _disposableMongoClient.Dispose(); [Fact] public void Autocomplete() @@ -103,8 +107,9 @@ public void Count_total() [Fact] public void Exists() { - var result = SearchSingle(Builders.Search.Compound() - .Must(Builders.Search.Text("life, liberty, and the pursuit of happiness", x => x.Body), + var result = SearchSingle( + Builders.Search.Compound().Must( + Builders.Search.Text("life, liberty, and the pursuit of happiness", x => x.Body), Builders.Search.Exists(x => x.Title))); result.Title.Should().Be("Declaration of Independence"); @@ -113,9 +118,10 @@ public void Exists() [Fact] public void Filter() { - var result = SearchSingle(Builders.Search.Compound().Filter( - Builders.Search.Phrase("life, liberty", x => x.Body), - Builders.Search.Wildcard("happ*", x => x.Body, true))); + var result = SearchSingle( + Builders.Search.Compound().Filter( + Builders.Search.Phrase("life, liberty", x => x.Body), + Builders.Search.Wildcard("happ*", x => x.Body, true))); result.Title.Should().Be("Declaration of Independence"); } @@ -158,10 +164,11 @@ public void FunctionScore(string functionScoreType) [Fact] public void GeoShape() { - var results = GeoSearch(GeoBuilders.Search.GeoShape( - __testPolygon, - x => x.Address.Location, - GeoShapeRelation.Intersects)); + var results = GeoSearch( + GeoBuilders.Search.GeoShape( + __testPolygon, + x => x.Address.Location, + GeoShapeRelation.Intersects)); results.Count.Should().Be(25); results.First().Name.Should().Be("Ribeira Charming Duplex"); @@ -203,9 +210,10 @@ public void MoreLikeThis() [Fact] public void Must() { - var result = SearchSingle(Builders.Search.Compound().Must( - Builders.Search.Phrase("life, liberty", x => x.Body), - Builders.Search.Wildcard("happ*", x => x.Body, true))); + var result = SearchSingle( + Builders.Search.Compound().Must( + Builders.Search.Phrase("life, liberty", x => x.Body), + Builders.Search.Wildcard("happ*", x => x.Body, true))); result.Title.Should().Be("Declaration of Independence"); } @@ -213,9 +221,9 @@ public void Must() [Fact] public void MustNot() { - var result = SearchSingle(Builders.Search.Compound() - .MustNot(Builders.Search.Phrase("life, liberty", x => x.Body))); - + var result = SearchSingle( + Builders.Search.Compound().MustNot( + Builders.Search.Phrase("life, liberty", x => x.Body))); result.Title.Should().Be("US Constitution"); } @@ -269,9 +277,10 @@ public void Phrase() [Fact] public void PhraseMultiPath() { - var result = SearchSingle(Builders.Search.Phrase( - "life, liberty, and the pursuit of happiness", - Builders.Path.Multi(x => x.Title, x => x.Body))); + var result = SearchSingle( + Builders.Search.Phrase( + "life, liberty, and the pursuit of happiness", + Builders.Path.Multi(x => x.Title, x => x.Body))); result.Title.Should().Be("Declaration of Independence"); } @@ -279,9 +288,10 @@ public void PhraseMultiPath() [Fact] public void PhraseAnalyzerPath() { - var result = SearchSingle(Builders.Search.Phrase( - "life, liberty, and the pursuit of happiness", - Builders.Path.Analyzer(x => x.Body, "english"))); + var result = SearchSingle( + Builders.Search.Phrase( + "life, liberty, and the pursuit of happiness", + Builders.Path.Analyzer(x => x.Body, "english"))); result.Title.Should().Be("Declaration of Independence"); } @@ -289,9 +299,10 @@ public void PhraseAnalyzerPath() [Fact] public void PhraseWildcardPath() { - var result = SearchSingle(Builders.Search.Phrase( - "life, liberty, and the pursuit of happiness", - Builders.Path.Wildcard("b*"))); + var result = SearchSingle( + Builders.Search.Phrase( + "life, liberty, and the pursuit of happiness", + Builders.Path.Wildcard("b*"))); result.Title.Should().Be("Declaration of Independence"); } @@ -307,9 +318,10 @@ public void QueryString() [Fact] public void Range() { - var results = GeoSearch(GeoBuilders.Search.Compound().Must( - GeoBuilders.Search.Range(SearchRangeBuilder.Gt(2).Lt(4), x => x.Bedrooms), - GeoBuilders.Search.Range(SearchRangeBuilder.Gte(14).Lte(14), x => x.Beds))); + var results = GeoSearch( + GeoBuilders.Search.Compound().Must( + GeoBuilders.Search.Range(SearchRangeBuilder.Gt(2).Lt(4), x => x.Bedrooms), + GeoBuilders.Search.Range(SearchRangeBuilder.Gte(14).Lte(14), x => x.Beds))); results.Should().ContainSingle().Which.Name.Should().Be("House close to station & direct to opera house...."); } @@ -376,8 +388,9 @@ public void SearchMeta_facet() [Fact] public void Should() { - var result = SearchSingle(Builders.Search.Compound() - .Should(Builders.Search.Phrase("life, liberty", x => x.Body), + var result = SearchSingle( + Builders.Search.Compound().Should( + Builders.Search.Phrase("life, liberty", x => x.Body), Builders.Search.Wildcard("happ*", x => x.Body, true)) .MinimumShouldMatch(2)); result.Title.Should().Be("Declaration of Independence"); @@ -425,10 +438,12 @@ public void Wildcard() GetGeoTestCollection().Aggregate().Search(searchDefintion).ToList(); private HistoricalDocument SearchSingle(SearchDefinition searchDefintion) => - GetTestCollection().Aggregate().Search(searchDefintion) - .Limit(1) - .ToList() - .Single(); + GetTestCollection() + .Aggregate() + .Search(searchDefintion) + .Limit(1) + .ToList() + .Single(); private IMongoCollection GetTestCollection() => _disposableMongoClient .GetDatabase("sample_training")