コード例 #1
0
 public IMongoAdminTests()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString("strict=false")))
     {
         admin.DropDatabase();
     }
 }
コード例 #2
0
ファイル: MongoDatabaseTest.cs プロジェクト: zeya/NoRM
 public MongoDatabaseTest()
 {
     using (var admin = new MongoAdmin(_connectionString))
     {
         admin.DropDatabase();
     }
 }
コード例 #3
0
ファイル: MongoCollectionTests.cs プロジェクト: zulkamal/NoRM
        public void Find_Subset_Returns_Appropriate_Subset()
        {
            using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                admin.SetProfileLevel(2);
            }
            using (var db = Mongo.Create(TestHelper.ConnectionString()))
            {
                var coll = db.GetCollection <TestProduct>();
                coll.Delete(new { });
                var oid = ObjectId.NewObjectId();

                coll.Insert(new TestProduct
                {
                    _id      = oid,
                    Price    = 42.42f,
                    Supplier = new Supplier
                    {
                        Name      = "Bob's house of pancakes",
                        RefNum    = 12,
                        CreatedOn = DateTime.MinValue
                    }
                });


                var subset = db.GetCollection <TestProduct>().Find(new { }, new { }, Int32.MaxValue, 0,
                                                                   j => new { SupplierName = j.Supplier.Name, Cost = j.Price, Id = j._id }).ToArray();

                Assert.Equal("Bob's house of pancakes", subset[0].SupplierName);
                Assert.Equal(42.42f, subset[0].Cost);
                Assert.Equal(oid, subset[0].Id);
            }
        }
コード例 #4
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);
            }
        }
コード例 #5
0
 public void Get_CurrentOp_Returns()
 {
     using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var currOps = mAdmin.GetCurrentOperations().ToArray();
     }
 }
コード例 #6
0
ファイル: MongoDatabaseTest.cs プロジェクト: zulkamal/NoRM
 public MongoDatabaseTest()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         admin.DropDatabase();
     }
 }
コード例 #7
0
 public void Reset_Last_Error_Returns()
 {
     using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         Assert.True(mAdmin.ResetLastError());
     }
 }
コード例 #8
0
 public void Repair_Database_Returns()
 {
     using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         Assert.True(mAdmin.RepairDatabase(false, false));
     }
 }
コード例 #9
0
ファイル: MongoAdminTests.cs プロジェクト: ereichert/NoRM
 public MongoAdminTests()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString("strict=false")))
     {
         admin.DropDatabase();
     }
 }
コード例 #10
0
ファイル: MongoDatabaseTest.cs プロジェクト: gaoninggn/NoRM
 public MongoDatabaseTest()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         admin.DropDatabase();
     }      
 }
コード例 #11
0
ファイル: MongoAdminTests.cs プロジェクト: gaoninggn/NoRM
 public void Repair_Database_Returns()
 {
     using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         Assert.True(mAdmin.RepairDatabase(false, false));
     }
 }
コード例 #12
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();
 }
コード例 #13
0
ファイル: MongoAdminTests.cs プロジェクト: zeya/NoRM
 public void GetsServerStatus()
 {
     using (var admin = new MongoAdmin(ConnectionString()))
     {
         var status = admin.ServerStatus();
     }
 }
コード例 #14
0
ファイル: MongoAdminTests.cs プロジェクト: gaoninggn/NoRM
        public void Get_CurrentOp_Returns()
        {
            using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                var currOps = mAdmin.GetCurrentOperations().ToArray();
            }

        }
コード例 #15
0
ファイル: MongoAdminTests.cs プロジェクト: zeya/NoRM
 public void BuildInfoThrowsExceptionIfNotConnectedToAdmin()
 {
     using (var admin = new MongoAdmin(ConnectionString("temp")))
     {
         var ex = Assert.Throws<MongoException>(() => admin.BuildInfo());
         Assert.Equal("This command is only valid when connected to admin", ex.Message);
     }
 }
コード例 #16
0
ファイル: UpdateModifiersTests.cs プロジェクト: zulkamal/NoRM
        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();
        }
コード例 #17
0
ファイル: MongoAdminTests.cs プロジェクト: gaoninggn/NoRM
 public void Get_CurrentOp_Returns_Results()
 {
     using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var a = mAdmin.PreviousErrors();
         Assert.Equal(true, a.WasSuccessful);
     }
 }
