Baustein 9: Konflikt-Review-UI (Kapitel 10)
Minimale Liste im Tab "Synchronisation" - Entitaet, Zeitpunkt, welche Seite ConflictResolver gewaehlt hat, mit "Gesehen"-Aktion. Kein Feld-Diff fuer v1: die Payloads sind clientseitig verschluesselt, ein Diff wuerde ohnehin nur rohes JSON zeigen. Neu EventQueue.MarkReviewed(id) - bisher gab es AddConflict/ GetUnreviewed/ConflictCount, aber keinen Weg, einen Konflikt als gesehen zu markieren. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using LehrerApp.Sync.Models;
|
||||
using Xunit;
|
||||
|
||||
namespace LehrerApp.Sync.Tests;
|
||||
|
||||
public sealed class EventQueueTests
|
||||
{
|
||||
[Fact]
|
||||
public void MarkReviewed_EntferntKonfliktAusDerUnreviewedListe()
|
||||
{
|
||||
using var temp = new TempEventQueue();
|
||||
var conflict = new ConflictEntry
|
||||
{
|
||||
LocalEvent = MakeEvent(),
|
||||
RemoteEvent = MakeEvent(),
|
||||
Resolution = "LocalWon",
|
||||
};
|
||||
temp.Queue.AddConflict(conflict);
|
||||
|
||||
temp.Queue.MarkReviewed(conflict.Id);
|
||||
|
||||
Assert.Empty(temp.Queue.GetUnreviewed());
|
||||
Assert.Equal(0, temp.Queue.ConflictCount());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MarkReviewed_UnbekannteId_TutNichtsUndWirftNicht()
|
||||
{
|
||||
using var temp = new TempEventQueue();
|
||||
|
||||
var exception = Record.Exception(() => temp.Queue.MarkReviewed(Guid.NewGuid()));
|
||||
|
||||
Assert.Null(exception);
|
||||
}
|
||||
|
||||
private static SyncEvent MakeEvent() => new()
|
||||
{
|
||||
DeviceId = "desktop-1",
|
||||
DeviceType = DeviceType.Desktop,
|
||||
EntityType = "Student",
|
||||
EntityId = Guid.NewGuid().ToString(),
|
||||
Operation = "Save",
|
||||
Payload = "{}",
|
||||
};
|
||||
|
||||
private sealed class TempEventQueue : IDisposable
|
||||
{
|
||||
private readonly string _directory = Path.Combine(
|
||||
Path.GetTempPath(), $"lehrerapp-sync-tests-eventqueue-{Guid.NewGuid():N}");
|
||||
public EventQueue Queue { get; }
|
||||
|
||||
public TempEventQueue()
|
||||
{
|
||||
Directory.CreateDirectory(_directory);
|
||||
Queue = new EventQueue(Path.Combine(_directory, "queue.db"));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Queue.Dispose();
|
||||
if (Directory.Exists(_directory)) Directory.Delete(_directory, recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user