Source

mongo-dart / tests / DbCommandTest.dart

Full commit
vadimtsushko 9f4d884 
vadimtsushko f35d109 
vadimtsushko 2b81e76 
vadimtsushko f35d109 
vadimtsushko e056253 
vadimtsushko f35d109 
vadimtsushko e056253 
vadimtsushko f35d109 

vadimtsushko e056253 
vadimtsushko b049363 

















vadimtsushko f35d109 



vadimtsushko 9f4d884 


vadimtsushko b049363 
vadimtsushko 9f4d884 
vadimtsushko f35d109 
#library("dbcommand");
#import("../lib/mongo.dart");
#import('../third_party/unittest/unittest.dart');
testDbCommandCreation(){
  Db db = new Db('mongo-dart-test');
  DbCommand dbCommand = new DbCommand(db,"student",0,0,1,{},{});
  Expect.stringEquals('mongo-dart-test.student',dbCommand.collectionNameBson.value);
}
testPingDbCommand(){
  Db db = new Db('mongo-dart-test');
  db.open().then((d){
    DbCommand pingCommand = DbCommand.createPingCommand(db);
    Future<MongoReplyMessage> mapFuture = db.executeQueryMessage(pingCommand);
    mapFuture.then((msg) {
      Expect.mapEquals({'ok': 1},msg.documents[0]);
      db.close();
    });
  });
}
testDropDbCommand(){
  Db db = new Db('mongo-dart-test');
  db.open().then((d){
    DbCommand command = DbCommand.createDropDatabaseCommand(db);
    Future<MongoReplyMessage> mapFuture = db.executeQueryMessage(command);
    mapFuture.then((msg) {
      expect(msg.documents[0]["ok"]).equals(1);      
      db.close();  
    });
  });
}

main(){
  group("DBCommand tests:", (){
    test("testDbCommandCreation",testDbCommandCreation);
    test("testPingDbCommand",testPingDbCommand);
    test("testDropDbCommand",testDropDbCommand);    
  });
}