Beispiel #1
0
 public void Setup()
 {
     _server = Configuration.TestServer;
     _server.Connect();
     _database = Configuration.TestDatabase;
     _database.Drop();
 }
 public void Setup()
 {
     _server = Configuration.TestServer;
     _primary = Configuration.TestServer.Primary;
     _database = Configuration.TestDatabase;
     _database.Drop();
 }
 public void TestDatabaseExists()
 {
     _database.Drop();
     Assert.IsFalse(_server.DatabaseExists(_database.Name));
     _collection.Insert(new BsonDocument("x", 1));
     Assert.IsTrue(_server.DatabaseExists(_database.Name));
 }
 private static void CreateLaptopFactoryDatabase(MongoDatabase db)
 {
     db.Drop();
     CreateMakersTable(db);
     CreateModelsTable(db);
     CreateLaptopsTable(db);
 }
Beispiel #5
0
        public bool Connect2MongoDB(string ip, string port, string dbName)
        {
            string source = "mongodb://" + ip + ":" + " :" + port;


            try
            {
                mMongoClient = new MongoClient();
                mMongoServer = mMongoClient.GetServer();
                mMongoDB     = mMongoServer.GetDatabase(dbName);
                mMongoDB.Drop();
                // mMongoDB.CreateCollection(dbName);
            }
            catch (Exception ex)
            {
                return(false);
            }
            //BmClassBuilder MCB = new BmClassBuilder("BookStore");
            //var myclass = MCB.CreateObject(new string[5] { "Id", "BookTitle", "Auther", "Category", "ISBN" }, new Type[5] { typeof(ObjectId), typeof(string), typeof(string), typeof(string), typeof(string) });
            //var myObject = Activator.CreateInstance(myclass.GetType());

            //myclass.GetType().GetProperty("BookTitle", BindingFlags.Public | BindingFlags.Instance).SetValue(myObject, "dddMongoDB Basics", null);
            //myclass.GetType().GetProperty("ISBN", BindingFlags.Public | BindingFlags.Instance).SetValue(myObject, "8767687689898yu", null);
            //myclass.GetType().GetProperty("Auther", BindingFlags.Public | BindingFlags.Instance).SetValue(myObject, "Tanya", null);
            //myclass.GetType().GetProperty("Category", BindingFlags.Public | BindingFlags.Instance).SetValue(myObject, "NoSQL DBMS", null);
            //var collection = mMongoDB.GetCollection("BookStore");


            //    collection.Save(myObject);



            return(true);
        }
Beispiel #6
0
        public static void Seed()
        {
            db.Drop();

            List <Category> categories         = GenerateCategories();
            var             categoryCollection = db.GetCollection("Categories");

            categoryCollection.InsertBatch <Category>(categories);

            List <Product> products          = GenerateProducts();
            var            productCollection = db.GetCollection("Products");

            productCollection.InsertBatch <Product>(products);

            List <CustomerStatus> customerStatuses = GenerateCustomerStatuses();
            var customerStatusCollection           = db.GetCollection("CustomerStatuses");

            customerStatusCollection.InsertBatch <CustomerStatus>(customerStatuses);

            List <Customer> customers          = GenerateCustomers();
            var             customerCollection = db.GetCollection("Customers");

            customerCollection.InsertBatch <Customer>(customers);

            List <Position> positions          = GeneratePositions();
            var             positionCollection = db.GetCollection("Positions");

            positionCollection.InsertBatch <Position>(positions);

            List <Employee> employees          = GenerateEmployees();
            var             employeeCollection = db.GetCollection("Employees");

            employeeCollection.InsertBatch <Employee>(employees);
        }
 public void Setup()
 {
     _server   = Configuration.TestServer;
     _primary  = Configuration.TestServer.Primary;
     _database = Configuration.TestDatabase;
     _database.Drop();
 }
Beispiel #8
0
 public void Setup()
 {
     _server   = LegacyTestConfiguration.Server;
     _primary  = LegacyTestConfiguration.Server.Primary;
     _database = LegacyTestConfiguration.Database;
     _database.Drop();
 }
 public void Setup()
 {
     _server = Configuration.TestServer;
     _server.Connect();
     _database = Configuration.TestDatabase;
     _database.Drop();
 }
