-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Issue2487_Tests.cs
41 lines (30 loc) · 1.1 KB
/
Issue2487_Tests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using FluentAssertions;
using Xunit;
namespace LiteDB.Tests.Issues;
public class Issue2487_tests
{
private class DataClass
{
[BsonId]
public int Id { get; set; }
public string Foo { get; set; }
public string Bar { get; set; }
}
[Fact]
public void Test_Contains_EmptyStrings()
{
using var engine = new ConnectionString(":memory:").CreateEngine();
using var db = new LiteDatabase(engine);
var collection = db.GetCollection<DataClass>("data");
collection.Insert(new DataClass { Foo = "bar", Bar = "abc" });
collection.Insert(new DataClass { Foo = " ", Bar = "def" });
collection.Insert(new DataClass { Foo = "fo bar", Bar = "def" });
var containsAction = () => collection.FindOne(x => x.Foo.Contains(" "));
containsAction.Should().NotThrow();
var def = containsAction();
def.Should().NotBeNull();
def.Bar.Should().Be("def");
var shouldExecute = () => engine.Query("data", Query.All(Query.Contains("Foo", " ")));
shouldExecute.Should().NotThrow();
}
}