public void Test()
        {
            TestObject object1 = TestObject.NewRandom();

            _test1.Insert(object1);
            AssertHelper.AreEqual(_testObjectDao.SelectById(object1.Id), object1);
        }
예제 #2
0
        public void TestNoTransaction()
        {
            ISqlMapper    sqlMapper     = new DomSqlMapBuilder().Configure("IBatisNet.config");
            TestObjectDao testObjectDao = new TestObjectDao(sqlMapper);

            TestObject object1 = TestObject.NewRandom();

            testObjectDao.Insert(object1);
            Assert.Throws <SqlException>(() => testObjectDao.Insert(object1));
        }
예제 #3
0
        public void TestMixed()
        {
            TestObject object1 = TestObject.NewRandom();
            TestObject object2 = TestObject.NewRandom();
            TestObject object3 = TestObject.NewRandom();

            try { _test.TestMixed(object1, object2, object3); } catch { }
            AssertHelper.AreEqual(_testObjectDao.SelectById(object1.Id), object1);
            Assert.IsNull(_testObjectDao.SelectById(object2.Id));
            AssertHelper.AreEqual(_testObjectDao.SelectById(object3.Id), object3);
        }
        public void TestObjectCRUD()
        {
            TestObject object1 = TestObject.NewRandom();

            _testObjectDao.Insert(object1);

            TestObject object2 = _testObjectDao.SelectById(object1.Id);

            AssertHelper.AreEqual(object1, object2);

            _testObjectDao.DeleteById(object1.Id);
            Assert.IsNull(_testObjectDao.SelectById(object1.Id));
        }
예제 #5
0
        public void TestInsertSuccess(Action <TestObject> action)
        {
            TestObject object1 = TestObject.NewRandom();

            try
            {
                action(object1);   //SqlException : Violation of PRIMARY KEY constraint
            }
            catch
            {
            }
            AssertHelper.AreEqual(_testObjectDao.SelectById(object1.Id), object1);
        }
예제 #6
0
        public void TestInsertFaild(Action <TestObject> action)
        {
            TestObject object1 = TestObject.NewRandom();

            try
            {
                action(object1);   //SqlException : Violation of PRIMARY KEY constraint
            }
            catch
            {
            }
            Assert.IsNull(_testObjectDao.SelectById(object1.Id));
        }
        public void Test2()
        {
            TestObject object1 = TestObject.NewRandom();

            try
            {
                _test1.Insert2(object1);
            }
            catch
            {
            }
            Assert.IsNull(_testObjectDao.SelectById(object1.Id));
        }
예제 #8
0
        public void TestTransaction2()
        {
            ISqlMapper    sqlMapper     = new DomSqlMapBuilder().Configure("IBatisNet.config");
            TestObjectDao testObjectDao = new TestObjectDao(sqlMapper);
            TestObject    object1       = TestObject.NewRandom();

            try
            {
                //using... syntax
                using (IDalSession session = sqlMapper.BeginTransaction())
                {
                    testObjectDao.Insert(object1);
                    testObjectDao.Insert(object1);
                    session.Complete();
                }
            }
            catch { }

            TestObject object2 = testObjectDao.SelectById(object1.Id);

            Assert.IsNull(object2);
        }
예제 #9
0
        public void TestTransaction1()
        {
            ISqlMapper    sqlMapper     = new DomSqlMapBuilder().Configure("IBatisNet.config");
            TestObjectDao testObjectDao = new TestObjectDao(sqlMapper);
            TestObject    object1       = TestObject.NewRandom();

            //try...catch... syntax
            try
            {
                sqlMapper.BeginTransaction();
                testObjectDao.Insert(object1);
                testObjectDao.Insert(object1);
                sqlMapper.CommitTransaction();
            }
            catch
            {
                sqlMapper.RollBackTransaction();
            }

            TestObject object2 = testObjectDao.SelectById(object1.Id);

            Assert.IsNull(object2);
        }