Line data Source code
1 : using System;
2 : using cdmdotnet.Logging;
3 : using Cqrs.Domain;
4 : using Cqrs.Domain.Factories;
5 : using Cqrs.Authentication;
6 : using Cqrs.Snapshots;
7 : using Cqrs.Tests.Substitutes;
8 : using NUnit.Framework;
9 :
10 : namespace Cqrs.Tests.Snapshots
11 : {
12 : [TestFixture]
13 : public class When_getting_snapshotable_aggreate
14 0 : {
15 : private TestSnapshotStore _snapshotStore;
16 : private TestSnapshotAggregate _aggregate;
17 :
18 : [SetUp]
19 0 : public void Setup()
20 : {
21 : var eventStore = new TestInMemoryEventStore();
22 : var eventPublisher = new TestEventPublisher();
23 : _snapshotStore = new TestSnapshotStore();
24 : var snapshotStrategy = new DefaultSnapshotStrategy<ISingleSignOnToken>();
25 : var dependencyResolver = new TestDependencyResolver(null);
26 : var aggregateFactory = new AggregateFactory(dependencyResolver, dependencyResolver.Resolve<ILogger>());
27 : var repository = new SnapshotRepository<ISingleSignOnToken>(_snapshotStore, snapshotStrategy, new AggregateRepository<ISingleSignOnToken>(aggregateFactory, eventStore, eventPublisher, new NullCorrelationIdHelper()), eventStore, aggregateFactory);
28 : var session = new UnitOfWork<ISingleSignOnToken>(repository);
29 :
30 : _aggregate = session.Get<TestSnapshotAggregate>(Guid.NewGuid());
31 : }
32 :
33 : [Test]
34 0 : public void Should_ask_for_snapshot()
35 : {
36 : Assert.True(_snapshotStore.VerifyGet);
37 : }
38 :
39 : [Test]
40 0 : public void Should_run_restore_method()
41 : {
42 : Assert.True(_aggregate.Restored);
43 : }
44 : }
45 : }
|