예제 #1
0
        public void TestGenerateDeleteWithID()
        {
            var         schemeName    = TestingTools.RandomString;
            var         tableName     = TestingTools.RandomString;
            var         propertyName  = TestingTools.RandomString;
            var         propertyValue = TestingTools.RandomString;
            var         id            = TestingTools.RandomInt;
            DeleteQuery query         = new DeleteQuery(schemeName, tableName);

            query.AddWhereFragment(id);

            var result = query.Build();

            var expected = String.Format("DELETE FROM \"{0}\".\"{1}\" WHERE \"ID\"={2};",
                                         schemeName, tableName, id);

            Assert.IsNotNull(result);
            Assert.AreEqual(expected, result);
        }
예제 #2
0
        public void TestGenerateDeleteWithWhere()
        {
            var         schemeName    = TestingTools.RandomString;
            var         tableName     = TestingTools.RandomString;
            var         propertyName  = TestingTools.RandomString;
            var         propertyValue = TestingTools.RandomString;
            var         id            = TestingTools.RandomInt;
            DeleteQuery query         = new DeleteQuery(schemeName, tableName);

            Expression <Func <ConnectionDM, bool> > exp = (item) => item.ChildID == id;

            query.AddWhereFragment((BinaryExpression)exp.Body);

            var result = query.Build();

            var expected = String.Format("DELETE FROM \"{0}\".\"{1}\" WHERE \"ChildID\" = '{2}';",
                                         schemeName, tableName, id);

            Assert.IsNotNull(result);
            Assert.AreEqual(expected, result);
        }