public async Task only_most_recent_snapshot_is_used() { var snap = Setup.Snapshot(3, Guid.NewGuid()); await _store.Store(snap); var snap1 = Setup.Snapshot(4, snap.EntityId); await _store.Store(snap1); var get = await _store.GetData(Config(c => c.OfEntity(snap.EntityId).IncludeSnapshots(true)), _cancellationToken); var mem2 = Utils.UnpackSnapshot(get.Value.LatestSnapshot.Value.SerializedData) as SomeMemento; var mem1 = Utils.UnpackSnapshot(snap1.SerializedData) as SomeMemento; mem2.Name.Should().Be(mem1.Name); mem2.IsOpen.Should().Be(mem1.IsOpen); }
public static Snapshot Snapshot(int ver, Guid entity, string tenant = "_") => new Snapshot(ver, entity, tenant, Utils.PackSnapshot(new Fixture().Create <SomeMemento>()), DateTimeOffset.Now);
public static UnversionedCommit UnversionedCommit(string tenantId = "_", Guid?guid = null) => new UnversionedCommit(tenantId, guid ?? Guid.NewGuid(), Utils.PackEvents(Events(1)), Guid.NewGuid(), DateTimeOffset.Now);
public static IEnumerable <object> GetEvents(this Commit commit, IReadOnlyDictionary <Type, IMapEventDataToObject> upc) { return(Utils.UnpackEvents(commit.Timestamp, commit.EventData, upc)); }
public static IEnumerable <Commit> Commits <T, V>(int count) where T : class, new() where V : class, new() { return(Enumerable.Range(1, count) .Select(i => new Commit("_", Setup.EntityId, Utils.PackEvents(new Object[] { new T(), new V() }), Guid.NewGuid(), DateTimeOffset.Now, i))); }
public static Commit Commit(params object[] events) => new Commit("_", Guid.NewGuid(), Utils.PackEvents(events), Guid.NewGuid(), DateTimeOffset.Now, 1);