public void Contains_Text_Of_Two_Selected_Columns()
            {
                const string column2 = "AccountName";
                Target = new SqlQuery(String.Format("SELECT id, {0} FROM Account", column2));

                Assert.AreEqual<string>(column2.ToLower(), Target.Columns.ElementAt(1));
            }
        public ResultSet BuildResultSet(SqlQuery query, IEnumerable<Entity> entities)
        {
            var entityType = Type.GetType(String.Format("{0}.{1}", typeof(Entity).Namespace, query.Entity), true, true);
            var columnHeaders = GetColumnHeaders(query, entityType);

            var set = new ResultSet(columnHeaders);
            foreach (var entity in entities)
                set.Add(BuildResultSetRow(columnHeaders, entity).ToList());

            return set;
        }
            public void Populates_Correctly_With_Lowercase_Select()
            {
                const string column2 = "AccountName";
                Target = new SqlQuery(String.Format("select id, {0} FROM Account", column2));

                Assert.AreEqual<string>(column2.ToLower(), Target.Columns.ElementAt(1));
            }
            public void Does_Not_Include_Commas_In_Field_Names()
            {
                var query = new SqlQuery("SELECT AccountName, id FROM Account");

                Assert.IsFalse(query.Columns.ElementAt(0).Contains(","));
            }
 public void BeforeEachTest()
 {
     Target = new SqlQuery("SELECT id FROM Account");
 }
            public void Returns_Stuff_After_Where()
            {
                Target = new SqlQuery("SELECT * FROM Account WHERE id = 12");

                Assert.AreEqual<string>("id = 12", Target.WhereClause);
            }
            public void Does_Not_Include_OrderBy_When_There_Is_An_OrderBy_Clause()
            {
                string clause = "id = 12";
                Target = new SqlQuery(String.Format("SELECT * From Account WHERE {0} ORDER BY id", clause));

                Assert.AreEqual<string>(clause, Target.WhereClause);
            }
            public void Returns_Stuff_After_Order_By()
            {
                Target = new SqlQuery("SELECT * FROM Account ORDER BY id");

                Assert.AreEqual<string>("id", Target.OrderByClause);
            }
            public void Returns_Word_After_From_In_Sql_Statement()
            {
                const string entity = "account";
                Target = new SqlQuery(String.Format("SELECT * FROM {0}", entity));

                Assert.AreEqual<string>(entity, Target.Entity);
            }
            public void Returns_Correct_Value_When_From_Is_Not_Capitlized()
            {
                const string entity = "account";
                Target = new SqlQuery(String.Format("select * from {0}", entity));

                Assert.AreEqual<string>(entity, Target.Entity);
            }
            public void Returns_Empty_List_When_Select_Contains_Star()
            {
                Target = new SqlQuery("SELECT * FROM Account");

                Assert.AreEqual<int>(0, Target.Columns.Count());
            }
 private static IEnumerable<string> GetColumnHeaders(SqlQuery query, Type entityType)
 {
     return query.Columns.Any() ? query.Columns : GetQualifyingPropertiesOfType(entityType);
 }