Ejemplo n.º 1
0
        public void VerifyThatIfNoDecompositionRuleIsViolatedNoViolationsAreReturned()
        {
            var rule = new DecompositionRule(Guid.NewGuid(), this.cache, this.uri);

            rule.ContainingCategory = this.systemCategory;
            rule.ContainedCategory.Add(this.functionCategory);
            rule.MinContained = 1;
            rule.MaxContained = 2;

            var satellite = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri);

            satellite.Category.Add(this.systemCategory);
            this.iteration.Element.Add(satellite);

            var electricalStorage = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri);

            electricalStorage.Category.Add(this.electricalPowerStorageCategory);
            this.iteration.Element.Add(electricalStorage);

            var elementUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri);

            elementUsage.ElementDefinition = electricalStorage;
            satellite.ContainedElement.Add(elementUsage);

            var violations = rule.Verify(this.iteration);

            Assert.IsEmpty(violations);
        }
Ejemplo n.º 2
0
        public void VerifyThatIfDecompositionIsSatisfiedButMaxContainedNotViolationIsReturned()
        {
            var rule = new DecompositionRule(Guid.NewGuid(), this.cache, this.uri);

            rule.ContainingCategory = this.systemCategory;
            rule.ContainedCategory.Add(this.productCategory);
            rule.MinContained = 1;
            rule.MaxContained = 2;

            var satelliteElementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Name      = "satellite",
                ShortName = "SAT"
            };

            satelliteElementDefinition.Category.Add(this.systemCategory);
            this.iteration.Element.Add(satelliteElementDefinition);

            var batteryElementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Name      = "Battery",
                ShortName = "BAT"
            };

            batteryElementDefinition.Category.Add(this.productCategory);
            this.iteration.Element.Add(batteryElementDefinition);

            var batteryUsage1 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "battery 1", ShortName = "bat_1"
            };

            batteryUsage1.ElementDefinition = batteryElementDefinition;
            satelliteElementDefinition.ContainedElement.Add(batteryUsage1);

            var batteryUsage2 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "battery 2", ShortName = "bat_2"
            };

            batteryUsage2.ElementDefinition = batteryElementDefinition;
            satelliteElementDefinition.ContainedElement.Add(batteryUsage2);

            var batteryUsage3 = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "battery 3", ShortName = "bat_3"
            };

            batteryUsage3.ElementDefinition = batteryElementDefinition;
            satelliteElementDefinition.ContainedElement.Add(batteryUsage3);

            var violations = rule.Verify(this.iteration);

            Assert.AreEqual(1, violations.Count());

            var violation = violations.Single();

            Assert.IsTrue(violation.Description.Contains("contains more Element Usages than the maximum of 2"));
        }
Ejemplo n.º 3
0
        public void VerifyThatIfThereAreNoElementDefinitionsContainedByAnITerationAnEmptyResultIsReturned()
        {
            var rule = new DecompositionRule(Guid.NewGuid(), this.cache, this.uri);

            CollectionAssert.IsEmpty(this.iteration.Element);

            var violations = rule.Verify(this.iteration);

            CollectionAssert.IsEmpty(violations);
        }
Ejemplo n.º 4
0
        public void VerifyThatIfTheIterationContainsNoBinaryRelationShipsAnEmptyResultIsReturned()
        {
            var rule = new DecompositionRule(Guid.NewGuid(), this.cache, this.uri);

            var multiRelationship = new MultiRelationship(Guid.NewGuid(), this.cache, this.uri);

            this.iteration.Relationship.Add(multiRelationship);

            var violations = rule.Verify(this.iteration);

            CollectionAssert.IsEmpty(violations);
        }
Ejemplo n.º 5
0
        public void VerifyThatIfRuleIsViolatedExpectedViolationsAreReturned()
        {
            var rule = new DecompositionRule(Guid.NewGuid(), this.cache, this.uri)
            {
                ContainingCategory = this.systemCategory
            };

            rule.ContainedCategory.Add(this.functionCategory);
            rule.ContainedCategory.Add(this.productCategory);

            var spaceMissionElementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Name      = "Space Mission",
                ShortName = "SpaceMission"
            };

            spaceMissionElementDefinition.Category.Add(this.systemCategory);

            var satelliteElementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Name      = "satellite",
                ShortName = "SAT"
            };

            satelliteElementDefinition.Category.Add(this.systemCategory);

            var satelliteElementUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                ElementDefinition = satelliteElementDefinition
            };

            spaceMissionElementDefinition.ContainedElement.Add(satelliteElementUsage);

            this.iteration.Element.Add(spaceMissionElementDefinition);
            this.iteration.Element.Add(satelliteElementDefinition);

            var violations = rule.Verify(this.iteration);

            var violation = violations.SingleOrDefault();

            Assert.IsNotNull(violation);

            Assert.IsTrue(violation.Description.Contains("of an incorrect type"));

            CollectionAssert.Contains(violation.ViolatingThing, spaceMissionElementDefinition.Iid);
            CollectionAssert.Contains(violation.ViolatingThing, satelliteElementUsage.Iid);
        }
Ejemplo n.º 6
0
        public void VerifyThatNullIterationThrowsArgumentException()
        {
            var rule = new DecompositionRule(Guid.NewGuid(), this.cache, this.uri);

            Assert.Throws <ArgumentNullException>(() => rule.Verify(null));
        }