Example #1
0
        public void SessionSetsIdOnSave()
        {
            IDocumentStore store;
            using (TestHelper.GetDocumentStore(out store))
            using (var session = store.OpenSession())
            {
                var entity = new BasicObject { Value = "Some Value" };
                session.Store(entity);
                session.SaveChanges();

                Assert.NotEqual("", entity.Id);
            }
        }
Example #2
0
        public void SessionSavesAndLoadsData()
        {
            IDocumentStore store;
            using (TestHelper.GetDocumentStore(out store))
            {
                const string id = "basicobject/123";
                using (var session = store.OpenSession())
                {
                    var entity = new BasicObject
                    {
                        Id = id,
                        Value = "Some Value"
                    };
                    session.Store(entity);
                    session.SaveChanges();

                    Assert.Equal(id, entity.Id);
                }

                using (var session = store.OpenSession())
                {
                    var entity = session.Load<BasicObject>(id);
                    Assert.Equal(id, entity.Id);
                    Assert.Equal("Some Value", entity.Value);
                }
            }
        }