Line data Source code
1 : using System;
2 : using Cqrs.Authentication;
3 : using Cqrs.Snapshots;
4 :
5 : namespace Cqrs.Tests.Substitutes
6 : {
7 : public class TestSnapshotAggregate : SnapshotAggregateRoot<ISingleSignOnToken, TestSnapshotAggregateSnapshot>
8 0 : {
9 0 : public TestSnapshotAggregate(Guid? id = null)
10 : {
11 : Id = id ?? Guid.NewGuid();
12 : }
13 :
14 : public bool Restored { get; private set; }
15 : public bool Loaded { get; private set; }
16 : public int Number { get; private set; }
17 :
18 0 : protected override TestSnapshotAggregateSnapshot CreateSnapshot()
19 : {
20 : return new TestSnapshotAggregateSnapshot {Number = Number};
21 : }
22 :
23 0 : protected override void RestoreFromSnapshot(TestSnapshotAggregateSnapshot snapshot)
24 : {
25 : Number = snapshot.Number;
26 : Restored = true;
27 : }
28 :
29 : private void Apply(TestAggregateDidSomething e)
30 : {
31 : Loaded = true;
32 : Number++;
33 : }
34 :
35 0 : public void DoSomething()
36 : {
37 : ApplyChange(new TestAggregateDidSomething());
38 : }
39 : }
40 :
41 : public class TestSnapshotAggregateSnapshot : Snapshot
42 0 : {
43 : public int Number { get; set; }
44 : }
45 : }
|