コード例 #18
0
 public void ListsAllDatabasesThrowsExceptionIfNotConnectedToAdmin()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var ex = Assert.Throws <MongoException>(() => admin.GetAllDatabases());
         Assert.Equal("This command is only valid when connected to admin", ex.Message);
     }
 }
コード例 #19
0
 public void ForceSyncThrowsExceptionIfNotConnectedToAdmin()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var ex = Assert.Throws <MongoException>(() => admin.ForceSync(true));
         Assert.Equal("This command is only valid when connected to admin", ex.Message);
     }
 }
コード例 #20
0
 public void GetsServerStatus()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var status = admin.ServerStatus();
         Assert.Equal(true, status.WasSuccessful);
     }
 }
コード例 #21
0
 public void Get_CurrentOp_Returns_Results()
 {
     using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var a = mAdmin.PreviousErrors();
         Assert.Equal(true, a.WasSuccessful);
     }
 }
コード例 #22
0
ファイル: MongoAdminTests.cs プロジェクト: ereichert/NoRM
 public void ForceSyncThrowsExceptionIfNotConnectedToAdmin()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var ex = Assert.Throws<MongoException>(() => admin.ForceSync(true));
         Assert.Equal("This command is only valid when connected to admin", ex.Message);
     }
 }
コード例 #23
0
 public void ReturnsEmptyInProcessResponse()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString(null, "admin", null, null)))
     {
         var response = admin.GetCurrentOperations();
         Assert.Equal(0, response.Count());
     }
 }
コード例 #24
0
ファイル: UpdateTests.cs プロジェクト: ereichert/NoRM
 public void Dispose()
 {
     _server.Database.DropCollection("CheeseClubContacts");
     using (var admin = new MongoAdmin("mongodb://localhost/NormTests?pooling=false"))
     {
         admin.DropDatabase();
     }
     _server.Dispose();
 }
コード例 #25
0
 public void Dispose()
 {
     _server.Database.DropCollection("TestClasses");
     using (var admin = new MongoAdmin(TestHelper.ConnectionString("pooling=false")))
     {
         admin.DropDatabase();
     }
     _server.Dispose();
 }
コード例 #26
0
ファイル: WhereQualifierTests.cs プロジェクト: kenegozi/NoRM
 public void Dispose()
 {
     _server.Database.DropCollection("TestClasses");
     using (var admin = new MongoAdmin("mongodb://localhost/NoRMTests?pooling=false"))
     {
         admin.DropDatabase();
     }
     _server.Dispose();
 }
コード例 #27
0
ファイル: WhereQualifierTests.cs プロジェクト: zulkamal/NoRM
 public void Dispose()
 {
     _server.Database.DropCollection("TestClasses");
     using (var admin = new MongoAdmin("mongodb://localhost/NormTests?pooling=false"))
     {
         admin.DropDatabase();
     }
     _server.Dispose();
 }
コード例 #28
0
 public void Get_Assert_Info_Returns_Results()
 {
     using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var aInfo = mAdmin.AssertionInfo();
         Assert.NotNull(aInfo);
         Assert.Equal(true, aInfo.WasSuccessful);
     }
 }
コード例 #29
0
        public sealed override void Update()
        {
            if (String.IsNullOrEmpty(this.Script))
            {
                throw new InvalidOperationException("MigrationBase.GenerateMigrationScript() method should not returns null or empty script");
            }

            MongoAdmin.ExecuteScript(this.Database, this.Script);
        }
コード例 #30
0
 public void Dispose()
 {
     _server.Database.DropCollection("TestClasses");
     using (var admin = new MongoAdmin(TestHelper.ConnectionString("pooling=false")))
     {
         admin.DropDatabase();
     }
     _server.Dispose();
 }
コード例 #31
0
ファイル: MongoAdminTests.cs プロジェクト: zeya/NoRM
 public void ForceSyncDoesSomethingOk()
 {
     using (var admin = new MongoAdmin(ConnectionString()))
     {
         var response = admin.ForceSync(true);
         Assert.Equal(1d, response.OK);
         Assert.Equal(2, response.NumFiles); //don't know what this is
     }
 }
コード例 #32
0
ファイル: MongoAdminTests.cs プロジェクト: gaoninggn/NoRM
        public void Get_Assert_Info_Returns_Results()
        {
            using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                var aInfo = mAdmin.AssertionInfo();
                Assert.NotNull(aInfo);
                Assert.Equal(true, aInfo.WasSuccessful);
            }

        }
コード例 #33
0
ファイル: QueryTests.cs プロジェクト: gleborgne/NoRM
 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 { });
 }
