Line data Source code
1 : using System;
2 : using System.Runtime.Caching;
3 : using Cqrs.Cache;
4 : using Cqrs.Authentication;
5 : using Cqrs.Tests.Substitutes;
6 : using NUnit.Framework;
7 :
8 : namespace Cqrs.Tests.Cache
9 : {
10 : [TestFixture]
11 : public class When_saving_fails
12 0 : {
13 : private CacheRepository<ISingleSignOnToken> _rep;
14 : private TestAggregate _aggregate;
15 : private TestAggregateRepository _testRep;
16 :
17 : [SetUp]
18 0 : public void Setup()
19 : {
20 : _testRep = new TestAggregateRepository();
21 : _rep = new CacheRepository<ISingleSignOnToken>(_testRep, new TestInMemoryEventStore());
22 : _aggregate = _testRep.Get<TestAggregate>(Guid.NewGuid());
23 : _aggregate.DoSomething();
24 : try
25 : {
26 : _rep.Save(_aggregate, 100);
27 : }
28 : catch (Exception){}
29 : }
30 :
31 : [Test]
32 0 : public void Should_evict_old_object_from_cache()
33 : {
34 : var aggregate = MemoryCache.Default.Get(_aggregate.Id.ToString());
35 : Assert.That(aggregate, Is.Null);
36 : }
37 : }
38 : }
|