Exemple #1
0
        public void DoWork()
        {
            var guid = Guid.Parse("f63469c1-9caa-4a17-b7f5-3c8248193de9");

            using (var store = new DocumentStore
            {
                Urls = new[] { "http://localhost:8888" },
                Database = "BankAccountEventStore"
            })
            {
                store.Initialize();
                using (var session = store.OpenSession())
                {
                    IEventStore eventStore  = new RavenDbEventStore(session);
                    var         repository  = new BankAccountRepository(eventStore);
                    var         bankAccount = repository.FindBy(guid);

                    repository.SaveSnapshot(bankAccount.Snapshot(), bankAccount);

                    bankAccount.Deposit(new Money(200m));
                    repository.Save(bankAccount);


                    session.SaveChanges();


//                    repository.SaveSnapshot(bankAccount.Snapshot(), bankAccount);
//                    session.SaveChanges();
//
//                    var bankAccountOption = repository.FindBy(guid);
//                    var bankAccount2 = bankAccountOption.Value;
                }
            }
        }
 public void Ctor_should_set_DocumentStore_field()
 {
     var bus  = new Mock <IEventDispatcher>().Object;
     var mock = new Mock <DocumentStore>().Object;
     var sut  = new RavenDbEventStore(mock, bus);
     //Assert.AreEqual(mock, RavenDbEventStore.DocumentStore);
 }
        private static void InitializeRepository()
        {
            var db = new EmbeddableDocumentStore()
            {
                UseEmbeddedHttpServer = true
            };

            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8081);
            db.Configuration.Port = 8081;

            db.Initialize();

            DocumentStore = db;

            var eventStore = new RavenDbEventStore(db, _bus);
            var repository = new DomainRepository(eventStore);

            DomainRepository = repository;
        }
        private static void InitializeRepository()
        {
            var db = new EmbeddableDocumentStore()
            {
                UseEmbeddedHttpServer = true
            };

            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8081);
            db.Configuration.Port = 8081;

            db.Initialize();

            DocumentStore = db;

            var eventStore = new RavenDbEventStore(db, _bus);
            var repository = new DomainRepository(eventStore);

            DomainRepository = repository;
        }
Exemple #5
0
        public void Get_Data_From_DB()
        {
            var guid = Guid.Parse("f63469c1-9caa-4a17-b7f5-3c8248193de9");

            using (var store = new DocumentStore
            {
                Urls = new[] { "http://localhost:8888" },
                Database = "BankAccountEventStore"
            })
            {
                store.Initialize();
                using (var session = store.OpenSession())
                {
                    IEventStore eventStore = new RavenDbEventStore(session);
                    var         repository = new BankAccountRepository(eventStore);

                    var bankAccount = repository.FindBy(guid);
                }
            }
        }
Exemple #6
0
        public void SetUp()
        {
            using (var ravenDocumentStore = new DocumentStore()
            {
                ConnectionStringName = "RavenDbInstance"
            })
            {
                ravenDocumentStore.Initialize();
                ravenDocumentStore.DatabaseCommands
                .GlobalAdmin
                .EnsureDatabaseExists("TestDocumentStore");
                ravenDocumentStore.DatabaseCommands
                .GlobalAdmin
                .EnsureDatabaseExists("TestEventStore");
            }

            documentStore = new DocumentStore()
            {
                ConnectionStringName = "DocumentStore"
            };
            documentStore.Initialize();

            eventDocumentStore = new DocumentStore()
            {
                ConnectionStringName = "EventStore"
            };
            eventDocumentStore.Initialize();

            eventDocumentStore.RegisterListener(new PatchDomainEventsApplyingMementoMetadata());

            new DomainEvents_Stream().Execute(eventDocumentStore);
            new RavenDocumentsByEntityName().Execute(eventDocumentStore);

            var bus = new Mock <IEventDispatcher>().Object;
            var mementoEventStore = new RavenDbEventStore(eventDocumentStore, bus);

            MementoEventStore = mementoEventStore;
        }