コード例 #34
0
 public void Kill_Operation_Returns()
 {
     //since we don't have any long-running ops, this is all we can test without mocks.
     using (var mAdmin = new MongoAdmin("mongodb://127.0.0.1/admin"))
     {
         var x = mAdmin.KillOperation(double.MaxValue);
         Assert.Equal(false, x.WasSuccessful);
         Assert.Equal("no op number field specified?", x["err"]);
     }
 }
コード例 #35
0
ファイル: QueryTests.cs プロジェクト: zulkamal/NoRM
        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 { });
        }
コード例 #36
0
 public void Set_Profile_Level_Changes_Profile_Level_And_Reports_Change()
 {
     using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         int prev;
         if (mAdmin.SetProfileLevel(2, out prev))
         {
             mAdmin.SetProfileLevel(prev);
         }
     }
 }
コード例 #37
0
ファイル: MongoAdminTests.cs プロジェクト: gaoninggn/NoRM
        public void Set_Profile_Level_Changes_Profile_Level_And_Reports_Change()
        {
            using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                int prev;
                if (mAdmin.SetProfileLevel(2, out prev))
                {
                    mAdmin.SetProfileLevel(prev);
                }
            }

        }
コード例 #38
0
 public void Get_Current_Profile_Level()
 {
     using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var level = mAdmin.GetProfileLevel();
         if (level != 2d)
         {
             mAdmin.SetProfileLevel(2);
         }
         Assert.Equal(2, mAdmin.GetProfileLevel());
         mAdmin.SetProfileLevel(level);
     }
 }
コード例 #39
0
        public MongoConfigurationTests()
        {
            MongoConfiguration.RemoveMapFor<User2>();
            MongoConfiguration.RemoveMapFor<User>();
            MongoConfiguration.RemoveMapFor<TestProduct>();
            MongoConfiguration.RemoveMapFor<Shopper>();
            MongoConfiguration.RemoveMapFor<Cart>();
            MongoConfiguration.RemoveMapFor<TestProduct>();

            using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                admin.DropDatabase();
            }
        }
コード例 #40
0
ファイル: MongoAdminTests.cs プロジェクト: gaoninggn/NoRM
        public void Get_Current_Profile_Level()
        {
            using (var mAdmin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                var level = mAdmin.GetProfileLevel();
                if (level != 2d)
                {
                    mAdmin.SetProfileLevel(2);

                }
                Assert.Equal(2, mAdmin.GetProfileLevel());
                mAdmin.SetProfileLevel(level);
            }
        }
コード例 #41
0
        public MongoConfigurationTests()
        {
            MongoConfiguration.RemoveMapFor<User2>();
            MongoConfiguration.RemoveMapFor<User>();
            MongoConfiguration.RemoveMapFor<TestProduct>();
            MongoConfiguration.RemoveMapFor<Shopper>();
            MongoConfiguration.RemoveMapFor<Cart>();
            MongoConfiguration.RemoveMapFor<TestProduct>();
            MongoConfiguration.RemoveTypeConverterFor<NonSerializableValueObject>();

            using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                admin.DropDatabase();
            }
        }
コード例 #42
0
        public MongoConfigurationTests()
        {
            MongoConfiguration.RemoveMapFor <User2>();
            MongoConfiguration.RemoveMapFor <User>();
            MongoConfiguration.RemoveMapFor <TestProduct>();
            MongoConfiguration.RemoveMapFor <Shopper>();
            MongoConfiguration.RemoveMapFor <Cart>();
            MongoConfiguration.RemoveMapFor <TestProduct>();
            MongoConfiguration.RemoveTypeConverterFor <NonSerializableValueObject>();

            using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                admin.DropDatabase();
            }
        }
コード例 #43
0
        public async Task <IEnumerable <IScanInstanceModel> > GetListBy(IEnumerable <object> scanIds)
        {
            List <ScanInstance> ret = new List <ScanInstance>();

            if (!scanIds.IsEmptyList())
            {
                var filter = Builders <ScanInstance> .Filter.In(p => p.ScanId, System.Linq.Enumerable.Select(scanIds, p => (ObjectId)p));

                var coll = MongoAdmin.GetCollection <ScanInstance>(this.Db.Database);
                var find = await coll.FindAsync(filter);

                ret.AddRange(await find.ToListAsync());
            }

            return(ret);
        }
コード例 #44
0
ファイル: MongoAdminTests.cs プロジェクト: ereichert/NoRM
 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.");
         }
     }
 }
