Example #1
0
        public void TestSuccessiveConnections()
        {
            var adapter = new MySQLCommandChannelFactory().Create(new CreationParameters <MySqlConnectionStringBuilder>(Credentials, "CREATE TABLE a (b TEXT)", true));

            adapter.Execute("INSERT INTO a VALUES ('c')");
            adapter = new MySQLCommandChannelFactory().Create(new CreationParameters <MySqlConnectionStringBuilder>(Credentials, "CREATE TABLE a (b TEXT)", true));
            Assert.AreEqual(0, adapter.FetchLines("SELECT * FROM a").Count);
        }
Example #2
0
        public void TestMultithreading()
        {
            var mainAdapter = new MySQLCommandChannelFactory().Create(new CreationParameters <MySqlConnectionStringBuilder>(Credentials, "CREATE TABLE a (b TEXT)", true));

            var t1 = new Thread(() =>
            {
                var adapter = new MySQLCommandChannelFactory().Open(Credentials);
                foreach (var _ in Enumerable.Repeat(0, 50))
                {
                    adapter.Execute("INSERT INTO a VALUES ('c')");
                }
            });

            var t2 = new Thread(() =>
            {
                var adapter = new MySQLCommandChannelFactory().Open(Credentials);
                foreach (var _ in Enumerable.Repeat(0, 50))
                {
                    adapter.Execute("INSERT INTO a VALUES ('c')");
                }
            });

            var t3 = new Thread(() =>
            {
                var adapter = new MySQLCommandChannelFactory().Open(Credentials);
                foreach (var _ in Enumerable.Repeat(0, 50))
                {
                    adapter.Execute("INSERT INTO a VALUES ('c')");
                }
            });

            t1.Start();
            t2.Start();
            t3.Start();

            t1.Join();
            t2.Join();
            t3.Join();

            Assert.AreEqual(150, mainAdapter.FetchLines("SELECT * FROM a").Count);
        }