public void ExtractCreateQueries_Empty() { var sqlCodeBuilder = new CodeBuilder("/*", "*/"); var createQueries = DatabaseModelBuilderAccessor.ExtractCreateQueries(sqlCodeBuilder.GeneratedCode); Assert.AreEqual( "", TestUtility.DumpSorted(createQueries, cq => $"{cq.Key}:{cq.Value}")); }
public void ExtractCreateQueries_BeforeFirst2() { var sqlCodeBuilder = new CodeBuilder("/*", "*/"); sqlCodeBuilder.InsertCode("before first"); var newConceptApplications = new List <CodeGenerator>(); TestUtility.ShouldFail <FrameworkException>( () => DatabaseModelBuilderAccessor.ExtractCreateQueries(sqlCodeBuilder.GeneratedCode), "The first segment should be empty"); }
public void ExtractCreateQueries_BeforeFirst1() { var ca1 = new CodeGenerator(new BaseCi { Name = "ci1" }, new SimpleConceptImplementation()); const string createQuery1 = "create query 1"; var ca2 = new CodeGenerator(new BaseCi { Name = "ci2" }, new SimpleConceptImplementation()); const string createQuery2 = "create query 2"; var sqlCodeBuilder = new CodeBuilder("/*", "*/"); sqlCodeBuilder.InsertCode("before first"); sqlCodeBuilder.InsertCode(DatabaseModelBuilderAccessor.GetCodeGeneratorSeparator(0)); sqlCodeBuilder.InsertCode(createQuery1); sqlCodeBuilder.InsertCode(DatabaseModelBuilderAccessor.GetCodeGeneratorSeparator(1)); sqlCodeBuilder.InsertCode(createQuery2); TestUtility.ShouldFail <FrameworkException>( () => DatabaseModelBuilderAccessor.ExtractCreateQueries(sqlCodeBuilder.GeneratedCode), "The first segment should be empty"); }
public void ExtractCreateQueries() { var ca1 = new CodeGenerator(new BaseCi { Name = "ci1" }, new SimpleConceptImplementation()); const string createQuery1 = "create query 1"; var ca2 = new CodeGenerator(new BaseCi { Name = "ci2" }, new SimpleConceptImplementation()); const string createQuery2 = "create query 2"; var sqlCodeBuilder = new CodeBuilder("/*", "*/"); sqlCodeBuilder.InsertCode(DatabaseModelBuilderAccessor.GetCodeGeneratorSeparator(ca1.Id)); sqlCodeBuilder.InsertCode(createQuery1); sqlCodeBuilder.InsertCode(DatabaseModelBuilderAccessor.GetCodeGeneratorSeparator(ca2.Id)); sqlCodeBuilder.InsertCode(createQuery2); var createQueries = DatabaseModelBuilderAccessor.ExtractCreateQueries(sqlCodeBuilder.GeneratedCode); Assert.AreEqual( $"{ca1.Id}:create query 1, {ca2.Id}:create query 2", TestUtility.DumpSorted(createQueries, cq => $"{cq.Key}:{cq.Value}")); }