コード例 #45
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.");
         }
     }
 }
コード例 #46
0
        public GridFSTests()
        {
            //construct a random 10MB stream.
            Random r = new Random(DateTime.Now.Millisecond);

            for (int i = 0; i < 1024 * 1024 * 1.5; i++)
            {
                this._randomBytes.Write(BitConverter.GetBytes(r.NextDouble()), 0, 8);
            }
            this._randomBytes.Position = 0;
            this._randomByteHash       = _hasher.ComputeHash(_randomBytes);
            this._randomBytes.Position = 0;
            this._db = Mongo.Create(TestHelper.ConnectionString());
            using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                admin.DropDatabase();
            }
        }
コード例 #47
0
ファイル: DbContext.cs プロジェクト: mehmetgoren/Kamaji
        public DbContext(IConnectionStringProvider provider)
        {
            if (null == provider)
            {
                throw new ArgumentNullException("Please register ConnectionStringProvider using Startup.Register method");
            }

            this.Database = MongoAdmin.GetDatabase(new MongoClient(provider.ConnectionString), provider.DatabaseName);

            this.MongoClient = this.Database.Client;//for all clients.

            this._scanPrerequisites = this.GetLazy <ScanPrerequisite>();
            this._scanResources     = this.GetLazy <ScanResource>();
            this._scans             = this.GetLazy <Scan>();
            this._scanInstances     = this.GetLazy <ScanInstance>();
            this._nodes             = this.GetLazy <Node>();
            this._authes            = this.GetLazy <Auth>();
            this._scanSchedules     = this.GetLazy <ScanSchedule>();
        }
コード例 #48
0
ファイル: Startup.cs プロジェクト: mehmetgoren/Kamaji
        public static void Register(IConnectionStringProvider connectionStringProvider)
        {
            if (null == connectionStringProvider)
            {
                throw new ArgumentNullException(nameof(connectionStringProvider));
            }

            ServiceCollection.AddSingleton(typeof(IConnectionStringProvider), connectionStringProvider.GetType());

            ServiceCollection.AddTransient <DbContext, DbContext>();



            MongoClientProxy.SetConnectionString(connectionStringProvider.ConnectionString);

            var _db = MongoAdmin.GetDatabase(MongoClientProxy.Instance, connectionStringProvider.DatabaseName);

            InitializeMigration(_db);
        }
コード例 #49
0
ファイル: UpdateTests.cs プロジェクト: zulkamal/NoRM
        public void Dispose()
        {
            try
            {
                _server.Database.DropCollection("CheeseClubContacts");
            }
            catch (MongoException e)
            {
                if (e.Message != "ns not found")
                {
                    throw;
                }
            }

            using (var admin = new MongoAdmin("mongodb://localhost/NormTests?pooling=false"))
            {
                admin.DropDatabase();
            }
            _server.Dispose();
        }
コード例 #50
0
ファイル: MongoAdminTests.cs プロジェクト: zeya/NoRM
        public void DropsDatabase()
        {
            //create another database
            using (var mongo = Mongo.ParseConnection(ConnectionString("temp")))
            {
                mongo.GetCollection<FakeObject>().Insert(new FakeObject());
            }
            using (var admin = new MongoAdmin(ConnectionString("temp")))
            {
                admin.DropDatabase();
            }

            using (var admin = new MongoAdmin(ConnectionString()))
            {
                foreach (var db in admin.GetAllDatabases())
                {
                   Assert.NotEqual("temp", db.Name);
                }
            }
        }
コード例 #51
0
ファイル: MongoAdminTests.cs プロジェクト: zeya/NoRM
        public void ListsAllDatabases()
        {
            var expected = new List<string> {"admin", "temp", "local"};

            //create another database
            using (var mongo = Mongo.ParseConnection(ConnectionString("temp")))
            {
                mongo.GetCollection<FakeObject>().Insert(new FakeObject());
            }

            using (var admin = new MongoAdmin(ConnectionString()))
            {
                foreach (var db in admin.GetAllDatabases())
                {
                    Assert.Contains(db.Name, expected);
                    expected.Remove(db.Name);
                }
            }
            Assert.Equal(0, expected.Count);
        }
コード例 #52
0
ファイル: MongoAdminTests.cs プロジェクト: ereichert/NoRM
        public void DropsDatabase()
        {
            //create another database
            using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
            {
                mongo.GetCollection<FakeObject>().Insert(new FakeObject());
            }
            using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                admin.DropDatabase();
            }

            using (var admin = new MongoAdmin(TestHelper.ConnectionString(null, "admin", null, null)))
            {
                foreach (var db in admin.GetAllDatabases())
                {
                   Assert.NotEqual("NormTests", db.Name);
                }
            }
        }
