Ejemplo n.º 1
0
        public static string MockAllDependencies(System.Threading.CancellationToken token, TsqltManager.MockOptionsDictionary options, string connectionString, System.Collections.Generic.List <ObjectReference> dependencies)
        {
            var sb = new StringBuilder();

            QueryManager.Run(connectionString, token, (qm) =>
            {
                foreach (var m in dependencies)
                {
                    var objectType = GetObjectTypeDesc(qm, m);

                    if (objectType == null)
                    {
                        sb.AppendLine("-- Could not find type for " + m.ReferencedObject.ToFullString());
                    }
                    else if (objectType == "USER_TABLE")
                    {
                        sb.AppendLine(TsqltManager.MockTableWithRows(token, options, 1, m.ReferencedObject, connectionString));
                    }
                    else if (objectType == "SQL_STORED_PROCEDURE")
                    {
                        sb.AppendLine(TsqltManager.MockProcedure(m.ReferencedObject, qm));
                    }
                    else if (objectType.ToUpperInvariant().Contains("FUNCTION"))
                    {
                        sb.AppendLine(TsqltManager.MockFunction(m.ReferencedObject));
                    }
                    else
                    {
                        sb.AppendLine("-- Unknown object type: " + m.ReferencedObject.ToFullString());
                    }
                    sb.AppendLine();
                }
            });
            return(sb.ToString());
        }
Ejemplo n.º 2
0
        public static string MockTableWithRows(CancellationToken token, MockOptionsDictionary options, int numRows, ObjectMetadata tableMeta, string connectionString)
        {
            StringBuilder        sb = new StringBuilder();
            ObjectMetadataAccess da = new ObjectMetadataAccess(connectionString);
            var table = da.SelectTopNFrom(tableMeta, token, numRows);

            sb.Append(TsqltManager.FakeTable(tableMeta));
            sb.AppendLine();
            sb.Append(TsqltManager.GenerateInsertFor(table, tableMeta, options.EachColumnInSelectOnNewRow, options.EachColumnInValuesOnNewRow));

            return(sb.ToString());
        }