Пример #1
0
        public void CanOverrideMongoDriver()
        {
            MongoDBDriver <BsonDocument> tempDriver = new MongoDBDriver <BsonDocument>();

            this.MongoDBDriver = tempDriver;

            Assert.AreEqual(this.TestObject.MongoDBManager.Get(), tempDriver);
        }
Пример #2
0
        public void RespectNewDriverOverride()
        {
            var mongoDriver = new MongoDBDriver <BsonDocument>(MongoDBConfig.GetCollectionString());

            this.TestObject.OverrideMongoDBDriver(mongoDriver);

            Assert.AreEqual(mongoDriver.Collection, this.MongoDBDriver.Collection);
        }
Пример #3
0
        public void RespectDirectDriverOverride()
        {
            var mongoDriver = new MongoDBDriver <BsonDocument>(MongoDBConfig.GetCollectionString());

            this.MongoDBDriver = mongoDriver;

            Assert.AreEqual(mongoDriver.Collection, this.MongoDBDriver.Collection);
        }
Пример #4
0
        public void RespectDriverConnectionsOverride()
        {
            var mongoDriver = new MongoDBDriver <BsonDocument>(MongoDBConfig.GetConnectionString(), MongoDBConfig.GetDatabaseString(), MongoDBConfig.GetCollectionString());

            this.TestObject.MongoDBManager.OverrideDriver(mongoDriver);

            Assert.AreEqual(mongoDriver.Collection, this.MongoDBDriver.Collection);
        }
Пример #5
0
        public void RespectDefaultDriverOverride()
        {
            var mongoDriver = new MongoDBDriver <BsonDocument>();

            this.TestObject.MongoDBManager.OverrideDriver(mongoDriver);

            Assert.AreEqual(mongoDriver.Collection, this.MongoDBDriver.Collection);
            Assert.AreEqual(mongoDriver.Collection.Database, this.MongoDBDriver.Database);
            Assert.AreEqual(mongoDriver.Collection.Database.Client, this.MongoDBDriver.Client);
        }
Пример #6
0
        public void OverrideWithCustomDriver()
        {
            var firstDriver = this.MongoDBDriver;
            var newDriver   = new MongoDBDriver <BsonDocument>(MongoFactory.GetCollection <BsonDocument>(MongoDBConfig.GetConnectionString(), MongoDBConfig.GetDatabaseString(), null, MongoDBConfig.GetCollectionString()));

            this.TestObject.OverrideMongoDBDriver(newDriver);

            Assert.AreNotEqual(firstDriver, this.MongoDBDriver);
            Assert.AreEqual(newDriver, this.MongoDBDriver);
            Assert.IsFalse(this.MongoDBDriver.IsCollectionEmpty());
        }
Пример #7
0
        public void OverrideDriver()
        {
            var firstDriver = this.MongoDBDriver;
            var newDriver   = new MongoDBDriver <BsonDocument>(MongoFactory.GetDefaultCollection <BsonDocument>());

            this.TestObject.OverrideMongoDBDriver(newDriver);

            Assert.AreNotEqual(firstDriver, this.MongoDBDriver);
            Assert.AreEqual(newDriver, this.MongoDBDriver);
            Assert.IsFalse(this.MongoDBDriver.IsCollectionEmpty());
        }
Пример #8
0
        public TestMongoDB()
        {
            Car car = new Car
            {
                veichle     = "Fiesta",
                vendor      = "Ford",
                year        = 2008,
                description = "Ford Fiesta 2008 1.6",
                sold        = false,
                createdAt   = DateTime.Now,
                updatedAt   = DateTime.Now
            };

            MongoDBDriver db = new MongoDBDriver();

            db.OperateCar(ref car, DaoOperations.Insert);

            List <Car> result = (List <Car>)(db.OperateCar(ref car, DaoOperations.Search).data);
            bool       ok     = result.Count > 0;
            string     a      = ok.ToString();

            ok = bool.Parse(a);
        }