Example #1
0
        public void apply_updates_via_the_actual_document()
        {
            var stringDoc1 = new StringDoc {Id = "Foo"};
            var stringDoc2 = new StringDoc {Id = "Bar"};
            var user1 = new User();
            var user2 = new User();
            var int1 = new IntDoc {Id = 1};
            var int2 = new IntDoc {Id = 2};
            var long1 = new LongDoc {Id = 3};
            var long2 = new LongDoc {Id = 4};

            var uow1 = theContainer.GetInstance<UnitOfWork>();
            uow1.Store(user1, user2);
            uow1.Store(stringDoc1, stringDoc2);
            uow1.Store(int1, int2);
            uow1.Store(long1, long2);
            var batch1 = theContainer.GetInstance<UpdateBatch>();
            uow1.ApplyChanges(batch1);


            var uow2 = theContainer.GetInstance<UnitOfWork>();
            uow2.Delete(stringDoc2);
            uow2.Delete(user2);
            uow2.Delete(int2);
            uow2.Delete(long2);
            var batch2 = theContainer.GetInstance<UpdateBatch>();
            uow2.ApplyChanges(batch2);

            theSession.Query<StringDoc>().Single().Id.ShouldBe(stringDoc1.Id);
            theSession.Query<User>().Single().Id.ShouldBe(user1.Id);
            theSession.Query<IntDoc>().Single().Id.ShouldBe(int1.Id);
            theSession.Query<LongDoc>().Single().Id.ShouldBe(long1.Id);
        }
Example #2
0
        public void apply_updates_via_the_actual_document()
        {
            var stringDoc1 = new StringDoc {
                Id = "Foo"
            };
            var stringDoc2 = new StringDoc {
                Id = "Bar"
            };
            var user1 = new User();
            var user2 = new User();
            var int1  = new IntDoc {
                Id = 1
            };
            var int2 = new IntDoc {
                Id = 2
            };
            var long1 = new LongDoc {
                Id = 3
            };
            var long2 = new LongDoc {
                Id = 4
            };

            var uow1 = theStore.Advanced.CreateUnitOfWork();

            uow1.StoreUpdates(user1, user2);
            uow1.StoreUpdates(stringDoc1, stringDoc2);
            uow1.StoreUpdates(int1, int2);
            uow1.StoreUpdates(long1, long2);



            var batch1 = theStore.Advanced.CreateUpdateBatch();

            uow1.ApplyChanges(batch1);

            batch1.Connection.Dispose();


            var uow2 = theStore.Advanced.CreateUnitOfWork();

            uow2.DeleteEntity(stringDoc2);
            uow2.DeleteEntity(user2);
            uow2.DeleteEntity(int2);
            uow2.DeleteEntity(long2);
            var batch2 = theStore.Advanced.CreateUpdateBatch();

            uow2.ApplyChanges(batch2);

            batch2.Connection.Dispose();

            theSession.Query <StringDoc>().Single().Id.ShouldBe(stringDoc1.Id);
            theSession.Query <User>().Single().Id.ShouldBe(user1.Id);
            theSession.Query <IntDoc>().Single().Id.ShouldBe(int1.Id);
            theSession.Query <LongDoc>().Single().Id.ShouldBe(long1.Id);
        }
