Path: redb/redb.Tests.Integration/Tests/Base/SqliteRowMapperTestsBase.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Base/SqliteRowMapperTestsBase.cs
----
using redb.Core;
using redb.Core.Models.Entities;
namespace redb.Tests.Integration.Tests.Base;
///
/// The SQLite row mapper (review SL-57). A column value that did not convert to the property type went through two
/// silent catches and the property kept its default - a row read as if the column were NULL. SQLite's dynamic typing
/// lets any column hold text, so such a row is one bad write away. Free and Pro share the connection.
///
public abstract class SqliteRowMapperTestsBase
{
protected readonly IRedbService Redb;
protected SqliteRowMapperTestsBase(IRedbService redb) => Redb = redb;
[Fact]
public async Task AColumnValueThatDoesNotConvert_IsRefused()
{
var read = async () => await Redb.Context.QueryFirstOrDefaultAsync("SELECT 'abc' AS _value_long");
await read.Should().ThrowAsync().WithMessage("*_value_long*abc*");
}
[Fact]
public async Task AColumnValueThatConverts_IsRead()
{
var row = await Redb.Context.QueryFirstOrDefaultAsync("SELECT 42 AS _value_long, 'x' AS _name");
row!.ValueLong.Should().Be(42);
}
}