public void WildcardsAreReplaced() { var whereArguments = "Date.BatchId LIKE '%abc%'"; var stage = FilterDefinitionBuilder.Build <BsonDocument>(whereArguments); Assert.That(stage.Json.Contains("%abc%"), Is.False); }
public void PipelineDefinitionCanBeBuild(string whereArguments) { JsonPipelineStageDefinition <BsonDocument, BsonDocument> stage = null; Assert.That(() => stage = FilterDefinitionBuilder.Build <BsonDocument>(whereArguments), Throws.Nothing); Assert.That(stage, Is.Not.Null); }
public void LikeClauseCanHandleRegexCharacters() { var whereArguments = "Data.BatchId LIKE '%|%'"; JsonPipelineStageDefinition <BsonDocument, BsonDocument> stage = null; Assert.That(() => stage = FilterDefinitionBuilder.Build <BsonDocument>(whereArguments), Throws.Nothing); Assert.That(stage.Json.Contains(".*\\\\|.*")); }
public void PipelineDefinitionAsExpected(string whereArguments, string expected) { JsonPipelineStageDefinition <BsonDocument, BsonDocument> stage = null; Assert.That(() => stage = FilterDefinitionBuilder.Build <BsonDocument>(whereArguments), Throws.Nothing); Assert.That(stage, Is.Not.Null); Assert.That(stage.Json, Is.EqualTo(expected)); }
public void InvalidParenthesesCountCausesException() { var whereArguments = "(timestamp > '2018-01-01' AND (name = 'Test' || Id = 123)"; // Missing final parenthesis Assert.That(() => FilterDefinitionBuilder.Build <BsonDocument>(whereArguments), Throws.Exception.TypeOf <FormatException>()); }
public void KeywordsInsideFieldNamesAreNotDetected(string whereArguments) { Assert.That(() => FilterDefinitionBuilder.Build <BsonDocument>(whereArguments), Throws.InstanceOf <FormatException>()); }