Exemplo n.º 1
0
        public void TestLoadAllLikeTop()
        {
            using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
                List <Kinetix.Data.SqlClient.Test.Bean> list = new List <Kinetix.Data.SqlClient.Test.Bean>();
                for (byte i = 0; i < 10; i++)
                {
                    Kinetix.Data.SqlClient.Test.Bean b = new Kinetix.Data.SqlClient.Test.Bean();
                    b.Pk           = i;
                    b.DataBool     = true;
                    b.DataByte     = i;
                    b.DataBytes    = new byte[i];
                    b.DataChar     = (char)(i + 64);
                    b.DataChars    = new char[i];
                    b.DataDateTime = DateTime.Now;
                    b.DataDecimal  = i;
                    b.DataDouble   = i;
                    b.DataFloat    = i;
                    b.DataGuid     = Guid.NewGuid();
                    b.DataInt      = i;
                    b.DataLong     = i;
                    b.DataShort    = i;
                    b.DataString   = i.ToString();
                    list.Add(b);
                }
                TestDbProviderFactory.DefinedNextResult(list);

                OracleSqlStore <Kinetix.Data.SqlClient.Test.Bean> store = new OracleSqlStore <Kinetix.Data.SqlClient.Test.Bean>("test");
                FilterCriteria criteria = new FilterCriteria().Equals(Kinetix.Data.SqlClient.Test.Bean.Cols.BEA_FLOAT, 3);
                QueryParameter sort     = new QueryParameter(Kinetix.Data.SqlClient.Test.Bean.Cols.BEA_FLOAT, SortOrder.Asc, 10);
                Kinetix.Data.SqlClient.Test.TestDbCommand command = Kinetix.Data.SqlClient.Test.TestDbCommand.LastCommand;
                Assert.AreEqual("select * from (select BEA_PK, BEA_LONG, BEA_SHORT, BEA_GUID, BEA_FLOAT, BEA_DOUBLE, BEA_DECIMAL, BEA_DATETIME, BEA_CHARS, BEA_CHAR, BEA_BYTE, BEA_BOOL, BEA_INT, BEA_STRING from BEAN where BEA_FLOAT = :BEA_FLOAT order by BEA_FLOAT asc) where rownum <= 10", command.CommandText);
                //Assert.AreEqual(10 + 1, command.Parameters["top"].Value);
                Assert.AreEqual(3, command.Parameters["BEA_FLOAT"].Value);
            }
        }
Exemplo n.º 2
0
        public void TestUpdate()
        {
            using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
                List <PkBean> list = new List <PkBean>();
                PkBean        b    = new PkBean();
                b.Pk = 1;
                list.Add(b);
                TestDbProviderFactory.DefinedNextResult(list);

                OracleSqlStore <Kinetix.Data.SqlClient.Test.Bean> store = new OracleSqlStore <Kinetix.Data.SqlClient.Test.Bean>("test");
                Kinetix.Data.SqlClient.Test.Bean bean = new Kinetix.Data.SqlClient.Test.Bean();
                bean.Pk = 1;
                Assert.AreEqual(1, store.Put(bean));
                Kinetix.Data.SqlClient.Test.TestDbCommand command = Kinetix.Data.SqlClient.Test.TestDbCommand.LastCommand;
                Assert.IsTrue(command.CommandText.Contains("update BEAN set BEA_LONG = :BEA_LONG, BEA_SHORT = :BEA_SHORT, BEA_GUID = :BEA_GUID, BEA_FLOAT = :BEA_FLOAT, BEA_DOUBLE = :BEA_DOUBLE, BEA_DECIMAL = :BEA_DECIMAL, BEA_DATETIME = :BEA_DATETIME, BEA_CHARS = :BEA_CHARS, BEA_CHAR = :BEA_CHAR, BEA_BYTES = :BEA_BYTES, BEA_BYTE = :BEA_BYTE, BEA_BOOL = :BEA_BOOL, BEA_INT = :BEA_INT, BEA_STRING = :BEA_STRING where BEA_PK = :BEA_PK"));
            }
        }
Exemplo n.º 3
0
        public void TestUpdateWithWhereIncrementalUpdate()
        {
            using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
                List <PkBean> list = new List <PkBean>();
                PkBean        b    = new PkBean();
                b.Pk = 1;
                list.Add(b);
                TestDbProviderFactory.DefinedNextResult(list);

                SqlServerStore <Kinetix.Data.SqlClient.Test.Bean> store = new SqlServerStore <Kinetix.Data.SqlClient.Test.Bean>("test");
                TestStoreRule rule = new TestStoreRule("DataFloat");
                rule.WhereValue = new ValueRule(null, ActionRule.IncrementalUpdate);
                store.AddRule(rule);
                Kinetix.Data.SqlClient.Test.Bean bean = new Kinetix.Data.SqlClient.Test.Bean();
                bean.Pk = 1;
                Assert.AreEqual(1, store.Put(bean));
                Kinetix.Data.SqlClient.Test.TestDbCommand command = Kinetix.Data.SqlClient.Test.TestDbCommand.LastCommand;
                Assert.AreEqual("update BEAN set BEA_LONG = @BEA_LONG, BEA_SHORT = @BEA_SHORT, BEA_GUID = @BEA_GUID, BEA_FLOAT = @BEA_FLOAT, BEA_DOUBLE = @BEA_DOUBLE, BEA_DECIMAL = @BEA_DECIMAL, BEA_DATETIME = @BEA_DATETIME, BEA_CHARS = @BEA_CHARS, BEA_CHAR = @BEA_CHAR, BEA_BYTES = @BEA_BYTES, BEA_BYTE = @BEA_BYTE, BEA_BOOL = @BEA_BOOL, BEA_INT = @BEA_INT, BEA_STRING = @BEA_STRING where BEA_PK = @BEA_PK", command.CommandText);
            }
        }
