示例#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 CreateNewApplications_MissingMiddleApplications()
        {
            IConceptInfo ci1 = new SimpleCi {
                Name = "1"
            };
            IConceptInfo ci2 = new SimpleCi2 {
                Name = "2"
            };
            IConceptInfo ci3 = new SimpleCi3 {
                Name = "3"
            };

            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 plugins = CreatePluginsContainer(new PluginsMetadataList <IConceptDatabaseDefinition>
            {
                new NullImplementation(),
                { new SimpleConceptImplementation(), new Dictionary <string, object> {
                      { "Implements", typeof(SimpleCi) }
                  } },
                { new ExtendingConceptImplementation(), new Dictionary <string, object> {
                      { "Implements", typeof(SimpleCi3) }
                  } }
            });

            DatabaseGenerator_Accessor databaseGenerator = new DatabaseGenerator_Accessor(dslModel, plugins);
            var createdApplications = databaseGenerator.CreateNewApplications(new List <ConceptApplication>());

            tempConceptInfoDependencies = null;

            var ca1 = createdApplications.Where(ca => ca.ConceptInfo == ci1).Single();
            var ca3 = createdApplications.Where(ca => ca.ConceptInfo == ci3).Single();

            Assert.IsTrue(DirectAndIndirectDependencies(ca1).Contains(ca3), "Concept application ca3 should be included in direct or indirect dependencies of ca1.");
        }