Example #1
0
        public void should_be_able_to_get_delete_all_docs_using_helper()
        {
            using (var session = new TemporarySession())
            {
                var testObject1 = new TestDoc {
                    Text = "hello world"
                };
                var testObject2 = new TestDoc {
                    Text = "hello world"
                };
                var testObject3 = new TestDoc {
                    Text = "hello world"
                };

                var info1 = session.Save(testObject1);
                var info2 = session.Save(testObject2);
                var info3 = session.Save(testObject3);

                var result = session.Bulk.All(new ViewQuery()
                {
                    IncludeDocs = true
                });
                result.Rows.Length.ShouldBe(3);

                session.Bulk.Delete(result.Documents.ToArray());

                result = session.Bulk.All(new ViewQuery()
                {
                    IncludeDocs = true
                });
                result.Rows.Length.ShouldBe(0);
            }
        }
Example #2
0
        public void db_put_get_delete()
        {
            using (var session = new TemporarySession())
            {
                var testObject = new TestDoc {
                    Text = "hello world"
                };

                var result = session.Get <TestDoc>("test");

                Assert.That(result, Is.Null);

                var info = session.Save(testObject, "test");

                testObject.Text = "hello world chagned";

                session.Save(testObject);

                testObject.Text = "hello world changed";

                info = session.Save(testObject);

                testObject.Text = "hello world changed 2";

                session.Save(testObject, info);

                session.Delete(testObject);

                result = session.Get <TestDoc>("test");

                Assert.That(result, Is.Null);
            }
        }
Example #3
0
        public void should_use_configuration_database_when_specified()
        {
            using (var session = new TemporarySession())
            {
                using (var anotherSession = new TemporarySession())
                {
                    Documents.Configure <TestDoc>(database: anotherSession.DatabaseName);

                    var testObject = new TestDoc {
                        Text = "hello world"
                    };

                    var info = session.Save(testObject, "test");

                    var fromDb = session.Get <JObject>(info.Id);
                    fromDb.ShouldBe(null);


                    session.DatabaseName.ShouldBe(session.DefaultDatabase);

                    var fromDb2 = session.Get <TestDoc>(info.Id);
                    fromDb2.ShouldNotBe(null);

                    var info2 = session.Documents.Save(testObject);

                    info2.Id.ShouldBe(info.Id);

                    session.DatabaseName.ShouldBe(session.DefaultDatabase);
                }
            }
        }
Example #4
0
        public void should_be_able_to_get_all_docs()
        {
            using (var session = new TemporarySession())
            {
                var testObject1 = new TestDoc {
                    Text = "hello world"
                };
                var testObject2 = new TestDoc {
                    Text = "hello world"
                };
                var testObject3 = new TestDoc {
                    Text = "hello world"
                };

                var info1 = session.Save(testObject1);
                var info2 = session.Save(testObject2);
                var info3 = session.Save(testObject3);

                var result = session.Bulk.All();

                result.Rows.Length.ShouldBe(3);
            }
        }
Example #5
0
        public void should_allow_keys_to_contain_slashes()
        {
            using (var session = new TemporarySession())
            {
                var testObject1 = new TestDoc {
                    _id = "test/1", Text = "hello world"
                };

                var result1 = session.Get <TestDoc>("test/1");

                Assert.That(result1, Is.Null);

                session.Save(testObject1, testObject1._id);

                var result2 = session.Get <TestDoc>("test/1");

                Assert.That(result2, Is.Not.Null);
                Assert.That(result2._id == "Test/1");


                var testObject2 = new TestDoc {
                    _id = "test/2", Text = "hello world"
                };

                var result3 = session.Get <TestDoc>("test/2");

                Assert.That(result3, Is.Null);

                session.Save(testObject2, testObject2._id);

                var result4 = session.Get <TestDoc>("test/2");

                Assert.That(result4, Is.Not.Null);
                Assert.That(result4._id == "Test/2");
            }
        }