Ejemplo n.º 1
0
        public void PutNewDocInTxCommitAndThenGetIt()
        {
            var transactionInformation = new TransactionInformation {
                Id = Guid.NewGuid().ToString(), Timeout = TimeSpan.FromMinutes(1)
            };

            db.Put("ayende", null, RavenJObject.Parse("{ayende:'rahien'}"), new RavenJObject(), transactionInformation);

            db.PrepareTransaction(transactionInformation.Id);
            db.Commit(transactionInformation.Id);

            Assert.NotNull(db.Get("ayende", null));
        }
Ejemplo n.º 2
0
        public void DeletingDocumentAndThenAddingDocumentInSameTransactionCanWork()
        {
            db.Put("ayende", null, RavenJObject.Parse("{ayende:'oren'}"), new RavenJObject(), null);
            var transactionInformation = new TransactionInformation {
                Id = Guid.NewGuid().ToString(), Timeout = TimeSpan.FromMinutes(1)
            };

            db.Delete("ayende", null, transactionInformation);
            db.Put("ayende", null, RavenJObject.Parse("{ayende:'rahien'}"), new RavenJObject(), transactionInformation);
            db.PrepareTransaction(transactionInformation.Id);
            db.Commit(transactionInformation.Id);

            Assert.Equal("rahien", db.Get("ayende", null).ToJson()["ayende"].Value <string>());
        }
Ejemplo n.º 3
0
        public void WhenUsingTransactionWillWorkIfDocumentEtagMatch()
        {
            db.Put("ayende", null, RavenJObject.Parse("{ayende:'oren'}"), new RavenJObject(), null);
            var doc = db.Get("ayende", null);
            var transactionInformation = new TransactionInformation {
                Id = Guid.NewGuid().ToString(), Timeout = TimeSpan.FromMinutes(1)
            };

            db.Put("ayende", doc.Etag, RavenJObject.Parse("{ayende:'rahien'}"), new RavenJObject(), transactionInformation);
            db.PrepareTransaction(transactionInformation.Id);
            db.Commit(transactionInformation.Id);


            Assert.Equal("rahien", db.Get("ayende", null).ToJson()["ayende"].Value <string>());
        }
Ejemplo n.º 4
0
        public void PutTwoDocumentsAndThenCommit()
        {
            EnsureDtcIsSupported(db);
            var transactionInformation = new TransactionInformation {
                Id = Guid.NewGuid().ToString(), Timeout = TimeSpan.FromMinutes(1)
            };

            db.Documents.Put("ayende1", null, RavenJObject.Parse("{ayende:'rahien'}"), new RavenJObject(), transactionInformation);
            db.Documents.Put("ayende2", null, RavenJObject.Parse("{ayende:'rahien'}"), new RavenJObject(), transactionInformation);

            db.PrepareTransaction(transactionInformation.Id);
            db.Commit(transactionInformation.Id);

            Assert.NotNull(db.Documents.Get("ayende1", null));
            Assert.NotNull(db.Documents.Get("ayende2", null));
        }