Наследование: Raven.Client.ContextualListeners.AbstractDocumentStoreListenerContext
        public void Should_use_context()
        {
            using (IDocumentSession session = DocumentStore.OpenSession())
            {
                var doc = new Doc {Id = "Doc", Name = "Name"};
                session.Store(doc);
                session.SaveChanges();
            }

            using (var storeContext = new StoreContext())
            using (var deleteContext = new DeleteContext())
            using (var queryContext = new QueryContext())
            using (var conversionContext = new ConversionContext())
            using (IDocumentSession session = DocumentStore.OpenSession())
            {
                var doc1 = new Doc {Id = "Doc1"};
                session.Store(doc1);
                Doc doc2 =
                    session.Query<Doc>()
                        .Where(d => d.Name == "Name")
                        .Customize(c => c.WaitForNonStaleResults())
                        .Single();
                session.Delete(doc2);
                session.SaveChanges();
                Assert.True(storeContext.AfterStoreCalled);
                Assert.True(storeContext.BeforeStoreCalled);
                Assert.True(deleteContext.BeforeDeleteCalled);
                Assert.True(queryContext.BeforeQueryExecutedCalled);
                Assert.True(conversionContext.DocumentToEntityCalled);
                Assert.True(conversionContext.EntityToDocumentCalled);
            }
        }
 public void Should_use_context()
 {
     using (var context = new StoreContext())
     using (IDocumentSession session = DocumentStore.OpenSession())
     {
         var doc = new Doc {Id = "Doc"};
         session.Store(doc);
         session.SaveChanges();
         Assert.True(context.BeforeStoreCalled);
         Assert.True(context.AfterStoreCalled);
     }
 }
        public void Should_support_nested_sessions()
        {
            using (var context1 = new StoreContext())
            using (IDocumentSession session1 = DocumentStore.OpenSession())
            {
                var doc1 = new Doc {Id = "Doc1"};
                session1.Store(doc1);

                using (var context2 = new StoreContext())
                using (IDocumentSession session2 = DocumentStore.OpenSession())
                {
                    var doc2 = new Doc {Id = "Doc2"};
                    session2.Store(doc2);
                    session2.SaveChanges();
                    Assert.True(context2.BeforeStoreCalled);
                    Assert.True(context2.AfterStoreCalled);
                }

                session1.SaveChanges();
                Assert.True(context1.BeforeStoreCalled);
                Assert.True(context1.AfterStoreCalled);
            }
        }