コード例 #1
0
ファイル: ProcedureBuilder.cs プロジェクト: japj/SSDT-DevPack
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
 private static string GenerateSchema(TSqlProcedure procedure)
 {
     var builder = new SchemaBuilder(procedure.Name.Parts.Last());
     return builder.GetScript();
 }