Beispiel #1
0
        public void InsertALot()
        {
            int n = 10000;
            IEnumerable <TestObj> q = from i in Enumerable.Range(1, n)
                                      select new TestObj
            {
                Text = "I am"
            };

            TestObj[] objs = q.ToArray();
            _db.TraceListener = DebugTraceListener.Instance;

            var sw = new Stopwatch();

            sw.Start();

            int numIn = _db.InsertAll(objs);

            sw.Stop();

            Assert.AreEqual(numIn, n, "Num inserted must = num objects");

            TestObj[] inObjs = _db.CreateCommand("select * from TestObj").ExecuteQuery <TestObj>().ToArray();

            for (int i = 0; i < inObjs.Length; i++)
            {
                Assert.AreEqual(i + 1, objs[i].Id);
                Assert.AreEqual(i + 1, inObjs[i].Id);
                Assert.AreEqual("I am", inObjs[i].Text);
            }

            var numCount = _db.CreateCommand("select count(*) from TestObj").ExecuteScalar <int>();

            Assert.AreEqual(numCount, n, "Num counted must = num objects");
        }