Example #1
0
        public When_evicting_cache_entry()
        {
            _cache     = new TestMemoryCache();
            _rep       = new CacheRepository(new TestRepository(), new TestEventStore(), _cache);
            _aggregate = _rep.Get <TestAggregate>(Guid.NewGuid()).Result;
            var field = _rep.GetType().GetField("_locks", BindingFlags.Static | BindingFlags.NonPublic);

            _locks = (ConcurrentDictionary <Guid, SemaphoreSlim>)field.GetValue(_rep);
            _cache.Remove(_aggregate.Id);
        }
        public When_evicting_cache_entry()
        {
            _cache     = new MemoryCache();
            _rep       = new CacheRepository(new TestRepository(), new TestEventStore(), _cache);
            _aggregate = _rep.Get <TestAggregate>(Guid.NewGuid()).Result;
            var field = _rep.GetType().GetField("_locks", BindingFlags.Static | BindingFlags.NonPublic);

            _locks = (ConcurrentDictionary <Guid, ManualResetEvent>)field.GetValue(_rep);
            _locks.TryGetValue(_aggregate.Id, out var resetEvent);
            _cache.Remove(_aggregate.Id);
            resetEvent.WaitOne(500);
        }