예제 #1
0
        public void CreateNewApplications_MissingMiddleApplications()
        {
            IConceptInfo ci1 = new SimpleCi {
                Name = "1"
            };                                              // Concept application SimpleConceptImplementation will generate SQL script "create 1".
            IConceptInfo ci2 = new SimpleCi2 {
                Name = "2"
            };                                               // No concept application in database.
            IConceptInfo ci3 = new SimpleCi3 {
                Name = "3"
            };                                               // Concept application ExtendingConceptImplementation does not generate SQL script.

            var conceptImplementations = new PluginsMetadataList <IConceptDatabaseDefinition>
            {
                new NullImplementation(),
                { new SimpleConceptImplementation(), typeof(SimpleCi) },
                { new ExtendingConceptImplementation(), typeof(SimpleCi3) },
            };

            tempConceptInfoDependencies = new[] { Tuple.Create(ci2, ci1), Tuple.Create(ci3, ci2) };
            // Concept application that implements ci3 should (indirectly) depend on concept application that implements ci1.
            // This test is specific because there is no concept application for ci2, so there is possibility of error when calculating dependencies between concept applications.

            var dslModel             = new MockDslModel(new[] { ci1, ci2, ci3 });
            var databasePlugins      = MockDatabasePluginsContainer.Create(conceptImplementations);
            var databaseModelBuilder = new DatabaseModelBuilderAccessor(databasePlugins, dslModel);
            var conceptApplications  = databaseModelBuilder.CreateDatabaseModel().DatabaseObjects;

            tempConceptInfoDependencies = null;

            var ca1 = conceptApplications.Where(ca => ca.ConceptInfoKey == ci1.GetKey()).Single();
            var ca3 = conceptApplications.Where(ca => ca.ConceptInfoKey == ci3.GetKey()).Single();

            Assert.IsTrue(DirectAndIndirectDependencies(ca1).Contains(ca3), "Concept application ca3 should be included in direct or indirect dependencies of ca1.");
        }
예제 #2
0
        public void ExtractDependenciesFromConceptInfosTest()
        {
            var a  = CreateBaseCiApplication("A");
            var b  = CreateBaseCiApplication("B");
            var c  = CreateBaseCiApplication("C");
            var r1 = MultipleReferencingCi.CreateApplication("1", a, b);
            var r2 = MultipleReferencingCi.CreateApplication("2", b, c);
            var r3 = MultipleReferencingCi.CreateApplication("3", r1, r2);
            var r5 = MultipleReferencingCi.CreateApplication("5", c, c);
            var r4 = MultipleReferencingCi.CreateApplication("4", c, r5);

            var conceptImplementations = new PluginsMetadataList <IConceptDatabaseDefinition>
            {
                new NullImplementation(),
                { new SimpleConceptImplementation(), typeof(SimpleCi) },
            };

            var all = new List <CodeGenerator> {
                a, b, c, r1, r2, r3, r4, r5
            };
            var dependencies = new DatabaseModelDependencies(new ConsoleLogProvider())
                               .ExtractCodeGeneratorDependencies(all, MockDatabasePluginsContainer.Create(conceptImplementations));

            string result = string.Join(" ", dependencies
                                        .Select(d => ((dynamic)d).DependsOn.ConceptInfo.Name + "<" + ((dynamic)d).Dependent.ConceptInfo.Name)
                                        .OrderBy(str => str));

            Console.WriteLine(result);

            Assert.AreEqual("1<3 2<3 5<4 A<1 A<3 B<1 B<2 B<3 C<2 C<3 C<4 C<5", result);
        }
예제 #3
0
        private List <DatabaseObject> CreateConceptApplications(params IConceptInfo[] concepts)
        {
            var implementations = new PluginsMetadataList <IConceptDatabaseDefinition>()
            {
                new NullImplementation(),
                { new SimpleImplementation(), typeof(SimpleConcept) },
                { new ReferenceImplementation(), typeof(ReferenceConcept) },
                { new ReferenceReferenceImplementation(), typeof(ReferenceReferenceConcept) },
            };

            var databaseModelBuilder = new DatabaseModelBuilder(
                MockDatabasePluginsContainer.Create(implementations),
                new MockDslModel(concepts),
                new ConsoleLogProvider(),
                new DatabaseModelDependencies(new ConsoleLogProvider()));

            var conceptApplications = databaseModelBuilder.CreateDatabaseModel().DatabaseObjects;

            Console.WriteLine("ConceptApplications:"
                              + string.Concat(conceptApplications.Select(ca => $"\r\n- {ca}, depends on: {string.Join(", ", ca.DependsOn.Select(d => d.ToString()))}.")));
            return(conceptApplications);
        }