コード例 #1
0
        public DocumentStoreTests()
        {
            var configuration = MockBuilder.BuildConfiguration();

            var documentSessionFactory = new DocumentSessionFactory(new Raven.Client.Documents.DocumentStore
            {
                Urls = new[] { configuration.DocumentStore.Url }
            },
                                                                    new NullLogger(),
                                                                    false);

            _documentStore = new DocumentStore(documentSessionFactory, new Raven.Client.Documents.DocumentStore());
            _documentStore.SetSession("Tests");
        }
コード例 #2
0
        public RavenDbSagaPersisterTests()
        {
            var documentStore = new Raven.Client.Client.EmbeddableDocumentStore { RunInMemory = true };
            documentStore.Initialize();

            //var documentStore = new Raven.Client.Document.DocumentStore {Url = "http://localhost:8080"};
            //documentStore.Initialize();

            //IDocumentSessionFactory documentSessionFactory = new DocumentSessionFactory(embeddableDocumentStore);
            IDocumentSessionFactory documentSessionFactory = new DocumentSessionFactory(documentStore);

            SagaPersister = new SagaPersister
            {
                DocumentSessionFactory = documentSessionFactory
            };
        }
コード例 #3
0
        public RavenDbSagaPersisterTests()
        {
            var documentStore = new Raven.Client.Client.EmbeddableDocumentStore {
                RunInMemory = true
            };

            documentStore.Initialize();

            //var documentStore = new Raven.Client.Document.DocumentStore {Url = "http://localhost:8080"};
            //documentStore.Initialize();

            //IDocumentSessionFactory documentSessionFactory = new DocumentSessionFactory(embeddableDocumentStore);
            IDocumentSessionFactory documentSessionFactory = new DocumentSessionFactory(documentStore);

            SagaPersister = new SagaPersister
            {
                DocumentSessionFactory = documentSessionFactory
            };
        }
コード例 #4
0
        public void Initialize()
        {
            var documentStore = GetSession(out IDocumentSession documentSession);

            _contextId = Guid.NewGuid();

            var testContext2 = new TestContext2
            {
                ContextId     = _contextId,
                AssertContent = "My-Init-Test-Content"
            };

            testContext2.Claims.Add(new UserClaim {
                Type = "CustomType", Value = "CustomValue"
            });

            var entity = new User
            {
                Username = "******",
                Id       = null,
                Contexts = new List <Context> {
                    new Context {
                        Id      = testContext2.ContextId.ToString(),
                        Claims  = testContext2.Claims,
                        Content = JsonConvert.SerializeObject(testContext2),
                        Type    = testContext2.GetType().FullName
                    }
                }
            };

            documentSession.Store(entity);
            documentSession.SaveChanges();

            _testUserId             = entity.Id;
            _documentSessionFactory = new DocumentSessionFactory(documentStore, new NullLogger(), false);
            _userContextService     = new UserContextService(new DocumentStore(_documentSessionFactory, new Raven.Client.Documents.DocumentStore()));
        }
コード例 #5
0
        public void RobTheBank(string storeFilename)
        {
            var swFull = new Stopwatch();

            swFull.Start();
            using (DocumentSession session = DocumentSessionFactory.Create(storeFilename))
            {
                var sw = new Stopwatch();
                sw.Start();
                for (int i = 0; i < EventCount; i++)
                {
                    session.Store(i.ToString(), new NumericDocument
                    {
                        Number = i
                    });
                }
                sw.Stop();

                Console.WriteLine("10k inserts: {0}ms", sw.ElapsedMilliseconds);
            }
            swFull.Stop();
            Console.WriteLine("Spin up, insert, and shutdown: {0}ms", swFull.ElapsedMilliseconds);

            swFull.Reset();
            swFull.Start();
            using (DocumentSession session = DocumentSessionFactory.Create(storeFilename))
            {
                var sw = new Stopwatch();
                sw.Start();
                for (int i = 0; i < EventCount; i++)
                {
                    var document = session.Retrieve <NumericDocument>(i.ToString());
                    Assert.That(document, Is.Not.Null, "Document not found for record {0}".FormatWith(i));
                    int result = document.Number;

                    Assert.That(result, Is.EqualTo(i));
                }

                sw.Stop();

                Console.WriteLine("10k reads: {0}ms", sw.ElapsedMilliseconds);
            }
            swFull.Stop();
            Console.WriteLine("Spin up, assert each, and shutdown: {0}ms", swFull.ElapsedMilliseconds);

            swFull.Reset();
            swFull.Start();
            using (DocumentSession session = DocumentSessionFactory.Create(storeFilename))
            {
                var rand = new Random();

                var sw = new Stopwatch();
                sw.Start();
                for (int i = 0; i < EventCount / 100; i++)
                {
                    string key = rand.Next(EventCount - 1).ToString();
                    session.Delete <NumericDocument>(key);
                }
                sw.Stop();
                int count = session.List <NumericDocument>().Count();
                Console.WriteLine("{1} (of {2} attempted) deletes: {0}ms", sw.ElapsedMilliseconds, EventCount - count,
                                  EventCount / 100);
                // at least one delete should have happened
                count.ShouldBeLessThan(EventCount - 1);
            }
            swFull.Stop();
            Console.WriteLine("Spin up, delete, count, and shutdown: {0}ms", swFull.ElapsedMilliseconds);
        }
コード例 #6
0
        public void Robbin_the_filestore_bank()
        {
            DocumentSessionFactory.SetEngineFactory(str => new FileStorageEngine(str));

            RobTheBank(InsertStoreName);
        }
コード例 #7
0
 public void A_cabin_session()
 {
     DocumentSessionFactory.SetEngineFactory(str => new FileStorageEngine(str));
     Session = DocumentSessionFactory.Create("session.specs.store");
 }
コード例 #8
0
 public DocumentStore(DocumentSessionFactory documentSessionFactory, IDocumentStore documentStore)
 {
     _documentSessionFactory   = documentSessionFactory;
     _documentStore            = documentStore;
     _documentSessionException = new InvalidOperationException("Document Session is not initialized. Please SetSession('<database-name>')");
 }
コード例 #9
0
 public void SetStore(DocumentSessionFactory documentSessionFactory)
 {
     DocumentSessionFactory = documentSessionFactory;
 }