Esempio n. 1
0
        public void TestGenerateUpdateWithID()
        {
            var         schemeName    = TestingTools.RandomString;
            var         tableName     = TestingTools.RandomString;
            var         propertyName  = TestingTools.RandomString;
            var         propertyValue = TestingTools.RandomString;
            var         id            = TestingTools.RandomInt;
            UpdateQuery query         = new UpdateQuery(schemeName, tableName);

            query.AddPropertyValue(propertyName, propertyValue);
            query.AddWhereFragment(id);

            var result = query.Build();

            var expected = String.Format("UPDATE \"{0}\".\"{1}\" SET \"{2}\"='{3}' WHERE \"ID\"={4};",
                                         schemeName, tableName, propertyName, propertyValue, id);

            Assert.IsNotNull(result);
            Assert.AreEqual(expected, result);
        }
Esempio n. 2
0
        public void TestGenerateUpdateWithWhere()
        {
            var         schemeName    = TestingTools.RandomString;
            var         tableName     = TestingTools.RandomString;
            var         propertyName  = TestingTools.RandomString;
            var         propertyValue = TestingTools.RandomString;
            var         id            = TestingTools.RandomInt;
            UpdateQuery query         = new UpdateQuery(schemeName, tableName);

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

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

            var result = query.Build();

            var expected = String.Format("UPDATE \"{0}\".\"{1}\" SET \"{2}\"='{3}' WHERE \"ChildID\" = '{4}';",
                                         schemeName, tableName, propertyName, propertyValue, id);

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