예제 #1
0
        public void Can_save_and_load_strongly_typed_document()
        {
            var origin = new Sample { Name = "John Wayne" };
            var id = _collection.Save(origin, false);

            var reloaded = _collection.Load<Sample>(id);

            Assert.That(reloaded.Id, Is.EqualTo(origin.Id));
            Assert.That(reloaded.Name, Is.EqualTo(origin.Name));
        }
예제 #2
0
        public void Can_update_strongly_typed_document()
        {
            var origin = new Sample { Name = "John Wayne" };
            var id = _collection.Save(origin, false);

            var reloaded = _collection.Load<Sample>(id);

            reloaded.Name = "Max Payne";

            var id2 = _collection.Save<Sample>(reloaded, false);

            var reloaded2 = _collection.Load<Sample>(id);

            Assert.That(id,  Is.EqualTo(id2));
            Assert.That(reloaded2.Name, Is.EqualTo(reloaded.Name));
        }
예제 #3
0
        public void Setup()
        {
            if (File.Exists(DbName))
            {
                File.Delete(DbName);
            }
            _dataBase = Library.Instance.CreateDatabase();

            _dataBase.Open(DbName, Database.DefaultOpenMode | OpenMode.TruncateOnOpen);

            _collection = _dataBase.CreateCollection("default", new CollectionOptions());

            _originBson = BsonDocument.ValueOf(new { Name = "Denis Gladiolus" });

            _originSample = new Sample { Name = "Denis Gladiolus" };
        }