Beispiel #10
0
        public void setUp()
        {
            using (FileStream f = File.OpenRead("Penguins.jpg"))
                using (BinaryReader r = new BinaryReader(f))
                {
                    imageRawData = r.ReadBytes((int)f.Length);
                }

            CloudServer.BaseUrl = "http://*****:*****@waveface.com",
                user_id = "driver1_id",
                folder  = @"resource\group1",
                groups  = groups
            }
                );

            if (!Directory.Exists(@"resource\group1"))
            {
                Directory.CreateDirectory(@"resource\group1");
            }
        }
        void DropDb()
        {
            var url    = new MongoUrl(_eventStoreConnectionString);
            var client = new MongoClient(url);

            Database = client.GetServer().GetDatabase(url.DatabaseName);
            Database.Drop();
        }
Beispiel #12
0
 public void TestDropDatabaseClearsIndexCache()
 {
     _server.IndexCache.Reset();
     _collection.EnsureIndex("x");
     Assert.IsTrue(_server.IndexCache.Contains(_collection, "x_1"));
     _database.Drop();
     Assert.IsFalse(_server.IndexCache.Contains(_collection, "x_1"));
 }
Beispiel #13
0
        public void SetUp()
        {
            TimeMachine.Reset();

            db = MongoDatabase.Create(ConnectionStrings.MongoDb);
            db.Drop();

            DoSetUp();
        }
Beispiel #14
0
        public void SetUp()
        {
            TimeMachine.Reset();

            db = MongoHelper.GetDatabase(ConnectionStrings.MongoDb);
            db.Drop();

            DoSetUp();
        }
        public void SetUp()
        {
            var url    = new MongoUrl(ConfigurationManager.ConnectionStrings["system"].ConnectionString);
            var client = new MongoClient(url);

            _db = client.GetServer().GetDatabase(url.DatabaseName);
            _db.Drop();
            _service = new CounterService(_db);
        }
        public IStoreSagaData CreatePersister()
        {
            db = MongoHelper.GetDatabase(ConnectionStrings.MongoDb);
            
            db.Drop();

            return new MongoDbSagaPersister(ConnectionStrings.MongoDb)
                .AllowAutomaticSagaCollectionNames();
        }
Beispiel #17
0
        void DropDb()
        {
            var url    = new MongoUrl(_eventStoreConnectionString);
            var client = new MongoClient(url);

            Database     = client.GetServer().GetDatabase(url.DatabaseName);
            _checkpoints = Database.GetCollection <Checkpoint>("checkpoints");
            Database.Drop();
        }
        public IStoreSagaData CreatePersister()
        {
            db = MongoHelper.GetDatabase(ConnectionStrings.MongoDb);

            db.Drop();

            return(new MongoDbSagaPersister(ConnectionStrings.MongoDb)
                   .AllowAutomaticSagaCollectionNames());
        }
Beispiel #19
0
        public static void ClearMongoDB()
        {
            var mongoClient = new MongoClient(MongoDB_ConnectionString);
            //MongoServer server = MongoServer.Create(MongoDB_ConnectionString);
            var           server   = mongoClient.GetServer();
            MongoDatabase database = server.GetDatabase(MongoDB_Database);

            database.Drop();
            server.Disconnect();
        }
        public void TestGetCollectionNames()
        {
            _database.Drop();
            _database["a"].Insert(new BsonDocument("a", 1));
            _database["b"].Insert(new BsonDocument("b", 1));
            _database["c"].Insert(new BsonDocument("c", 1));
            var collectionNames = _database.GetCollectionNames();

            Assert.AreEqual(new[] { "a", "b", "c", "system.indexes" }, collectionNames);
        }
Beispiel #21
0
        private void ExecuteMethod(MongoDatabase obj)
        {
            DatabaseAction dba = new DatabaseAction();

            dba.Action       = ActionType.Drop;
            dba.DatabaseName = obj.Name;
            dba.Server       = obj.Server;
            obj.Drop();
            _eventAggregator.GetEvent <PubSubEvent <DatabaseAction> >().Publish(dba);
        }
        public void TestGetCollectionNames()
        {
            _database.Drop();
            _database.GetCollection("a").Insert(new BsonDocument("a", 1));
            _database.GetCollection("b").Insert(new BsonDocument("b", 1));
            _database.GetCollection("c").Insert(new BsonDocument("c", 1));
            var collectionNames = _database.GetCollectionNames();

            Assert.AreEqual(new[] { "a", "b", "c" }, collectionNames.Where(n => n != "system.indexes"));
        }
        public void MyTestInitialize()
        {
            m_Testdb = new MongoDBForTest().DB;
            m_Testdb.Drop();

            m_mocked = new Mock<IServicesLayer>();
            m_MocServiceLayer = m_mocked.Object;
            m_mockedBackOffice = new Mock<IBackofficeService>();
            m_MocBackOfficeService = m_mockedBackOffice.Object;
            m_imageService = new ImageServices();
        }
