public void TestInsert() { 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"); 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)")); } }
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); SqlServerStore <Kinetix.Data.SqlClient.Test.Bean> store = new SqlServerStore <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")); } }
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); SqlServerStore <Kinetix.Data.SqlClient.Test.Bean> store = new SqlServerStore <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); } }