public void ShouldReturnCollectionsFromDatabase()
        {
            //Given
            Mongo db = new Mongo(string.Format("Server={0}:{1}", "localhost", "27017"));
            db.Connect();
            IMongoCollection collection = db["test"]["folks"];
            Document doc1 = new Document() { { "first_name", "Bill" }, { "middle_initial", "Q" }, { "last_name", "Jackson" }, { "address", "744 Nottingham St." } };
            Document doc2 = new Document() { { "first_name", "Ralph" }, { "middle_initial", "M" }, { "last_name", "Buckingham" }, { "state", "CA" } };
            Document doc3 = new Document() { { "first_name", "Ronald" }, { "middle_initial", "Q" }, { "last_name", "Weasly" }, { "city", "Santa Rosa" } };
            collection.Insert(doc1);
            collection.Insert(doc2);
            collection.Insert(doc3);
            var queryProvider = new MongoDbCSharpQuery();

            try
            {
                //When
                IList<string> collections = queryProvider.GetCollections("localhost", "test", "27017");

                //Then
                Assert.IsNotNull(collections.Where(c => c == "folks").SingleOrDefault());
            }
            finally
            {
                //Clean Up
                collection.Delete(doc1);
                collection.Delete(doc2);
                collection.Delete(doc3);
                queryProvider.Dispose();
            }
        }
        public void ShouldReturnAllDataFromCollection()
        {
            //Given
            Mongo db = new Mongo(string.Format("Server={0}:{1}", "localhost", "27017"));
            db.Connect();
            IMongoCollection collection = db["test"]["folks"];
            Document doc1 = new Document() { { "first_name", "Bill" }, { "middle_initial", "Q" }, { "last_name", "Jackson" }, { "address", "744 Nottingham St." } };
            Document doc2 = new Document() { { "first_name", "Ralph" }, { "middle_initial", "M" }, { "last_name", "Buckingham" }, { "state", "CA" } };
            Document doc3 = new Document() { { "first_name", "Ronald" }, { "middle_initial", "Q" }, { "last_name", "Weasly" }, { "city", "Santa Rosa" } };
            collection.Insert(doc1);
            collection.Insert(doc2);
            collection.Insert(doc3);
            var queryProvider = new MongoDbCSharpQuery();

            try
            {
                //When
                IEnumerable data = queryProvider.RunQuery("localhost", "test", "27017", "folks");

                int numberOfRows = 0;
                foreach (var row in data) numberOfRows++;

                //Then
                Assert.AreEqual(3, numberOfRows);
            }
            finally
            {
                //Clean Up
                collection.Delete(doc1);
                collection.Delete(doc2);
                collection.Delete(doc3);
                queryProvider.Dispose();
            }
        }
        public void ShouldGetDataFromLocalMongoDbServer()
        {
            //Given
            Mongo db = new Mongo(string.Format("Server={0}:{1}", "localhost", "27017"));
            db.Connect();
            IMongoCollection collection = db["test"]["folks"];
            Document doc1 = new Document() { { "first_name", "Bill" }, { "middle_initial", "Q" }, { "last_name", "Jackson" }, { "address", "744 Nottingham St." } };
            Document doc2 = new Document() { { "first_name", "Ralph" }, { "middle_initial", "M" }, { "last_name", "Buckingham" }, { "state", "CA" } };
            Document doc3 = new Document() { { "first_name", "Ronald" }, { "middle_initial", "Q" }, { "last_name", "Weasly" }, { "city", "Santa Rosa" } };
            collection.Insert(doc1);
            collection.Insert(doc2);
            collection.Insert(doc3);

            IMongoQuery query = new MongoDbCSharpQuery();
            IMongoQueryFactory factory = new MongoDbCSharpQueryFactory(query);

            MainViewModel viewModel = new MainViewModel(factory)
                                          {
                                              Server = "localhost",
                                              Database = "test",
                                              Port = "27017",
                                              Query = "folks:this.middle_initial == 'Q'"
                                          };

            try
            {
                //When
                viewModel.RunQueryCommand.Execute(null);

                //Then
                Assert.AreEqual(2, viewModel.Items.Count);
                Assert.AreEqual(6, viewModel.Headers.Count); //including _id
            }
            finally
            {
                //Clean Up
                collection.Delete(doc1);
                collection.Delete(doc2);
                collection.Delete(doc3);
            }
        }