public void Test() { TestObject object1 = TestObject.NewRandom(); _test1.Insert(object1); AssertHelper.AreEqual(_testObjectDao.SelectById(object1.Id), object1); }
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)); }
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)); }
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); }
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)); }
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); }
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); }