public UpdateModifiersTests()
 {
     var admin = new MongoAdmin("mongodb://localhost/admin?pooling=false&strict=true");
     _server = Mongo.Create("mongodb://localhost/NormTests?pooling=false&strict=true");
     _collection = _server.GetCollection<Post>("Posts");
     _buildInfo = admin.BuildInfo();
 }
Beispiel #2
0
        public void ReturnsBuildInfo()
        {
            string gitVersion;
            string version;

            using (var process = new Process())
            {
                process.StartInfo = new ProcessStartInfo("mongod", "--version")
                {
                    RedirectStandardOutput = true, UseShellExecute = false
                };
                process.Start();
                using (var stream = process.StandardOutput)
                {
                    var data = stream.ReadToEnd();
                    gitVersion = Regex.Match(data, "git version: ([a-f0-9]+)\r\n").Groups[1].Value;
                    version    = Regex.Match(data, "db version v([^,]+),").Groups[1].Value;
                }
            }

            using (var admin = new MongoAdmin(TestHelper.ConnectionString(null, "admin", null, null)))
            {
                var info = admin.BuildInfo();
                Assert.Equal(true, info.WasSuccessful);
                Assert.Equal(gitVersion, info.GitVersion);
                Assert.Equal(version, info.Version);
            }
        }
Beispiel #3
0
 public void BuildInfoThrowsExceptionIfNotConnectedToAdmin()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var ex = Assert.Throws <MongoException>(() => admin.BuildInfo());
         Assert.Equal("This command is only valid when connected to admin", ex.Message);
     }
 }
Beispiel #4
0
 public void BuildInfoThrowsExceptionIfNotConnectedToAdmin()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var ex = Assert.Throws<MongoException>(() => admin.BuildInfo());
         Assert.Equal("This command is only valid when connected to admin", ex.Message);
     }
 }
Beispiel #5
0
        public UpdateModifiersTests()
        {
            var admin = new MongoAdmin("mongodb://localhost/admin?pooling=false&strict=true");

            _server     = Mongo.Create("mongodb://localhost/NormTests?pooling=false&strict=true");
            _collection = _server.GetCollection <Post>("Posts");
            _buildInfo  = admin.BuildInfo();
        }
Beispiel #6
0
 public QueryTests()
 {
     var admin = new MongoAdmin("mongodb://localhost/admin?pooling=false&strict=true");
     _server = Mongo.Create("mongodb://localhost/NormTests?pooling=false");
     _collection = _server.GetCollection<Person>("People");
     _buildInfo = admin.BuildInfo();
     //cause the collection to exist on the server by inserting, then deleting some things.
     _collection.Insert(new Person());
     _collection.Delete(new { });
 }
Beispiel #7
0
        public QueryTests()
        {
            var admin = new MongoAdmin("mongodb://localhost/admin?pooling=false&strict=true");

            _server     = Mongo.Create("mongodb://localhost/NormTests?pooling=false");
            _collection = _server.GetCollection <Person>("People");
            _buildInfo  = admin.BuildInfo();
            //cause the collection to exist on the server by inserting, then deleting some things.
            _collection.Insert(new Person());
            _collection.Delete(new { });
        }
Beispiel #8
0
 public void ForceSyncDoesSomethingOk()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString(null, "admin", null, null)))
     {
         if (!admin.BuildInfo().SystemInformation.ToLower().Contains("windows"))
         {
             var response = admin.ForceSync(true);
             Assert.Equal(true, response.WasSuccessful);
             Assert.True(response.NumberOfFiles > 0); //don't know what this is
         }
         else
         {
             Assert.Throws(typeof(MongoException), () => admin.ForceSync(true));
             Console.WriteLine("FSync is not supported on windows version of MongoDB and will throw an exception.");
         }
     }
 }
Beispiel #9
0
 public void ForceSyncDoesSomethingOk()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString(null, "admin", null, null)))
     {
         if (!admin.BuildInfo().SystemInformation.ToLower().Contains("windows"))
         {
             var response = admin.ForceSync(true);
             Assert.Equal(1d, response.Ok);
             Assert.True(response.NumberOfFiles > 0); //don't know what this is
         }
         else
         {
             Assert.Throws(typeof(MongoException),()=> admin.ForceSync(true));
             Console.WriteLine("FSync is not supported on windows version of MongoDB and will throw an exception.");
         }
     }
 }
Beispiel #10
0
        public void ReturnsBuildInfo()
        {
            string gitVersion;
            string version;
            using (var process = new Process())
            {
                process.StartInfo = new ProcessStartInfo("mongod", "--version"){ RedirectStandardOutput = true, UseShellExecute = false};
                process.Start();
                using (var stream = process.StandardOutput)
                {
                    var data = stream.ReadToEnd();
                    gitVersion = Regex.Match(data, "git version: ([a-f0-9]+)\r\n").Groups[1].Value;
                    version = Regex.Match(data, "db version v([^,]+),").Groups[1].Value;
                }
            }

            using (var admin = new MongoAdmin(TestHelper.ConnectionString(null, "admin", null, null)))
            {
                var info = admin.BuildInfo();
                Assert.Equal(1d, info.Ok);
                Assert.Equal(gitVersion, info.GitVersion);
                Assert.Equal(version, info.Version);
            }
        }