public void SortingCircular() { // Circular dependencies are not supported in Rhetos, // but this test verifies robustness of the algorithm implementation // and error detection. var cA = new C1 { Name = "A" }; var cB = new C1 { Name = "B" }; cA.Ref1 = cB; cB.Ref1 = cA; var cInit = new InitializationConcept { RhetosVersion = "init" }; var cDependant = new C2 { Name = "dep", Ref1 = cA, Ref2 = cB }; var testData = new List <IConceptInfo> { cDependant, cA, cB, cInit }; var dslContainer = new DslContainerAccessor { ResolvedConcepts = testData }; TestUtility.ShouldFail <FrameworkException>( () => dslContainer.SortReferencesBeforeUsingConcept(InitialConceptsSort.None), "C1 A"); }
public void TestMethod1() { var ic = new InitializationConcept { RhetosVersion = "1.2.3" }; Assert.AreEqual("InitializationConcept '1.2.3'", ic.GetKey()); Assert.AreEqual("InitializationConcept '1.2.3'", ic.GetShortDescription()); Assert.AreEqual("InitializationConcept '1.2.3'", ic.GetUserDescription()); Assert.AreEqual("'1.2.3'", ic.GetKeyProperties()); Assert.AreEqual("Rhetos.Dsl.InitializationConcept '1.2.3'", ic.GetFullDescription()); Assert.AreEqual(null, ic.GetKeyword()); Assert.AreEqual("InitializationConcept", ic.GetKeywordOrTypeName()); Assert.AreEqual(0, ic.GetDirectDependencies().Count()); Assert.AreEqual(0, ic.GetAllDependencies().Count()); Assert.AreEqual("Rhetos.Dsl.InitializationConcept RhetosVersion=1.2.3", ic.GetErrorDescription()); Assert.AreEqual(null, ConceptInfoHelper.GetKeyword(typeof(InitializationConcept))); Assert.AreEqual("InitializationConcept", ConceptInfoHelper.GetKeywordOrTypeName(typeof(InitializationConcept))); }
public void SortInitOnly() { var cInit = new InitializationConcept { RhetosVersion = "init" }; var testData = new List <IConceptInfo> { cInit }; var dslContainer = new DslContainerAccessor { ResolvedConcepts = testData }; dslContainer.SortReferencesBeforeUsingConcept(InitialConceptsSort.None); Assert.AreEqual( TestUtility.Dump(testData, c => c.GetKey()), TestUtility.Dump(dslContainer.ResolvedConcepts, c => c.GetKey())); }
public void TestMethod1() { var ic = new InitializationConcept { RhetosVersion = "1.2.3" }; Assert.AreEqual("InitializationConcept '1.2.3'", ic.GetKey()); Assert.AreEqual("InitializationConcept '1.2.3'", ic.GetShortDescription()); Assert.AreEqual("InitializationConcept '1.2.3'", ic.GetUserDescription()); Assert.AreEqual("'1.2.3'", ic.GetKeyProperties()); Assert.AreEqual("Rhetos.Dsl.InitializationConcept '1.2.3'", ic.GetFullDescription()); Assert.AreEqual(null, ic.GetKeyword()); Assert.AreEqual("InitializationConcept", ic.GetKeywordOrTypeName()); Assert.AreEqual(0, ic.GetDirectDependencies().Count()); Assert.AreEqual(0, ic.GetAllDependencies().Count()); Assert.AreEqual("Rhetos.Dsl.InitializationConcept RhetosVersion=1.2.3", ic.GetErrorDescription()); Assert.AreEqual(null, ConceptInfoHelper.GetKeyword(typeof(InitializationConcept))); Assert.AreEqual("InitializationConcept", ConceptInfoHelper.GetKeywordOrTypeName(typeof(InitializationConcept))); }
public void Sorting() { var cInit = new InitializationConcept { RhetosVersion = "init" }; var c01 = new C0 { Name = "1" }; var c02 = new C0 { Name = "2" }; var c03 = new C0 { Name = "3" }; var cB1 = new CBase { Name = "1" }; var cB2 = new CBase { Name = "2" }; var c2Dependant = new C2 { Name = "dep", Ref1 = c01, Ref2 = cB2 }; var testData = new List <IConceptInfo> { c02, c01, cB2, c2Dependant, cInit, c03, cB1 }; // The expected positions may somewhat change if the sorting algorithm internals change. var tests = new List <(string SortMethod, List <IConceptInfo> ExpectedResult)> { // cInit always goes first. cDependant does not need to move because it is after referenced c1 and c5. ("None", new List <IConceptInfo> { cInit, c02, c01, cB2, c2Dependant, c03, cB1 }), // cB2 is pushed before c2Dependant, to respect dependency precedence. ("Key", new List <IConceptInfo> { cInit, c01, c02, c03, cB2, c2Dependant, cB1 }), // c01 is pushed before c2Dependant, to respect dependency precedence. ("KeyDescending", new List <IConceptInfo> { cInit, cB2, cB1, c01, c2Dependant, c03, c02 }), }; foreach (var test in tests) { var configuration = new MockConfiguration { { "CommonConcepts.Debug.SortConcepts", test.SortMethod } }; var dslContainer = new DslContainerAccessor(configuration); dslContainer.ResolvedConcepts = testData; dslContainer.SortReferencesBeforeUsingConcept(); Assert.AreEqual( TestUtility.Dump(test.ExpectedResult, c => c.GetKey()), TestUtility.Dump(dslContainer.ResolvedConcepts, c => c.GetKey()), test.SortMethod); } }
public void Sorting() { var cInit = new InitializationConcept { RhetosVersion = "init" }; var c01 = new C0 { Name = "1" }; var c02 = new C0 { Name = "2" }; var c03 = new C0 { Name = "3" }; var cB1 = new CBase { Name = "1" }; var cB2 = new CBase { Name = "2" }; var c2Dependant = new C2 { Name = "dep", Ref1 = c01, Ref2 = cB2 }; var testData = new List <IConceptInfo> { c02, c01, cB2, c2Dependant, cInit, c03, cB1 }; // The expected positions may somewhat change if the sorting algorithm internals change. var tests = new List <(InitialConceptsSort SortMethod, List <IConceptInfo> ExpectedResult)> { // cInit always goes first. cDependant is moved to the end, even though it does not need to be moved // because it is after referenced c01 and cB2. Putting all level 2 concept after level 1, // instead of keeping the initial sort based on dynamic evaluation, should result with // less changes in the final generated code. (InitialConceptsSort.None, new List <IConceptInfo> { cInit, c02, c01, cB2, c03, cB1, c2Dependant }), // Keeping the InitialConceptsSort ordering between the concepts of the same level. (InitialConceptsSort.Key, new List <IConceptInfo> { cInit, c01, c02, c03, cB1, cB2, c2Dependant }), // Keeping the InitialConceptsSort ordering between the concepts of the same level. (InitialConceptsSort.KeyDescending, new List <IConceptInfo> { cInit, cB2, cB1, c03, c02, c01, c2Dependant }), }; foreach (var test in tests) { var dslContainer = new DslContainerAccessor { ResolvedConcepts = testData }; dslContainer.SortReferencesBeforeUsingConcept(test.SortMethod); Assert.AreEqual( TestUtility.Dump(test.ExpectedResult, c => c.GetKey()), TestUtility.Dump(dslContainer.ResolvedConcepts, c => c.GetKey()), $"SortConceptsMethod: {test.SortMethod}"); } }