Skip to content

Commit

Permalink
Add tests that assert that the new methods work
Browse files Browse the repository at this point in the history
  • Loading branch information
JKamsker committed Jun 4, 2024
1 parent 12a6a08 commit b1e8640
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
70 changes: 70 additions & 0 deletions LiteDB.Tests/Issues/Pull2468_Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using FluentAssertions;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xunit;

using static LiteDB.Tests.Issues.Issue1838_Tests;

namespace LiteDB.Tests.Issues;

public class Pull2468_Tests
{
// tests if lowerinvariant works
[Fact]
public void Supports_LowerInvariant()
{
using var db = new LiteDatabase(":memory:");
var collection = db.GetCollection<TestType>(nameof(TestType));

collection.Insert(new TestType()
{
Foo = "Abc",
Timestamp = DateTimeOffset.UtcNow,
});

collection.Insert(new TestType()
{
Foo = "Def",
Timestamp = DateTimeOffset.UtcNow,
});

var result = collection.Query()
.Where(x => x.Foo.ToLowerInvariant() == "abc")
.ToList();

Assert.NotNull(result);
Assert.Single(result);
}

// tests if upperinvariant works
[Fact]
public void Supports_UpperInvariant()
{
using var db = new LiteDatabase(":memory:");
var collection = db.GetCollection<TestType>(nameof(TestType));

collection.Insert(new TestType()
{
Foo = "Abc",
Timestamp = DateTimeOffset.UtcNow,
});

collection.Insert(new TestType()
{
Foo = "Def",
Timestamp = DateTimeOffset.UtcNow,
});

var result = collection.Query()
.Where(x => x.Foo.ToUpperInvariant() == "ABC")
.ToList();

Assert.NotNull(result);
Assert.Single(result);
}
}
3 changes: 2 additions & 1 deletion LiteDB/Client/Mapper/Linq/TypeResolver/StringResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq.Expressions;
using System.Reflection;
using System.Text;

using static LiteDB.Constants;

namespace LiteDB
Expand Down Expand Up @@ -59,4 +60,4 @@ public string ResolveMember(MemberInfo member)

public string ResolveCtor(ConstructorInfo ctor) => null;
}
}
}

0 comments on commit b1e8640

Please sign in to comment.