public void DeclarativeViaTransactionProxyFactoryObject() { ITestObjectManager mgr = ctx["testObjectManagerTP"] as ITestObjectManager; ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDao"]; PerformOperations(mgr, dao); }
private static void ExecuteDaoOperations(ITestObjectDao dao) { TestObject toGeorge = new TestObject(); toGeorge.Name = "George"; toGeorge.Age = 33; dao.Create(toGeorge); TestObject to = dao.FindByName("George"); Assert.IsNotNull(to, "FindByName for George should not return null"); Assert.AreEqual("George", to.Name); Assert.AreEqual(33, to.Age); to.Age = 34; dao.Update(to); TestObject to2 = dao.FindByName("George"); Assert.AreEqual(34, to2.Age); dao.Delete(to); TestObject to3 = dao.FindByName("George"); Assert.IsNull(to3, "Should not have found TestObject with name George. TestObject = " + to.ToString()); }
public static void PerformOperations(ITestObjectManager mgr, ITestObjectDao dao) { Assert.IsNotNull(mgr); TestObject to1 = new TestObject(); to1.Name = "Jack"; to1.Age = 7; TestObject to2 = new TestObject(); to2.Name = "Jill"; to2.Age = 8; mgr.SaveTwoTestObjects(to1, to2); TestObject to = dao.FindByName("Jack"); Assert.IsNotNull(to); to = dao.FindByName("Jill"); Assert.IsNotNull(to); Assert.AreEqual("Jill", to.Name); mgr.DeleteTwoTestObjects("Jack", "Jill"); to = dao.FindByName("Jack"); Assert.IsNull(to); to = dao.FindByName("Jill"); Assert.IsNull(to); }
public static void PerformOperations(ITestObjectManager mgr, ITestObjectDao dao) { Assert.IsNotNull(mgr); TestObject to1 = new TestObject(); to1.Name = "Jack"; to1.Age = 7; TestObject to2 = new TestObject(); to2.Name = "Jill"; to2.Age = 8; mgr.SaveTwoTestObjects(to1, to2); TestObject to = dao.FindByName("Jack"); Assert.IsNotNull(to); to = dao.FindByName("Jill"); Assert.IsNotNull(to); Assert.AreEqual("Jill", to.Name); mgr.DeleteTwoTestObjects("Jack", "Jill"); to = dao.FindByName("Jack"); Assert.IsNull(to); to = dao.FindByName("Jill"); Assert.IsNull(to); }
private static void ExecuteAndRollbackDaoOperations(ITestObjectDao dao) { TestObject toBugs = new TestObject(); toBugs.Name = "Bugs"; toBugs.Age = 33; dao.CreateUpdateRollback(toBugs); }
public void DemoDao() { ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDaoViaTxAttributes"]; TestObject toGeorge = new TestObject(); toGeorge.Name = "George"; toGeorge.Age = 33; dao.Create(toGeorge); }
public void SimpleDao() { ITestObjectDao dao = (ITestObjectDao)ctx["NHTestObjectDao"]; Assert.IsNotNull(dao); TestObject to = dao.FindByName("Gabriel"); Assert.IsNotNull(to); Assert.AreEqual("Gabriel", to.Name); }
public void ExecuteTemplate() { ITestObjectDao dao = (ITestObjectDao)ctx["NHTestObjectDao"]; TransactionTemplate tt = new TransactionTemplate(transactionManager); object result = tt.Execute(new SimpleTransactionCallback(dbProvider, dao)); TestObject to = result as TestObject; Assert.IsNotNull(to, "FindByName for Gabriel should not return null"); Assert.AreEqual("Gabriel", to.Name); }
private void zzzExecuteDaoOperations() { ITestObjectDao dao = (ITestObjectDao)ctx["SimpleTestDao"]; TestObject toGeorge = new TestObject(); toGeorge.Name = "George"; toGeorge.Age = 33; dao.Create(toGeorge); }
public void SimpleCreate() { IApplicationContext ctx = new XmlApplicationContext("assembly://Spring.Data.Integration.Tests/Spring.Data/nativeAdoTests.xml"); Assert.IsNotNull(ctx); ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDao"]; Assert.IsNotNull(dao); dao.Create("John", 44); }
public static void PerformOperations(ITestCoordinator coordinator, ITestObjectDao dao) { TestObject to1 = new TestObject(); to1.Name = "Jack"; to1.Age = 7; TestObject to2 = new TestObject(); to2.Name = "Jill"; to2.Age = 8; coordinator.WorkOn(to1, to2); coordinator.TestObjectManager.DeleteTwoTestObjects("Jack", "Jill"); }
public void CreateNative() { IApplicationContext ctx; string assemblyName = GetType().Assembly.GetName().Name; ctx = new XmlApplicationContext("assembly://" + assemblyName + "/Spring.Data.NHibernate/templateTests.xml"); ITestObjectDao dao = (ITestObjectDao)ctx.GetObject("nativeNHTestObjectDao"); TestObject toGeorge = new TestObject(); toGeorge.Name = "George"; toGeorge.Age = 34; dao.Create(toGeorge); }
public static void PerformOperations(ITestCoordinator coordinator, ITestObjectDao dao) { TestObject to1 = new TestObject(); to1.Name = "Jack"; to1.Age = 7; TestObject to2 = new TestObject(); to2.Name = "Jill"; to2.Age = 8; coordinator.WorkOn(to1, to2); coordinator.TestObjectManager.DeleteTwoTestObjects("Jack", "Jill"); }
public void DaoOperationsWithRollback() { ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDaoTransProxy"]; try { ExecuteAndRollbackDaoOperations(dao); } catch (Exception e) { TestObject to = dao.FindByName("Bugs"); Assert.IsNull(to); //just to get rid of compiler warning... Assert.IsNotNull(e); } }
public void UserCredentialsDbProvider() { ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDaoTransProxy"]; userCredentialsDbProvider.SetCredentialsForCurrentThread("User ID=springqa", "Password=springqa"); TestObject toGeorge = new TestObject(); toGeorge.Name = "George"; toGeorge.Age = 33; dao.Create(toGeorge); userCredentialsDbProvider.SetCredentialsForCurrentThread("User ID=springqa2", "Password=springqa2"); TestObject toMary = new TestObject(); toMary.Name = "Mary"; toMary.Age = 34; dao.Create(toMary); }
public void ExecuteTransactionManager() { DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.PropagationBehavior = TransactionPropagation.Required; ITransactionStatus status = transactionManager.GetTransaction(def); ITestObjectDao dao = (ITestObjectDao)ctx["NHTestObjectDao"]; TestObject to; try { to = dao.FindByName("Gabriel"); } catch (Exception) { transactionManager.Rollback(status); throw; } transactionManager.Commit(status); Assert.IsNotNull(to, "FindByName for Gabriel should not return null"); Assert.AreEqual("Gabriel", to.Name); }
public SimpleTransactionCallback(IDbProvider dbp, ITestObjectDao dao) { dbProvider = dbp; this.dao = dao; }
private static void ExecuteAndRollbackDaoOperations(ITestObjectDao dao) { TestObject toBugs = new TestObject(); toBugs.Name = "Bugs"; toBugs.Age = 33; dao.CreateUpdateRollback(toBugs); }
private static void ExecuteDaoOperations(ITestObjectDao dao) { TestObject toGeorge = new TestObject(); toGeorge.Name = "George"; toGeorge.Age = 33; dao.Create(toGeorge); TestObject to = dao.FindByName("George"); Assert.IsNotNull(to, "FindByName for George should not return null"); Assert.AreEqual("George", to.Name); Assert.AreEqual(33, to.Age); to.Age=34; dao.Update(to); TestObject to2 = dao.FindByName("George"); Assert.AreEqual(34, to2.Age); dao.Delete(to); TestObject to3 = dao.FindByName("George"); Assert.IsNull(to3, "Should not have found TestObject with name George. TestObject = " + to.ToString() ); }
public SimpleTransactionCallback(IDbProvider dbp, ITestObjectDao dao) { dbProvider = dbp; this.dao = dao; }
public void DaoOperationsViaTransactionProxy() { ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDaoTransProxy"]; ExecuteDaoOperations(dao); }
public void DaoOperationsViaProxyFactoryWithTxAttributes() { ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDaoViaTxAttributes"]; ExecuteDaoOperations(dao); }