Пример #1
0
        public void Test_Select_Statement_Generation()
        {
            // arrange
            var schema = new DataTable();
            schema.Columns.Add("COLUMN_NAME");
            schema.Rows.Add(new object[] { "field1" });
            schema.Rows.Add(new object[] { "field2" });
            schema.Rows.Add(new object[] { "field3" });
            conn.Setup(x => x.GetSchema("Columns", new [] { null, null, "testTable", null }))
                .Returns(schema);
            var generator = new SqlGenerator(conn.Object);

            // act
            var select = generator.GenerateSelect("testTable");

            // assert
            Assert.AreEqual("SELECT field1, field2, field3 FROM testTable", select);
        }
Пример #2
0
        public void Generate_Select_With_Where()
        {
            // arrange
            var conn = new Mock<DbConnection>();
            var schema = new DataTable();
            schema.Columns.Add("COLUMN_NAME");
            schema.Rows.Add(new object[] { "field1" });
            schema.Rows.Add(new object[] { "field2" });
            conn.Setup(x => x.GetSchema("Columns", new [] { null, null, "testTable", null }))
                .Returns(schema);
            var generator = new SqlGenerator(conn.Object);

            // act
            var select = generator.GenerateSelect("testTable", "tblContactLoginID = 'ahaley'");

            // assert
            Assert.AreEqual(
                "SELECT field1, field2 FROM testTable WHERE tblContactLoginID = 'ahaley'",
                select);
        }