예제 #1
0
        public void ToDeploymentModel_WithRecursiveDependenciesInSingleMicroservice_Returns_Correctly()
        {
            var aFeature = new Feature(new FeatureIdentifier("a"), "a", new[]
            {
                new Property(new PropertyIdentifier("p1"), "p1"),
                new Property(new PropertyIdentifier("p2"), "p2")
            }
                                       );

            var bFeature = new Feature(new FeatureIdentifier("b"), "b", new[]
            {
                new Property(new PropertyIdentifier("p3"), "p3"),
                new Property(new PropertyIdentifier("p4"), "p4")
            }
                                       );

            var cFeature = new Feature(new FeatureIdentifier("c"), "c", new[]
            {
                new Property(new PropertyIdentifier("p5"), "p5"),
                new Property(new PropertyIdentifier("p6"), "p6"),
                new Property(new PropertyIdentifier("p7"), "p7")
            }
                                       );

            var featureModel = new FeatureModel(new[] { aFeature, bFeature, cFeature }, new[]
            {
                new PropertyRelation(new PropertyIdentifier("p6"), new PropertyIdentifier("p4")),
                new PropertyRelation(new PropertyIdentifier("p4"), new PropertyIdentifier("p2"))
            });

            var genes = new[]
            {
                new DeploymentGene(new FeatureIdentifier("a"), new MicroserviceIdentifier("a")),
                new DeploymentGene(new FeatureIdentifier("b"), new MicroserviceIdentifier("b")),
                new DeploymentGene(new FeatureIdentifier("c"), new MicroserviceIdentifier("c"))
            };

            var sot = new DeploymentChromosome(featureModel, genes);

            var deploymentModel = new DeploymentModel(featureModel, new[]
            {
                new Microservice(new[]
                {
                    new FeatureInstance(aFeature, new[] { new PropertyIdentifier("p1"), new PropertyIdentifier("p2") }),
                }),
                new Microservice(new []
                {
                    new FeatureInstance(aFeature, new[] { new PropertyIdentifier("p2") }, true),
                    new FeatureInstance(bFeature, new[] { new PropertyIdentifier("p3"), new PropertyIdentifier("p4") })
                }),
                new Microservice(new []
                {
                    new FeatureInstance(cFeature, new[] { new PropertyIdentifier("p5"), new PropertyIdentifier("p6"), new PropertyIdentifier("p7") }),
                    new FeatureInstance(bFeature, new[] { new PropertyIdentifier("p4") }, true),
                    new FeatureInstance(aFeature, new[] { new PropertyIdentifier("p2") }, true)
                }),
            });

            Assert.AreEqual(deploymentModel, sot.ToDeploymentModel());
        }
예제 #2
0
        public void ToDeploymentModel_WithoutDependencies_Returns_Correctly()
        {
            var aFeature = new Feature(new FeatureIdentifier("a"), "a", new[]
            {
                new Property(new PropertyIdentifier("p1"), "p1")
            }
                                       );

            var bFeature = new Feature(new FeatureIdentifier("b"), "b", new[]
            {
                new Property(new PropertyIdentifier("p2"), "p2")
            }
                                       );

            var featureModel = new FeatureModel(new[] { aFeature, bFeature }, Enumerable.Empty <PropertyRelation>());

            var genes = new[]
            {
                new DeploymentGene(new FeatureIdentifier("a"), new MicroserviceIdentifier("a")),
                new DeploymentGene(new FeatureIdentifier("b"), new MicroserviceIdentifier("b"))
            };
            var sot = new DeploymentChromosome(featureModel, genes);

            var deploymentModel = new DeploymentModel(featureModel, new[]
            {
                new Microservice(new[] { new FeatureInstance(aFeature, new[] { new PropertyIdentifier("p1") }) }),
                new Microservice(new[] { new FeatureInstance(bFeature, new[] { new PropertyIdentifier("p2") }) }),
            });

            Assert.AreEqual(deploymentModel, sot.ToDeploymentModel());
        }