Beispiel #24
0
        public static void ClearMongoDB()
        {
            var mongoClient = new MongoClient(MongoDB_ConnectionString);

            //MongoServer server = MongoServer.Create(MongoDB_ConnectionString);
#pragma warning disable 0618
            var server = mongoClient.GetServer();
#pragma warning restore
            MongoDatabase database = server.GetDatabase(MongoDB_Database);
            database.Drop();
            server.Disconnect();
        }
Beispiel #25
0
        public void SetUp()
        {
            file = new byte[20];
            for (int i = 0; i < file.Length; i++)
            {
                file[i] = (byte)i;
            }
            filename = Encoding.UTF8.GetBytes("file1.jpg");
            filetype = Encoding.UTF8.GetBytes("100");
            oid      = Encoding.UTF8.GetBytes("object_id1");

            filePart     = CreatePart(file);
            filenamePart = CreatePart(filename);
            filetypePart = CreatePart(filetype);
            oidPart      = CreatePart(oid);

            parts.Clear();
            parts.Add(filePart);
            parts.Add(filenamePart);
            parts.Add(filetypePart);
            parts.Add(oidPart);

            MongoDatabase db = mongo.GetDatabase("wammer");

            db.Drop();

            List <UserGroup> groups = new List <UserGroup>();

            groups.Add(new UserGroup {
                group_id = "group1", description = "group1 descript", creator_id = "driver1_id", name = "group1"
            });
            DriverCollection.Instance.Save(
                new Driver {
                email   = "*****@*****.**",
                user_id = "driver1_id",
                folder  = @"resource\group1",
                groups  = groups
            }
                );

            CloudServer.BaseUrl = "http://localhost/v2/";

            cloudResponse = new ObjectUploadResponse
            {
                api_ret_code    = 0,
                api_ret_message = "success",
                status          = 200,
                timestamp       = DateTime.UtcNow
            };

            Directory.CreateDirectory("log");
        }
        public void SetUp()
        {
            var url = new MongoUrl(DB_URL);
            testDB = new MongoClient(url).GetServer().GetDatabase(url.DatabaseName);
            testDB.Drop();

            var sampleRaw = BsonDocument.Parse(GetSampleRawAct());
            SAMPLE_RAW_USER = sampleRaw["UserID"].AsString.ToLowerInvariant();
            SAMPLE_RAW_LESSON = sampleRaw["LessonID"].AsString.ToLowerInvariant();

            Assert.IsFalse(String.IsNullOrWhiteSpace(SAMPLE_RAW_USER));
            Assert.IsFalse(String.IsNullOrWhiteSpace(SAMPLE_RAW_LESSON));
        }
        public void ResetDatabase(bool force = false)
        {
            if (_databaseReset && !force)
            {
                return;
            }

            _database.Drop();
            _manager.InitializeRepositories();
            _sampleProjectsAdded      = false;
            _sampleOrganizationsAdded = false;

            _databaseReset = true;
        }
Beispiel #28
0
        public void SetUp()
        {
            var url = new MongoUrl(DB_URL);

            testDB = new MongoClient(url).GetServer().GetDatabase(url.DatabaseName);
            testDB.Drop();

            var sampleRaw = BsonDocument.Parse(GetSampleRawAct());

            SAMPLE_RAW_USER   = sampleRaw["UserID"].AsString.ToLowerInvariant();
            SAMPLE_RAW_LESSON = sampleRaw["LessonID"].AsString.ToLowerInvariant();

            Assert.IsFalse(String.IsNullOrWhiteSpace(SAMPLE_RAW_USER));
            Assert.IsFalse(String.IsNullOrWhiteSpace(SAMPLE_RAW_LESSON));
        }
Beispiel #29
0
        public void SetUp()
        {
            Current = new Tenant(new TenantATestSettings());

            var connectionString = ConfigurationManager.ConnectionStrings["eventstore"].ConnectionString;
            var url    = new MongoUrl(connectionString);
            var client = new MongoClient(url);

            _db = client.GetServer().GetDatabase(url.DatabaseName);
            _db.Drop();

            _identityConverter = new IdentityManager(new InMemoryCounterService());
            _identityConverter.RegisterIdentitiesFromAssembly(GetType().Assembly);
            var loggerFactory = Substitute.For <ILoggerFactory>();

            loggerFactory.Create(Arg.Any <Type>()).Returns(NullLogger.Instance);
            _eventStore = new EventStoreFactory(loggerFactory).BuildEventStore(connectionString);
            _repository = CreateRepository();
        }
