Merge claudedo/1891227787ae4085a52c112bd1dcd75a
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using ClaudeDo.Data.Filtering.Filters;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TaskStatus = ClaudeDo.Data.Models.TaskStatus;
|
||||
|
||||
namespace ClaudeDo.Data.Tests.Filtering;
|
||||
|
||||
/// <summary>
|
||||
/// Proves that <see cref="ClaudeDo.Data.Filtering.ITaskListFilter.MatchExpression"/> is a real
|
||||
/// expression tree that EF Core can translate into SQL, not just an in-memory delegate — the
|
||||
/// whole point of splitting it out from <c>Matches</c>.
|
||||
/// </summary>
|
||||
public sealed class MatchExpressionSqlTests : IDisposable
|
||||
{
|
||||
private readonly string _dbPath;
|
||||
private readonly DbContextOptions<ClaudeDoDbContext> _options;
|
||||
|
||||
public MatchExpressionSqlTests()
|
||||
{
|
||||
_dbPath = Path.Combine(Path.GetTempPath(), $"claudedo_matchexpr_{Guid.NewGuid():N}.db");
|
||||
_options = new DbContextOptionsBuilder<ClaudeDoDbContext>()
|
||||
.UseSqlite($"Data Source={_dbPath}")
|
||||
.Options;
|
||||
|
||||
using var ctx = new ClaudeDoDbContext(_options);
|
||||
ctx.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var suffix in new[] { "", "-wal", "-shm" })
|
||||
try { File.Delete(_dbPath + suffix); } catch { }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StatusFilter_MatchExpression_translates_to_a_SQL_WHERE_on_status()
|
||||
{
|
||||
var filter = new StatusFilter("virtual:queued", TaskStatus.Queued);
|
||||
|
||||
using var ctx = new ClaudeDoDbContext(_options);
|
||||
var sql = ctx.Tasks.Where(filter.MatchExpression).ToQueryString();
|
||||
|
||||
Assert.Contains("WHERE", sql, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("status", sql, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UserListFilter_MatchExpression_translates_to_a_SQL_WHERE_on_list_id()
|
||||
{
|
||||
var filter = new UserListFilter("abc");
|
||||
|
||||
using var ctx = new ClaudeDoDbContext(_options);
|
||||
var sql = ctx.Tasks.Where(filter.MatchExpression).ToQueryString();
|
||||
|
||||
Assert.Contains("WHERE", sql, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains("list_id", sql, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using ClaudeDo.Data.Models;
|
||||
using ClaudeDo.Ui.ViewModels.Islands;
|
||||
using Xunit;
|
||||
@@ -20,4 +21,25 @@ public class TaskRowViewModelTests
|
||||
vm.Status = s;
|
||||
Assert.Equal(expected, vm.StatusChipClass);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsDropTarget_Follows_Either_DropHint_And_Raises_PropertyChanged()
|
||||
{
|
||||
var vm = new TaskRowViewModel { Id = "t" };
|
||||
var raised = new List<string?>();
|
||||
vm.PropertyChanged += (_, e) => raised.Add(e.PropertyName);
|
||||
|
||||
Assert.False(vm.IsDropTarget);
|
||||
|
||||
vm.DropHintAbove = true;
|
||||
Assert.True(vm.IsDropTarget);
|
||||
Assert.Contains(nameof(TaskRowViewModel.IsDropTarget), raised);
|
||||
|
||||
vm.DropHintAbove = false;
|
||||
vm.DropHintBelow = true;
|
||||
Assert.True(vm.IsDropTarget);
|
||||
|
||||
vm.DropHintBelow = false;
|
||||
Assert.False(vm.IsDropTarget);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user