Example #3
0
        public void apply_updates_via_the_id()
        {
            var stringDoc1 = new StringDoc {
                Id = "Foo"
            };
            var stringDoc2 = new StringDoc {
                Id = "Bar"
            };
            var user1 = new User();
            var user2 = new User();
            var int1  = new IntDoc {
                Id = 1
            };
            var int2 = new IntDoc {
                Id = 2
            };
            var long1 = new LongDoc {
                Id = 3
            };
            var long2 = new LongDoc {
                Id = 4
            };

            var uow1 = theContainer.GetInstance <UnitOfWork>();

            uow1.Store(user1, user2);
            uow1.Store(stringDoc1, stringDoc2);
            uow1.Store(int1, int2);
            uow1.Store(long1, long2);
            var batch1 = theContainer.GetInstance <UpdateBatch>();

            uow1.ApplyChanges(batch1);

            batch1.Connection.Dispose();

            var uow2 = theContainer.GetInstance <UnitOfWork>();

            uow2.Delete <StringDoc>(stringDoc2.Id);
            uow2.Delete <User>(user2.Id);
            uow2.Delete <IntDoc>(int2.Id);
            uow2.Delete <LongDoc>(long2.Id);
            var batch2 = theContainer.GetInstance <UpdateBatch>();

            uow2.ApplyChanges(batch2);

            batch2.Connection.Dispose();

            theSession.Query <StringDoc>().Single().Id.ShouldBe(stringDoc1.Id);
            theSession.Query <User>().Single().Id.ShouldBe(user1.Id);
            theSession.Query <IntDoc>().Single().Id.ShouldBe(int1.Id);
            theSession.Query <LongDoc>().Single().Id.ShouldBe(long1.Id);
        }
        public void auto_assign_id_for_0_id()
        {
            var doc = new LongDoc { Id = 0 };

            theSession.Store(doc);

            doc.Id.ShouldBeGreaterThan(0L);

            var doc2 = new LongDoc { Id = 0 };
            theSession.Store(doc2);

            doc2.Id.ShouldNotBe(0L);

            doc2.Id.ShouldNotBe(doc.Id);
        }
        public void persist_and_load()
        {
            var LongDoc = new LongDoc { Id = 456 };

            theSession.Store(LongDoc);
            theSession.SaveChanges();

            using (var session = theContainer.GetInstance<IDocumentSession>())
            {
                session.Load<LongDoc>(456)
                    .ShouldNotBeNull();

                session.Load<LongDoc>(222)
                    .ShouldBeNull();
            }
        }
Example #6
0
        public void persist_and_load()
        {
            var LongDoc = new LongDoc {
                Id = 456
            };

            theSession.Store(LongDoc);
            theSession.SaveChanges();

            using (var session = theStore.OpenSession())
            {
                session.Load <LongDoc>(456)
                .ShouldNotBeNull();

                session.Load <LongDoc>(222)
                .ShouldBeNull();
            }
        }
        public void persist_and_load()
        {
            var LongDoc = new LongDoc {
                Id = 456
            };

            theSession.Store(LongDoc);
            theSession.SaveChanges();

            using (var session = theContainer.GetInstance <IDocumentStore>().OpenSession())
            {
                session.Load <LongDoc>(456)
                .ShouldNotBeNull();

                session.Load <LongDoc>(222)
                .ShouldBeNull();
            }
        }
        public void persist_and_delete()
        {
            var LongDoc = new LongDoc { Id = 567 };

            theSession.Store(LongDoc);
            theSession.SaveChanges();

            using (var session = theContainer.GetInstance<IDocumentSession>())
            {
                session.Delete<LongDoc>(LongDoc.Id);
                session.SaveChanges();
            }

            using (var session = theContainer.GetInstance<IDocumentSession>())
            {
                session.Load<LongDoc>(LongDoc.Id)
                    .ShouldBeNull();
            }
        }
Example #9
0
        public void auto_assign_id_for_0_id()
        {
            var doc = new LongDoc {
                Id = 0
            };

            theSession.Store(doc);

            doc.Id.ShouldBeGreaterThan(0L);

            var doc2 = new LongDoc {
                Id = 0
            };

            theSession.Store(doc2);

            doc2.Id.ShouldNotBe(0L);

            doc2.Id.ShouldNotBe(doc.Id);
        }
Example #10
0
        public void persist_and_delete()
        {
            var LongDoc = new LongDoc {
                Id = 567
            };

            theSession.Store(LongDoc);
            theSession.SaveChanges();

            using (var session = theStore.OpenSession())
            {
                session.Delete <LongDoc>((int)LongDoc.Id);
                session.SaveChanges();
            }

            using (var session = theStore.OpenSession())
            {
                session.Load <LongDoc>(LongDoc.Id)
                .ShouldBeNull();
            }
        }
        public void persist_and_delete()
        {
            var LongDoc = new LongDoc {
                Id = 567
            };

            theSession.Store(LongDoc);
            theSession.SaveChanges();

            using (var session = theContainer.GetInstance <IDocumentStore>().OpenSession())
            {
                session.Delete <LongDoc>(LongDoc.Id);
                session.SaveChanges();
            }

            using (var session = theContainer.GetInstance <IDocumentStore>().OpenSession())
            {
                session.Load <LongDoc>(LongDoc.Id)
                .ShouldBeNull();
            }
        }