예제 #1
0
		/// <summary>
		/// Verify that the input account is equal to the account(id=1).
		/// </summary>
		/// <param name="account">An account object</param>
		protected void AssertAccount5(Account account)
		{
			Assert.AreEqual(5, account.Id, "account.Id");
			Assert.AreEqual("Gilles", account.FirstName, "account.FirstName");
			Assert.AreEqual("Bayon", account.LastName, "account.LastName");
			Assert.AreEqual("*****@*****.**", account.EmailAddress, "account.EmailAddress");
		}
예제 #2
0
		public void TransactionalUsage()
		{
			container = CreateConfiguredContainer();
			container.AddFacility("IBatisNet", new IBatisNetFacility());
			container.AddFacility("transaction", new TransactionFacility());

			container.AddComponent("AccountDao", typeof (IAccountDao), typeof (AccountDao));
			container.AddComponent("Service", typeof (IService), typeof (Service));

			ResetDatabase();
			IService service = container["Service"] as IService;

			Account account = new Account();
			account.Id = 999;
			account.EmailAddress = "*****@*****.**";
			account.FirstName = "Gilles";
			account.LastName = "Bayon";

			service.InsertTransactionalAccount(account);
			account = null;
			account = service.GetAccountWithSpecificDataMapper(999) as Account;

			Assert.IsNotNull(account);
			Assert.AreEqual(999, account.Id, "account.Id");
		}
예제 #3
0
		/// <summary>
		/// Verify that the input account is equal to the account(id=5).
		/// </summary>
		/// <param name="account">An account object</param>
		protected void AssertAccount1(Account account)
		{
			Assert.AreEqual(1, account.Id, "account.Id");
			Assert.AreEqual("Joe", account.FirstName, "account.FirstName");
			Assert.AreEqual("Dalton", account.LastName, "account.LastName");
			Assert.AreEqual("*****@*****.**", account.EmailAddress, "account.EmailAddress");
		}
예제 #4
0
		public void Usage()
		{
			IWindsorContainer container = CreateConfiguredContainer();
			container.AddFacility("IBatisNet", new IBatisNetFacility());

			SqlMapper sqlMap = container[DATA_MAPPER] as SqlMapper;

			using (IDalSession session = sqlMap.OpenConnection())
			{
				Account account = new Account();
				account.Id = 99;
				account.EmailAddress = "*****@*****.**";
				account.FirstName = "Gilles";
				account.LastName = "Bayon";

				sqlMap.Insert("InsertAccount", account);
				account = null;
				account = sqlMap.QueryForObject("GetAccount", 99) as Account;

				Assert.AreEqual(99, account.Id, "account.Id");
			}
		}
예제 #5
0
		public void CommonUsage()
		{
			container = CreateConfiguredContainer();
			container.AddFacility("IBatisNet", new IBatisNetFacility());

			container.AddComponent("AccountDao", typeof (IAccountDao), typeof (AccountDao));

			ResetDatabase();

			IAccountDao dao = container["AccountDao"] as AccountDao;
			Account account = new Account();
			account.Id = 99;
			account.EmailAddress = "*****@*****.**";
			account.FirstName = "Gilles";
			account.LastName = "Bayon";

			dao.InsertAccount(account);
			account = null;
			account = dao.GetAccount(99) as Account;

			Assert.IsNotNull(account);
			Assert.AreEqual(99, account.Id, "account.Id");
		}
예제 #6
0
		public void InsertTransactionalAccountWithError(Account account)
		{
			_accountDao.InsertAccount(account);

			throw new ApplicationException("Ugh!");
		}
예제 #7
0
		public void InsertTransactionalAccount(Account account)
		{
			_accountDao.InsertAccount(account);
		}
예제 #8
0
		public void InsertAccount(Account account)
		{
			_accountDao.InsertAccount(account);
		}
예제 #9
0
		public void InsertAccount(Account account)
		{
			_sqlMap.Insert("InsertAccount", account);
		}
예제 #10
0
		public void ExecuteMethodUntilSignal()
		{
			Random _random = new Random();
			_startEvent.WaitOne(int.MaxValue, false);

			while (!_stopEvent.WaitOne(1, false))
			{
				int id = _random.Next();
				Account account = new Account();
				account.Id = id;
				account.EmailAddress = "*****@*****.**";
				account.FirstName = "Gilles";
				account.LastName = "Bayon";

				_dao.InsertAccount(account);
				account = null;
				account = _dao.GetAccount(id);
				Assert.IsNotNull(account);
			}
		}
예제 #11
0
		public void Rollback()
		{
			container = CreateConfiguredContainer();
			container.AddFacility("IBatisNet", new IBatisNetFacility());
			container.AddFacility("transaction", new TransactionFacility());

			container.AddComponent("AccountDao", typeof (IAccountDao), typeof (AccountDao));
			container.AddComponent("Service", typeof (IService), typeof (Service));

			ResetDatabase();
			IService service = container["Service"] as IService;

			Account account = new Account();
			account.Id = 999;
			account.EmailAddress = "*****@*****.**";
			account.FirstName = "Transaction";
			account.LastName = "Error";

			try
			{
				service.InsertTransactionalAccountWithError(account);
				Assert.Fail("Exception was expected");
			}
			catch (Exception)
			{
				// Expected
			}

			account = null;
			account = service.GetAccountWithSpecificDataMapper(999) as Account;

			Assert.IsNull(account);
		}