Exemplo n.º 1
0
        public void TestInsertWithValueRuleNull()
        {
            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");
                store.AddRule(rule);
                Assert.AreEqual(1, store.Put(new Kinetix.Data.SqlClient.Test.Bean()));
                Kinetix.Data.SqlClient.Test.TestDbCommand command = Kinetix.Data.SqlClient.Test.TestDbCommand.LastCommand;
                Assert.IsTrue(command.CommandText.Contains("insert into BEAN(BEA_LONG, BEA_SHORT, BEA_GUID, BEA_FLOAT, BEA_DOUBLE, BEA_DECIMAL, BEA_DATETIME, BEA_CHARS, BEA_CHAR, BEA_BYTES, BEA_BYTE, BEA_BOOL, BEA_INT, BEA_STRING) values (@BEA_LONG, @BEA_SHORT, @BEA_GUID, @BEA_FLOAT, @BEA_DOUBLE, @BEA_DECIMAL, @BEA_DATETIME, @BEA_CHARS, @BEA_CHAR, @BEA_BYTES, @BEA_BYTE, @BEA_BOOL, @BEA_INT, @BEA_STRING)\nselect cast(SCOPE_IDENTITY() as int)"));
            }
        }
Exemplo n.º 2
0
        public void TestUpdateWithWhereValueRuleNull()
        {
            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");
                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"));
            }
        }