public void LinqCreateBasicConditionTest() { AbstractDatabase fakeDb = DatabaseFactory.CreateDatabase("", "System.Data.SqlClient") as AbstractDatabase; SelectCommand expectedCommand = fakeDb.CreateSelectCommand(""); SelectCommand actualCommand = fakeDb.CreateSelectCommand(""); SqlConditionBuilder expectedConditionBuilder = expectedCommand.ConditionBuilder; SqlBasicParameterCondition expectedCondition = expectedConditionBuilder.Equal("TestColumn2", 123); SqlBasicParameterCondition actualCondition = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test2 == 123) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition, actualCondition); SqlBasicParameterCondition expectedCondition2 = expectedConditionBuilder.NotEqual("TestColumn2", 123); SqlBasicParameterCondition actualCondition2 = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test2 != 123) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition2, actualCondition2); SqlBasicParameterCondition expectedCondition3 = expectedConditionBuilder.GreaterThan("TestColumn2", 123); SqlBasicParameterCondition actualCondition3 = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test2 > 123) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition3, actualCondition3); SqlBasicParameterCondition expectedCondition4 = expectedConditionBuilder.LessThan("TestColumn2", 123); SqlBasicParameterCondition actualCondition4 = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test2 < 123) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition4, actualCondition4); SqlBasicParameterCondition expectedCondition5 = expectedConditionBuilder.GreaterThanOrEqual("TestColumn2", 123); SqlBasicParameterCondition actualCondition5 = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test2 >= 123) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition5, actualCondition5); SqlBasicParameterCondition expectedCondition6 = expectedConditionBuilder.LessThanOrEqual("TestColumn2", 123); SqlBasicParameterCondition actualCondition6 = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test2 <= 123) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition6, actualCondition6); SqlBasicParameterCondition expectedCondition7 = expectedConditionBuilder.IsNotNull("TestColumn1"); SqlBasicParameterCondition actualCondition7 = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test1 != null) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition7, actualCondition7); SqlBasicParameterCondition expectedCondition8 = expectedConditionBuilder.IsNull("TestColumn3"); SqlBasicParameterCondition actualCondition8 = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test3 == null) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition8, actualCondition8); SqlBasicParameterCondition expectedCondition10 = expectedConditionBuilder.EqualColumn("TestColumn2", "TestColumn3"); SqlBasicParameterCondition actualCondition10 = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test2 == c.Test3) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition10, actualCondition10); }
public void LinqCreateIsNullConditionTest() { AbstractDatabase fakeDb = DatabaseFactory.CreateDatabase("", "System.Data.SqlClient") as AbstractDatabase; SelectCommand expectedCommand = fakeDb.CreateSelectCommand(""); SelectCommand actualCommand = fakeDb.CreateSelectCommand(""); SqlConditionBuilder expectedConditionBuilder = expectedCommand.ConditionBuilder; SqlBasicParameterCondition expectedCondition = expectedConditionBuilder.IsNull("TestColumn1"); SqlBasicParameterCondition actualCondition = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test1.IsNull()) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition, actualCondition); SqlBasicParameterCondition expectedCondition2 = expectedConditionBuilder.IsNull("TestColumn2"); SqlBasicParameterCondition actualCondition2 = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test2.IsNull()) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition2, actualCondition2); SqlBasicParameterCondition expectedCondition3 = expectedConditionBuilder.IsNull("TestColumn5"); SqlBasicParameterCondition actualCondition3 = SqlLinqCondition.Create <TestEntity>(actualCommand, c => c.Test5.IsNull()) as SqlBasicParameterCondition; Assert.AreEqual(expectedCondition3, actualCondition3); }