public void Gen_Delete_Test_Keyless()
        {
            TestClass T = new TestClass()
            {
                DateColumn    = DateTime.Parse("1/1/2021"),
                FloatColumn   = 12.12,
                IntegerColumn = 123,
                ScalarColumn  = 1,
                TextColumn    = "Tomato"
            };

            SqlDeleteGenerator delr = new SqlDeleteGenerator();

            try
            {
                var command = delr.Generate(T, new Func <TestClass, IEnumerable <KeyValuePair <string, object> > >(x => {
                    return(new List <KeyValuePair <string, object> >());
                }));
            }
            catch
            {
                Assert.Pass();
            }

            Assert.Fail();
        }
Beispiel #2
0
 private void ButtonGenerateDelete_Click(object sender, RoutedEventArgs e)
 {
     if (lstSelectedTables.SelectedItems.Count > 0)
     {
         string output = string.Empty;
         foreach (var item in lstSelectedTables.SelectedItems)
         {
             if (item is TSqlObject table)
             {
                 SqlDeleteGenerator gen = new SqlDeleteGenerator(GeneratorSettings, table, true);
                 output += gen.Generate();
             }
         }
         txtOutput.Text = output;
     }
 }
        public void Gen_Delete_For_TestClass()
        {
            TestClass T = new TestClass()
            {
                DateColumn    = DateTime.Parse("1/1/2021"),
                FloatColumn   = 12.12,
                IntegerColumn = 123,
                ScalarColumn  = 1,
                TextColumn    = "Tomato"
            };

            SqlDeleteGenerator delr = new SqlDeleteGenerator();
            var command             = delr.Generate(T);

            Assert.AreEqual(command, correctStr);
        }
        public void Gen_Delete_Custom_Keys()
        {
            string    correctStatement = "DELETE FROM TestClass WHERE TextColumn = 'Blah' AND ScalarColumn = 1";
            TestClass T = new TestClass()
            {
                DateColumn    = DateTime.Parse("1/1/2021"),
                FloatColumn   = 12.12,
                IntegerColumn = 123,
                ScalarColumn  = 1,
                TextColumn    = "Tomato"
            };
            SqlDeleteGenerator delr = new SqlDeleteGenerator();
            var statement           = delr.Generate(T, new Func <TestClass, IEnumerable <KeyValuePair <string, object> > >(x =>
            {
                return(new List <KeyValuePair <string, object> >()
                {
                    new KeyValuePair <string, object>("TextColumn", "Blah"),
                    new KeyValuePair <string, object>("ScalarColumn", 1)
                });
            }));

            Assert.AreEqual(correctStatement, statement);
        }