예제 #1
0
        public void Nvelocity_template_with_if_should_work()
        {
            Account paramAccount = new Account();
            paramAccount.FirstName = "Joe";
            paramAccount.Id = 1;

            IDictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("account", paramAccount);

            Account account = dataMapper.QueryForObject<Account>("NVelocity.If", parameters);
            Assert.That(account.FirstName, Is.EqualTo("Joe"));
            Assert.That(account.LastName, Is.Null);

            paramAccount = new Account();
            paramAccount.LastName = "Dalton";
            paramAccount.Id = 1;

            parameters = new Dictionary<string, object>();
            parameters.Add("account", paramAccount);

            account = dataMapper.QueryForObject<Account>("NVelocity.If", parameters);
            Assert.That(account.LastName, Is.EqualTo("Dalton"));
            Assert.That(account.FirstName, Is.Null);

        }
예제 #2
0
		public void AddRange(Account[] value) 
		{
			for (int i = 0;	i < value.Length; i++) 
			{
				Add(value[i]);
			}
		}
 /// <summary>
 /// Create a new account with id = 6
 /// </summary>
 /// <returns>An account</returns>
 private Account NewAccount6()
 {
     Account account = new Account();
     account.Id = 6;
     account.FirstName = "Calamity";
     account.LastName = "Jane";
     account.EmailAddress = "*****@*****.**";
     return account;
 }
예제 #4
0
        public void Iterate2()
        {
            Account account = new Account();
            account.Ids = new int[3] { 1, 2, 3 };

            IList list = dataMapper.QueryForList("DynamicIterate2", account);
            AssertAccount1((Account)list[0]);
            Assert.AreEqual(3, list.Count);
        }
예제 #5
0
        public void TestDynamicJIRA168()
        {
            Query query = new Query();
            Account account = new Account();
            account.Id = 1;
            query.DataObject = account;

            account = (Account)dataMapper.QueryForObject("DynamicJIRA168", query);

            AssertAccount1(account);
        }
예제 #6
0
        public void Nvelocity_simple_sql_template_should_work()
        {
            Account paramAccount = new Account();
            paramAccount.Id = 1;

            IDictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("account", paramAccount);

            Account account = dataMapper.QueryForObject<Account>("NVelocity.Simple", parameters);
            Assert.That(account, Is.Not.Null);
            AssertAccount1(account);
        }
예제 #7
0
        public void GenericTestInsertAccountViaStoreProcedure() 
        {
            Account account = new Account();

            account.Id = 99;
            account.FirstName = "Achille";
            account.LastName = "Talon";
            account.EmailAddress = "*****@*****.**";

            dataMapper.Insert("InsertAccountViaStoreProcedure", account);

            Account testAccount = dataMapper.QueryForObject<Account>("GetAccountViaColumnName", 99);

            Assert.IsNotNull(testAccount);
            Assert.AreEqual(99, testAccount.Id);
        }
예제 #8
0
        public void IterateNestedListProperty() 
        {
            Account accountParam = new Account();

            Account account = new Account();
            account.Id = 1;
            accountParam.Accounts.Add(account);
            account = new Account();
            account.Id = 2;
            accountParam.Accounts.Add(account);
            account = new Account();
            account.Id = 3;
            accountParam.Accounts.Add(account);

            IList<Account> accounts = dataMapper.QueryForList<Account>("IterateNestedListProperty", accountParam);
            AssertAccount1((Account)accounts[0]);
            Assert.AreEqual(3, accounts.Count);
        }
예제 #9
0
        public void TestDynamicSqlOnColumnSelection()
        {
            Account paramAccount = new Account();
            Account resultAccount = new Account();
            IList list = null;

            paramAccount.LastName = "Dalton";
            list = dataMapper.QueryForList("DynamicSqlOnColumnSelection", paramAccount);
            resultAccount = (Account)list[0];
            AssertAccount1(resultAccount);
            Assert.AreEqual(5, list.Count);

            paramAccount.LastName = "Bayon";
            list = dataMapper.QueryForList("DynamicSqlOnColumnSelection", paramAccount);
            resultAccount = (Account)list[0];
            Assert.IsNull(resultAccount.FirstName);
            Assert.IsNull(resultAccount.LastName);
            Assert.AreEqual(5, list.Count);
        }
