Exemple #1
0
        public void CSharpDriverTest()
        {
            //Step. Get Facade
            CSharpDriverFacade facade = new CSharpDriverFacade("mongodb://localhost/?safe=true","dmongo","test");
            Assert.IsNotNull(facade);

            //Step. Set up model
            CSharpDriverModel model = new CSharpDriverModel() { Name = "Felipe" };
            Assert.IsNotNull(model);

            //Step. Insert
            var id = facade.Insert(model);
            Assert.IsNotNull(id);

            //Step. Find
            var result = facade.FindById(id);
            Assert.IsNotNull(result);
            Assert.AreEqual(result.Name,model.Name);
        }
 public ObjectId Insert(CSharpDriverModel entity)
 {
     this._collection.Insert(entity);
     return entity.Id;
 }