Line data Source code
1 : using System;
2 : using Cqrs.Cache;
3 : using Cqrs.Authentication;
4 : using Cqrs.Tests.Substitutes;
5 : using NUnit.Framework;
6 :
7 : namespace Cqrs.Tests.Cache
8 : {
9 : [TestFixture]
10 : public class When_getting_aggregate
11 0 : {
12 : private CacheRepository<ISingleSignOnToken> _rep;
13 : private TestAggregate _aggregate;
14 :
15 : [SetUp]
16 0 : public void Setup()
17 : {
18 : _rep = new CacheRepository<ISingleSignOnToken>(new TestRepository(), new TestEventStore());
19 : _aggregate = _rep.Get<TestAggregate>(Guid.NewGuid());
20 : }
21 :
22 : [Test]
23 0 : public void Should_get_aggregate()
24 : {
25 : Assert.That(_aggregate, Is.Not.Null);
26 : }
27 :
28 : [Test]
29 0 : public void Should_get_same_aggregate_on_second_try()
30 : {
31 : var aggregate =_rep.Get<TestAggregate>(_aggregate.Id);
32 : Assert.That(aggregate, Is.EqualTo(_aggregate));
33 : }
34 :
35 : [Test]
36 0 : public void Should_update_if_version_changed_in_event_store()
37 : {
38 : var aggregate = _rep.Get<TestAggregate>(_aggregate.Id);
39 : Assert.That(aggregate.Version, Is.EqualTo(4));
40 : }
41 :
42 : [Test]
43 0 : public void Should_get_same_aggregate_from_different_cache_repository()
44 : {
45 : var rep = new CacheRepository<ISingleSignOnToken>(new TestRepository(), new TestInMemoryEventStore());
46 : var aggregate = rep.Get<TestAggregate>(_aggregate.Id);
47 : Assert.That(aggregate, Is.EqualTo(_aggregate));
48 : }
49 : }
50 : }
|