//[Test]
 public void TestMultiThreadedReads(){
     Mongo db = new Mongo();
     db.Connect();               
     
     List<string> colnames = new List<string>{"threadsmallreads", "threadsmallreads",
                                             "threadsmallreads", "threadsmallreads"};
     List<Thread> threads = new List<Thread>();
     List<Reader> readers = new List<Reader>();
     int iterations = 50;
     foreach(string colname in colnames){
         Reader r = new Reader{Iterations = iterations, Collection = DB[colname]};
         readers.Add(r);
         ThreadStart ts = new ThreadStart(r.DoReads);
         Thread thread = new Thread(ts);                
         threads.Add(thread);
     }
     RunAndWait(threads);
     
     try{
         //Connection still alive?
         DB["smallreads"].Count();
     }catch(Exception e){
         Assert.Fail(e.Message);
     }
     foreach(Reader r in readers){
         Assert.AreEqual(iterations, r.Count, "A reader did not read everytime.");
     }
 }
        public void TestMultiThreadedReadsAndWrites(){
            Mongo db = new Mongo();
            db.Connect();

            IMongoCollection col = DB["threadreadinserts"];
            
            List<string> identifiers = new List<string>{"A", "B", "C", "D"};
            List<string> colnames = new List<string>{"threadsmallreads", "threadsmallreads",
                                                    "threadsmallreads", "threadsmallreads"};
            List<Thread> threads = new List<Thread>();
            List<Reader> readers = new List<Reader>();
            int writeiterations = 100;
            int readiterations = 50;
            foreach(string identifier in identifiers){
                Inserter ins = new Inserter {Iterations = writeiterations, Identifier = identifier, Collection = col};
                ThreadStart ts = new ThreadStart(ins.DoInserts);
                Thread thread = new Thread(ts);                
                threads.Add(thread);
            }            
            foreach(string colname in colnames){
                Reader r = new Reader{Iterations = readiterations, Collection = DB[colname]};
                readers.Add(r);
                ThreadStart ts = new ThreadStart(r.DoReads);
                Thread thread = new Thread(ts);                
                threads.Add(thread);
            }            
            
            RunAndWait(threads);
            try{
                Assert.AreEqual(identifiers.Count * writeiterations, col.Count());
            }catch(Exception e){
                Assert.Fail(e.Message);
            }
            foreach(Reader r in readers){
                Assert.AreEqual(readiterations, r.Count, "A reader did not read everytime.");
            }
        }