Ejemplo n.º 1
0
        public void ShouldGenerateFullInsertStatementForOneRow()
        {
            TableQueryGenerator generator = new TableQueryGenerator(customerTable);
            var          valueStore       = new ValueStore();
            DataProducer producer         = new DataProducer(valueStore);

            IEnumerable <DataRowEntity> rows = new List <DataRowEntity> {
                producer.ProduceRow(customerTable, 1)
            };

            string firstValues = generator.GenerateInsertStatement(rows.First(), valueStore);

            Assert.That(firstValues, Is.StringStarting("INSERT INTO dbo.Customer(" + generator.ColumnList + ") OUTPUT INSERTED.CustomerId")
                        .And.StringEnding(" VALUES (1, 'Arboga', 1)"));
        }
Ejemplo n.º 2
0
        public void ShouldGenerateInsertStatementForValueProducingColumns()
        {
            var          valueStore = new ValueStore();
            DataProducer producer   = new DataProducer(valueStore);

            TableQueryGenerator generator = new TableQueryGenerator(tableWithIdentity);

            IEnumerable <DataRowEntity> rows = new List <DataRowEntity> {
                producer.ProduceRow(tableWithIdentity, 1)
            };


            Assert.That(generator.ColumnList, Is.EqualTo("OrderDate"));
            Assert.That(
                generator.GenerateInsertStatement(rows.First(), valueStore),
                Is.StringStarting("INSERT INTO dbo.Order(" + generator.ColumnList + ") OUTPUT INSERTED.OrderId"));
        }