Ejemplo n.º 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");
		}
Ejemplo n.º 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");
		}
Ejemplo n.º 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");
		}
Ejemplo n.º 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");
			}
		}
Ejemplo n.º 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");
		}
Ejemplo n.º 6
0
		public void InsertTransactionalAccountWithError(Account account)
		{
			_accountDao.InsertAccount(account);

			throw new ApplicationException("Ugh!");
		}
Ejemplo n.º 7
0
		public void InsertTransactionalAccount(Account account)
		{
			_accountDao.InsertAccount(account);
		}
Ejemplo n.º 8
0
		public void InsertAccount(Account account)
		{
			_accountDao.InsertAccount(account);
		}
Ejemplo n.º 9
0
		public void InsertAccount(Account account)
		{
			_sqlMap.Insert("InsertAccount", account);
		}
Ejemplo n.º 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);
			}
		}
Ejemplo n.º 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);
		}