internal IEnumerable <CRflRow> NewR1NCForeignKeyRows(CRflProperty aR1NCProperty) { var aR1NPTyp = aR1NCProperty.DeclaringTyp; var aR1NCTyp = this.GetReturnTyp(aR1NCProperty); var aFkPropertyName = this.GetR1NCForeignKeyPropertyName(aR1NCProperty); var aSelfTypName = aR1NPTyp.Name; var aFkTypName = aR1NCTyp.Name; var aGeneratedComment = "Generated by " + nameof(CGenModelInterpreter) + "." + nameof(NewR1NCForeignKeyRows); var aFkPropertyRow = CRflRow.New(aFkTypName, aFkPropertyName, this.Tok.Mdl_P_A_Typ_Nme, nameof(System.Guid), string.Empty, aGeneratedComment); var aFkPropertyWriteOnlyBySystemRow = CRflRow.New(aFkTypName, aFkPropertyName, this.Tok.Trg_P_A_WriteOnlyBySystem, true.ToString()); var aFkCounterpartTypeAttributeType = this.Tok.GetModelAttributeTypName(typeof(CbOrm.App.Sys.CForeignKeyCounterpartTypeAttribute)); var aFkCounterpartTypeAttributeValue = aSelfTypName; var aFkCounterpartTypeAttributeRow = CRflRow.New(aFkTypName, aFkPropertyName, this.Tok.Mdl_P_A_Nme_DomA + aFkCounterpartTypeAttributeType, aFkCounterpartTypeAttributeValue, string.Empty, aGeneratedComment); var aFkCounterpartPropertyAttributeType = this.Tok.GetModelAttributeTypName(typeof(CForeignKeyCounterpartPropertyNameAttribute)); var aFkCounterpartPropertyAttributeValue = aR1NCProperty.Name; var aFkCounterpartAttributeRow = CRflRow.New(aFkTypName, aFkPropertyName, this.Tok.Mdl_P_A_Nme_DomA + aFkCounterpartPropertyAttributeType, aFkCounterpartPropertyAttributeValue, string.Empty, aGeneratedComment); yield return(aFkPropertyRow); yield return(aFkPropertyWriteOnlyBySystemRow); yield return(aFkCounterpartTypeAttributeRow); yield return(aFkCounterpartAttributeRow); }
public virtual IEnumerable <CRflRow> NewR1NCReverseNavigationRows(CRflProperty aR1NCProperty) { var aR1NPTyp = aR1NCProperty.DeclaringTyp; var aR1NCTyp = this.GetReturnTyp(aR1NCProperty); var aTargetTypName = aR1NCTyp.Name; var aReverseRefPropertyName = this.GetR1NCReverseNavigationRefName(aR1NCProperty); var aReferencedTypName = aR1NPTyp.Name; var aGeneratorComment = "Generated by " + nameof(CGenModelInterpreter) + "." + nameof(NewR1NCReverseNavigationRows); var aRefTypDeclRow = CRflRow.New(aTargetTypName, aReverseRefPropertyName, this.Tok.Mdl_P_A_Typ_Nme, aReferencedTypName, string.Empty, aGeneratorComment); var aRefCardinalityRow = CRflRow.New(aTargetTypName, aReverseRefPropertyName, this.Tok.Mdl_P_A_Nme_Crd, CCardinalityEnum.R1NP.ToString().TrimStart("R"), string.Empty, aGeneratorComment); yield return(aRefTypDeclRow); yield return(aRefCardinalityRow); }
public MainWindow() { InitializeComponent(); var aDirectoryInfo = new DirectoryInfo( System.IO.Path.Combine(new FileInfo(this.GetType().Assembly.Location).Directory.Parent.Parent.Parent.FullName, @"CbOrm\UnitTest" )); var aFileInfo = new FileInfo(System.IO.Path.Combine(aDirectoryInfo.FullName, "TestSequence.xdl")); var aRows = CRflRow.NewFromTextFile(aFileInfo); var aVms = (from aRow in aRows where aRow.RecognizeBool select new CTestCaseVm(aFileInfo.Directory, aRow)).ToArray(); this.TestCaseVms = aVms; this.RefreshTestCase(); this.InterceptionBorder.Visibility = Visibility.Collapsed; this.TestSequenceFile = aFileInfo; }
public virtual IEnumerable <CRflRow> NewR11CReverseNavigationRows(CRflProperty aR11CProperty) { var aR11PTyp = aR11CProperty.DeclaringTyp; var aR11CTyp = this.GetReturnTyp(aR11CProperty); var aTargetTypName = aR11CTyp.Name; var aReverseRefPropertyName = this.GetR11CReverseNavigationRefName(aR11CProperty); var aFkPropertyName = this.GetR11CReverseNavigationFkPropertyName(aR11CProperty); var aReferencedTypName = aR11PTyp.Name; var aGeneratorComment = "Generated by " + nameof(CGenModelInterpreter) + "." + nameof(NewR11CReverseNavigationRows); var aRefTypDeclRow = CRflRow.New(aTargetTypName, aReverseRefPropertyName, this.Tok.Mdl_P_A_Typ_Nme, aReferencedTypName, string.Empty, aGeneratorComment); var aRefCardinalityRow = CRflRow.New(aTargetTypName, aReverseRefPropertyName, this.Tok.Mdl_P_A_Nme_Crd, CCardinalityEnum.R11P.ToString().TrimStart("R"), string.Empty, aGeneratorComment); var aRefFkRow = CRflRow.New(aTargetTypName, aFkPropertyName, this.Tok.Mdl_P_A_Typ_Nme, nameof(Guid)); var aFkCounterpartTypeAttributeType = this.Tok.GetModelAttributeTypName(typeof(CbOrm.App.Sys.CForeignKeyCounterpartTypeAttribute)); var aSelfTypName = aR11CTyp.Name; var aSelfPropertyName = aReverseRefPropertyName; yield return(aRefFkRow); yield return(aRefTypDeclRow); yield return(aRefCardinalityRow); }
public void Run(CTestCase aTestCase) { var aReport = this.Report; var aTestSequence = this.TestSequence; var aDir = this.TestCasesDirectoryInfo; var aTestInterceptor = this.TestInterceptor; var aInterceptTemplate = new Action <CTestResultEventArgs>(delegate(CTestResultEventArgs aArgs) { aTestInterceptor.Accepted = (bool)aArgs.TestResult.Dyn().Ok; aTestInterceptor.OnIntercept(aArgs); if (!aTestInterceptor.Accepted) { throw new Exception("TestCase interceptur did not accept."); } }); var aInModelFileInfo = new FileInfo(Path.Combine(aDir.FullName, aTestCase.Name + "-in.xdl")); var aOutTestFileInfo = new FileInfo(Path.Combine(aDir.FullName, aTestCase.Name + "-out-test.cs")); var aOutOkFileInfo = new FileInfo(Path.Combine(aDir.FullName, aTestCase.Name + "-out-ok.cs")); System.Diagnostics.Debug.Print("Running Test: " + aTestCase.Name); if (aInModelFileInfo.Exists) { var aGenerator = new CCodeGenerator(new CGenModelInterpreter(), new CGenTokens(), new CCodeDomBuilder(), aInModelFileInfo, null, aOutTestFileInfo, null); var aTestCaseId = aTestCase.Name; var aNamespace = "Test" + aTestCaseId.Replace("-", "_"); var aNamespaceRow = CRflRow.New(string.Empty, string.Empty, this.Tok.Mdl_G_A_Nsp_Nme, aNamespace); var aSchemaRow = CRflRow.New(string.Empty, string.Empty, this.Tok.Mdl_G_A_ModelName, "Test"); aGenerator.Exp.ChainedExpanders.Add(new CRowsExpander(aNamespaceRow, aSchemaRow)); aGenerator.GenerateCode(); var aOutTestLines = File.ReadAllLines(aOutTestFileInfo.FullName); if (!aOutTestFileInfo.Exists) { System.Diagnostics.Debugger.Break(); // First Test detected. Continue to accept. File.WriteAllLines(aOutTestFileInfo.FullName, aOutTestLines); } else if (!aOutOkFileInfo.Exists) { System.Diagnostics.Debugger.Break(); // First Test-Validation detected. Continue to accept. File.WriteAllLines(aOutOkFileInfo.FullName, aOutTestLines); } else { try { Action aAcceptAction; var aTestResults = new List <CTestResult>(); var aOkLines = File.ReadAllLines(aOutOkFileInfo.FullName); if (aOutTestLines.Length != aOkLines.Length) { aTestResults.Add(CTestResultBuilder.NewTestResult(aTestCase, false, default(int?), "Number of generated rows missmatch.")); aAcceptAction = new Action(delegate() { File.WriteAllLines(aOutOkFileInfo.FullName, aOutTestLines); }); } else { var aLinePairs = from aIdx in Enumerable.Range(0, aOutTestLines.Length) select new Tuple <int, string, string>(aIdx, aOkLines[aIdx], aOutTestLines[aIdx]); var aFirstDiff = (from aTest in aLinePairs where aTest.Item2 != aTest.Item3 select aTest).FirstOrDefault(); if (aFirstDiff.IsNullRef()) { var aTestMethods = new CGenTestMethods(); var aExcNullable = aTestMethods.RunTests(aTestCase); aTestResults.AddRange(aTestMethods.TestResults); aTestResults.Add(CTestResultBuilder.NewTestResult(aTestCase, aExcNullable.IsNullRef(), default, aExcNullable.IsNullRef() ? string.Empty : aExcNullable.Message));
public CRflAttribute(CRflProperty aRflProperty, CRflRow aRflRow) { this.RflProperty = aRflProperty; this.Row = aRflRow; }