コード例 #53
0
        public void DropsDatabase()
        {
            //create another database
            using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
            {
                mongo.GetCollection <FakeObject>().Insert(new FakeObject());
            }
            using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                admin.DropDatabase();
            }

            using (var admin = new MongoAdmin(TestHelper.ConnectionString(null, "admin", null, null)))
            {
                foreach (var db in admin.GetAllDatabases())
                {
                    Assert.NotEqual("NormTests", db.Name);
                }
            }
        }
コード例 #54
0
ファイル: UpdateTests.cs プロジェクト: gaoninggn/NoRM
        public void Dispose()
        {
            try
            {
                _server.Database.DropCollection("CheeseClubContacts");
            }
            catch(MongoException e)
            {
                if (e.Message != "ns not found")
                {
                    throw;
                }
            }

            using (var admin = new MongoAdmin("mongodb://localhost/NormTests?pooling=false"))
            {
                admin.DropDatabase();
            }
            _server.Dispose();
        }
コード例 #55
0
        public void ListsAllDatabases()
        {
            var expected = new List <string> {
                "admin", "NormTests", "local"
            };

            //create another database
            using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
            {
                mongo.GetCollection <FakeObject>().Insert(new FakeObject());
            }

            using (var admin = new MongoAdmin(TestHelper.ConnectionString(null, "admin", null, null)))
            {
                foreach (var db in admin.GetAllDatabases())
                {
                    expected.Remove(db.Name);
                }
            }
            Assert.Equal(0, expected.Count);
        }
コード例 #56
0
ファイル: MongoAdminTests.cs プロジェクト: ereichert/NoRM
 public void ListsAllDatabasesThrowsExceptionIfNotConnectedToAdmin()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
     {
         var ex = Assert.Throws<MongoException>(() => admin.GetAllDatabases());
         Assert.Equal("This command is only valid when connected to admin", ex.Message);
     }
 }
コード例 #57
0
ファイル: MongoAdminTests.cs プロジェクト: ereichert/NoRM
        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);
            }
        }
コード例 #58
0
ファイル: MongoAdminTests.cs プロジェクト: ereichert/NoRM
 public void ReturnsEmptyInProcessResponse()
 {
     using (var admin = new MongoAdmin(TestHelper.ConnectionString(null, "admin", null, null)))
     {
         var response = admin.GetCurrentOperations();
         Assert.Equal(0, response.Count());
     }
 }
コード例 #59
0
ファイル: MongoAdminTests.cs プロジェクト: ereichert/NoRM
        public void ListsAllDatabases()
        {
            var expected = new List<string> { "admin", "NormTests", "local" };

            //create another database
            using (var mongo = Mongo.Create(TestHelper.ConnectionString()))
            {
                mongo.GetCollection<FakeObject>().Insert(new FakeObject());
            }

            using (var admin = new MongoAdmin(TestHelper.ConnectionString(null, "admin", null, null)))
            {
                foreach (var db in admin.GetAllDatabases())
                {
                    expected.Remove(db.Name);
                }
            }
            Assert.Equal(0, expected.Count);
        }
コード例 #60
0
        public void Find_Subset_Returns_Appropriate_Subset()
        {
            using (var admin = new MongoAdmin(TestHelper.ConnectionString()))
            {
                admin.SetProfileLevel(2);
            }
            using (var db = Mongo.Create(TestHelper.ConnectionString()))
            {
                var coll = db.GetCollection<TestProduct>();
                coll.Delete(new { });
                var oid = ObjectId.NewObjectId();

                coll.Insert(new TestProduct
                {
                    _id = oid,
                    Price = 42.42f,
                    Supplier = new Supplier
                    {
                        Name = "Bob's house of pancakes",
                        RefNum = 12,
                        CreatedOn = DateTime.MinValue
                    }
                });

                var subset = db.GetCollection<TestProduct>().Find(new { }, new { }, Int32.MaxValue, 0,
                    j => new { SupplierName = j.Supplier.Name, Cost = j.Price, Id = j._id }).ToArray();

                Assert.Equal("Bob's house of pancakes", subset[0].SupplierName);
                Assert.Equal(42.42f, subset[0].Cost);
                Assert.Equal(oid, subset[0].Id);
            }
        }