Exemplo n.º 4
0
        public void TestUpdateWithWhereCheck()
        {
            using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
                List <PkBean> list = new List <PkBean>();
                PkBean        b    = new PkBean();
                b.Pk = 1;
                list.Add(b);
                TestDbProviderFactory.DefinedNextResult(list);

                OracleSqlStore <Kinetix.Data.SqlClient.Test.Bean> store = new OracleSqlStore <Kinetix.Data.SqlClient.Test.Bean>("test");
                TestStoreRule rule = new TestStoreRule("DataFloat");
                rule.WhereValue = new ValueRule(3, ActionRule.Check);
                store.AddRule(rule);
                Kinetix.Data.SqlClient.Test.Bean bean = new Kinetix.Data.SqlClient.Test.Bean();
                bean.Pk = 1;
                Assert.AreEqual(1, store.Put(bean));
                Kinetix.Data.SqlClient.Test.TestDbCommand command = Kinetix.Data.SqlClient.Test.TestDbCommand.LastCommand;
                Assert.IsTrue(command.CommandText.Contains("update BEAN set BEA_LONG = :BEA_LONG, BEA_SHORT = :BEA_SHORT, BEA_GUID = :BEA_GUID, BEA_FLOAT = :BEA_FLOAT, BEA_DOUBLE = :BEA_DOUBLE, BEA_DECIMAL = :BEA_DECIMAL, BEA_DATETIME = :BEA_DATETIME, BEA_CHARS = :BEA_CHARS, BEA_CHAR = :BEA_CHAR, BEA_BYTES = :BEA_BYTES, BEA_BYTE = :BEA_BYTE, BEA_BOOL = :BEA_BOOL, BEA_INT = :BEA_INT, BEA_STRING = :BEA_STRING where BEA_PK = :BEA_PK and BEA_FLOAT = :RU_BEA_FLOAT"));
                Assert.AreEqual(3, command.Parameters["RU_BEA_FLOAT"].Value);
            }
        }
Exemplo n.º 5
0
        public void TestLoadAllByCriteriaString()
        {
            using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required)) {
                List <Kinetix.Data.SqlClient.Test.Bean> list = new List <Kinetix.Data.SqlClient.Test.Bean>();
                for (byte i = 0; i < 10; i++)
                {
                    Kinetix.Data.SqlClient.Test.Bean b = new Kinetix.Data.SqlClient.Test.Bean();
                    b.Pk           = i;
                    b.DataBool     = true;
                    b.DataByte     = i;
                    b.DataBytes    = new byte[i];
                    b.DataChar     = (char)(i + 64);
                    b.DataChars    = new char[i];
                    b.DataDateTime = DateTime.Now;
                    b.DataDecimal  = i;
                    b.DataDouble   = i;
                    b.DataFloat    = i;
                    b.DataGuid     = Guid.NewGuid();
                    b.DataInt      = i;
                    b.DataLong     = i;
                    b.DataShort    = i;
                    b.DataString   = i.ToString();
                    list.Add(b);
                }
                list.Add(new Kinetix.Data.SqlClient.Test.Bean());
                TestDbProviderFactory.DefinedNextResult(list);

                SqlServerStore <Kinetix.Data.SqlClient.Test.Bean> store = new SqlServerStore <Kinetix.Data.SqlClient.Test.Bean>("test");
                FilterCriteria criteria = new FilterCriteria()
                                          .Equals(Kinetix.Data.SqlClient.Test.Bean.Cols.BEA_FLOAT, 3)
                                          .StartsWith(Kinetix.Data.SqlClient.Test.Bean.Cols.BEA_STRING, "test")
                                          .NotStartsWith(Kinetix.Data.SqlClient.Test.Bean.Cols.BEA_STRING, "test2");
                QueryParameter sort = new QueryParameter(Kinetix.Data.SqlClient.Test.Bean.Cols.BEA_FLOAT, SortOrder.Asc);
                store.LoadAllByCriteria(null, criteria, sort);
                Kinetix.Data.SqlClient.Test.TestDbCommand command = Kinetix.Data.SqlClient.Test.TestDbCommand.LastCommand;
                Assert.AreEqual("select BEA_PK, BEA_LONG, BEA_SHORT, BEA_GUID, BEA_FLOAT, BEA_DOUBLE, BEA_DECIMAL, BEA_DATETIME, BEA_CHARS, BEA_CHAR, BEA_BYTE, BEA_BOOL, BEA_INT, BEA_STRING from BEAN where BEA_FLOAT = @BEA_FLOAT and BEA_STRING LIKE @BEA_STRING + '%' and BEA_STRING NOT LIKE @BEA_STRING2 + '%' order by BEA_FLOAT asc", command.CommandText);
                Assert.AreEqual(3, command.Parameters["@BEA_FLOAT"].Value);
                Assert.AreEqual("test", command.Parameters["@BEA_STRING"].Value);
            }
        }