Beispiel #30
0
        public void AskForReplay(AskForReplayCommand command)
        {
            // ask the engine to perform a complete event replay
            _logger.Debug("Commits Replay Start");

            // ugly: let's drop the query model database for this test command
            _db.Drop();

            // get all the commits and related events
            var commitList = _store.Advanced.GetFrom(DateTime.MinValue);

            _logger.Debug(string.Format("Processing {0} commits", commitList.Count()));

            // first attempt use our original IDomainEventRouter to send the events to our eventhandlers

            foreach (var commit in commitList)
            {
                if (commit.Headers.Count > 0)
                {
                    _logger.Debug(string.Format("Commit Header {0}", DumpDictionaryToString(commit.Headers)));
                }

                foreach (var committedEvent in commit.Events)
                {
                    _logger.Debug(string.Format("Replaying event: {0}", committedEvent.Body.ToString()));

                    if (committedEvent.Headers.Count > 0)
                    {
                        _logger.Debug(string.Format("Event Header {0}", DumpDictionaryToString(committedEvent.Headers)));
                    }

                    // it has side effects, like generating new commits on the eventstore
                    //OriginalDomainEventRouter.Dispatch(committedEvent.Body);
                    SpecificDomainEventRouter.Dispatch(committedEvent.Body);

                    _logger.Debug("Event Replay Completed");
                }
            }

            _logger.Debug("Commits Replay Completed");
        }
Beispiel #31
0
 public void MyTestInitialize()
 {
     m_Testdb = new MongoDBForTest().DB;
     m_Testdb.Drop();
 }
 public static void ClearDatabase(MongoDatabase db)
 {
     db.Drop();
 }
 public void TeardownContext()
 {
     _database.Drop();
 }
 public void TestFixtureTearDown()
 {
     _db.Drop();
 }
        public void setUp()
        {
            if (!Directory.Exists("resource"))
            {
                Directory.CreateDirectory("resource");
            }

            object_id1 = Guid.NewGuid();
            object_id2 = Guid.NewGuid();

            FileStream fs = File.Open("resource/" + object_id1.ToString() + ".png", FileMode.Create);

            using (StreamWriter w = new StreamWriter(fs))
            {
                w.Write("1234567890");
            }
            fs.Close();

            fs = File.Open("resource/" + object_id1.ToString() + "_medium.jpeg", FileMode.Create);
            using (StreamWriter w = new StreamWriter(fs))
            {
                w.Write("abcde");
            }
            fs.Close();

            MongoDatabase db = mongodb.GetDatabase("wammer");

            if (db.CollectionExists("attachments"))
            {
                db.Drop();
            }

            db.CreateCollection("attachments");

            db.GetCollection <Attachment>("attachments").Insert(new Attachment
            {
                object_id  = object_id1.ToString(),
                group_id   = "group1",
                mime_type  = "image/png",
                file_size  = 10,
                image_meta = new ImageProperty
                {
                    medium = new ThumbnailInfo
                    {
                        mime_type = "image/jpeg",
                        file_size = 5
                    }
                }
            });

            db.GetCollection <Attachment>("attachments").Insert(new Attachment
            {
                object_id  = object_id2.ToString(),
                type       = AttachmentType.image,
                image_meta = new ImageProperty
                {
                    medium = new ThumbnailInfo
                    {
                        mime_type = "image/jpeg",
                        file_size = 5
                    }
                }
            });

            DriverCollection.Instance.Save(
                new Driver
            {
                email   = "*****@*****.**",
                user_id = "driver1_id",
                folder  = "resource",
                groups  = new List <UserGroup>
                {
                    new UserGroup {
                        group_id    = "group1",
                        description = "group1 descript",
                        creator_id  = "driver1_id",
                        name        = "group1"
                    }
                }
            }
                );
        }
 public void SetUp()
 {
     _db.Drop();
 }
Beispiel #37
0
 public void MyTestInitialize()
 {
     m_Testdb = new TestDB().DB;
     m_Testdb.Drop();
 }
Beispiel #38
0
 public void CleanUp()
 {
     _mongoDatabase.Drop();
     _mongoDatabase = null;
 }
 public void Dispose()
 {
     db.Drop();
 }