예제 #10
0
        public void Procedure_with_complex_inline_parameter_should_work()
        {
            Account account = new Account();

            account.Id = 99;
            account.FirstName = "Achille";
            account.LastName = "Talon";
            account.EmailAddress = "*****@*****.**";
            account.CartOption = false;

            dataMapper.Insert("InsertAccountViaStoreProcedure", account);

            Account testAccount = dataMapper.QueryForObject<Account>("GetAccountViaColumnName", 99);

            Assert.IsNotNull(testAccount);
            Assert.That(testAccount.Id, Is.EqualTo(99));
            Assert.That(testAccount.EmailAddress, Is.EqualTo("*****@*****.**"));
            Assert.That(testAccount.CartOption, Is.False);
        }
예제 #11
0
        public void TestEmptyParameterObject()
        {
            Account account = new Account();
            account.Id = -1;

            IList list = dataMapper.QueryForList("DynamicQueryByExample", account);

            AssertAccount1((Account)list[0]);
            Assert.AreEqual(5, list.Count);
        }
예제 #12
0
        public void IterateNestedMapListProperty()
        {
            IDictionary map = new Hashtable();
            IList<Account> accountList = new List<Account>();
            map["Accounts"] = accountList;

            Account account = new Account();
            account.Id = 1;
            accountList.Add(account);
            account = new Account();
            account.Id = 2;
            accountList.Add(account);
            account = new Account();
            account.Id = 3;
            accountList.Add(account);

            IList<Account> accounts = dataMapper.QueryForList<Account>("IterateNestedMapListProperty", map);
            AssertAccount1((Account)accounts[0]);
            Assert.AreEqual(3, accounts.Count);
        }
예제 #13
0
        public void TestIsPropertyAvailableTrue()
        {
            Account account = new Account();
            account.Id = 1;

            IList list = dataMapper.QueryForList("DynamicIsPropertyAvailable", account);
            AssertAccount1((Account)list[0]);
            Assert.AreEqual(1, list.Count);
        }
예제 #14
0
 public void TestExecuteQueryForObjectWithResultObject()
 {
     Account account = new Account();
     Account testAccount = dataMapper.QueryForObject<Account>("GetAccountViaColumnName", 1, account);
     AssertAccount1(account);
     Assert.IsTrue(account == testAccount);
 }
예제 #15
0
        public void DBHelperParameterCache_should_work_in_transaction()
        {
            Account account = new Account();

            account.Id = 99;
            account.FirstName = "Achille";
            account.LastName = "Talon";
            account.EmailAddress = "*****@*****.**";

            using (ISession session = sessionFactory.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {

                    dataMapper.Insert("InsertAccountViaStoreProcedure", account);

                    Hashtable map = new Hashtable();
                    map.Add("Id", 0);
                    map.Add("Name", "Toto");
                    map.Add("Guid", Guid.NewGuid());

                    dataMapper.Insert("InsertCategoryViaStoreProcedureWithMap", map);
                    Assert.AreEqual(1, map["Id"]);

                    transaction.Complete();
                }
            }
        }
예제 #16
0
        public void TestQueryByExampleViaField()
        {
            Account account;

            account = new Account();

            account.Id = 5;
            account = dataMapper.QueryForObject("DynamicQueryByExampleViaPrivateField", account) as Account;
            AssertGilles(account);

            account = new Account();
            account.FirstName = "Gilles";
            account = dataMapper.QueryForObject("DynamicQueryByExampleViaPrivateField", account) as Account;
            AssertGilles(account);

            account = new Account();
            account.LastName = "Bayon";
            account = dataMapper.QueryForObject("DynamicQueryByExampleViaPrivateField", account) as Account;
            AssertGilles(account);

            account = new Account();
            account.EmailAddress = "gilles";
            account = (Account)dataMapper.QueryForObject("DynamicQueryByExampleViaPrivateField", account) as Account;
            AssertGilles(account);

            account = new Account();
            account.Id = 5;
            account.FirstName = "Gilles";
            account.LastName = "Bayon";
            account.EmailAddress = "*****@*****.**";
            account = dataMapper.QueryForObject("DynamicQueryByExampleViaPrivateField", account) as Account;
            AssertGilles(account);
        }
예제 #17
0
		public Order(int id, Account account, IList lineItems)
		{
			_id = id;
			_account = account;
			_lineItemsIList = lineItems;
		}
예제 #18
0
        public void TestComplexDynamic()
        {
            Account account = new Account();
            account.Id = 1;
            account.FirstName = "Joe";
            account.LastName = "Dalton";

            IList list = dataMapper.QueryForList("ComplexDynamicStatement", account);

            AssertAccount1((Account)list[0]);
            Assert.AreEqual(1, list.Count);
        }
