public ProcedureBuilder(string testSchema, string testName, TSqlProcedure procedureUnderTest) { CodeType = CodeType.Procedure; _testProcedure.StatementList = new StatementList(); foreach (var t in procedureUnderTest.BodyDependencies) { if (t.ObjectType == ModelSchema.Table) { //table to fake var table = new TSqlTable(t.Element); AddTable(table.Name); } } foreach (var p in procedureUnderTest.Parameters) { AddParameter(p.Name.GetName().UnQuote(), GetParameterType(p.DataType)); } CreateTestProcedureDefinition(testSchema, testName); CreateExecForProcUnderTest(procedureUnderTest.Name); }
private static string GenerateTest(TSqlProcedure procedure) { var builder = new ProcedureBuilder(procedure.Name.Parts.Last(), "[test To Be Implemented]", procedure.Name.ToSchemaObjectName()); foreach (var param in procedure.Parameters) { foreach (var type in param.DataType) { builder.AddParameter(param.Name.Parts.Last(), type.SqlDataType); break; } } foreach (var dependency in procedure.BodyDependencies) { if (dependency.ObjectType == ModelSchema.Table) { var table = new TSqlTable(dependency); builder.AddTable(table.Name.ToSchemaObjectName()); } } return builder.GetScript(); }
private static string GenerateSchema(TSqlProcedure procedure) { var builder = new SchemaBuilder(procedure.Name.Parts.Last()); return builder.GetScript(); }