예제 #19
0
        public void Test3ForJIRA29()
        {
            // init
            Account account = new Account();

            account.Id = 1234;
            account.FirstName = "#The Pound Signs#";
            account.LastName = "Gilles";
            account.EmailAddress = "*****@*****.**";

            dataMapper.Insert("InsertAccountViaInlineParameters", account);

            // test
            Hashtable param = new Hashtable();
            param["Foo"] = "The Pound Signs";

            Account testAccount = dataMapper.QueryForObject("SelectAccountJIRA29-2", param) as Account;

            Assert.IsNotNull(testAccount);
            Assert.AreEqual(1234, testAccount.Id);
            Assert.AreEqual("#The Pound Signs#", testAccount.FirstName);
        }
예제 #20
0
 /// <summary>
 /// Verify that the input account is equal to the account(id=6).
 /// </summary>
 /// <param name="account">An account object</param>
 private void AssertAccount6(Account account)
 {
     Assert.That(account.Id, Is.EqualTo(6), "account.Id");
     Assert.That(account.FirstName, Is.EqualTo("Calamity"), "account.FirstName");
     Assert.That(account.LastName, Is.EqualTo("Jane"), "account.LastName");
     Assert.That(account.EmailAddress, Is.Null, "account.EmailAddress");
 }
예제 #21
0
        public void TestIterateWithTwoPrepends()
        {
            Account account = new Account();
            account.Id = 1;
            account.FirstName = "Joe";

            account = dataMapper.QueryForObject("DynamicWithPrepend", account) as Account;
            Assert.IsNotNull(account);
            AssertAccount1(account);

            IList list = dataMapper.QueryForList("DynamicWithTwoDynamicElements", account);
            AssertAccount1((Account)list[0]);
        }
예제 #22
0
        public void TestDynamicWithPrepend1()
        {
            Account account = new Account();
            account.Id = 1;

            account = (Account)dataMapper.QueryForObject("DynamicWithPrepend", account);

            AssertAccount1(account);
        }
예제 #23
0
		public Order(int id, Account account, LineItemCollection collection)
		{
			_id = id;
			_account = account;
            _collection = collection;
		}
예제 #24
0
		public Order(int id, Account account, LineItem[] lineItemsArray)
		{
			_id = id;
			_account = account;
			_lineItemsArray = lineItemsArray;
		}
예제 #25
0
        public void TestDynamicWithExtend()
        {
            Account account = new Account();
            account.Id = -1;

            IList list = dataMapper.QueryForList("DynamicWithExtend", account);

            AssertAccount1((Account)list[0]);
            Assert.AreEqual(5, list.Count);
        }
예제 #26
0
        public void TestSelectKeyWithDynamicSql()
        {
            Account account = new Account();
            account.Id = 99998;
            account.FirstName = "R";
            account.LastName = "G";

            Hashtable param = new Hashtable(2);
            param["Account"] = account;
            param["AccountsTableName"] = "Accounts";
            object selectKeyValue = dataMapper.Insert("SelectKeyWithDynamicSql", param);

            Assert.IsNotNull(selectKeyValue);
            Assert.AreEqual(99998, Convert.ToInt32(selectKeyValue));

            Assert.IsTrue(param.ContainsKey("AccountId"));
            Assert.AreEqual(99998, (int)param["AccountId"]);
        }
예제 #27
0
        public void TestArrayPropertyIterate()
        {
            Account account = new Account();
            account.Ids = new int[3] { 1, 2, 3 };

            IList list = dataMapper.QueryForList("DynamicQueryByExample", account);

            AssertAccount1((Account)list[0]);
            Assert.AreEqual(3, list.Count);
        }
예제 #28
0
        public void TestExecuteQueryForObjectViaInlineParameters()
        {
            Account account = new Account();
            account.Id = 1;

            Account testAccount = dataMapper.QueryForObject<Account>("GetAccountViaInlineParameters", account);

            AssertAccount1(testAccount);
        }
예제 #29
0
        public void TestDynamicWithPrepend3()
        {
            Account account = new Account();
            account.Id = 1;
            account.FirstName = "Joe";
            account.LastName = "Dalton";

            account = (Account)dataMapper.QueryForObject("DynamicWithPrepend", account);
            AssertAccount1(account);
        }
예제 #30
0
		public Order(int id, Account account)
		{
			_id = id;
			_account = account;
		}