// This method will be inlined by the JIT.
 // Resets the validator to its initial state. This is important when a IInstanceProvider threw an
 // exception, because a new call to that provider would otherwise make the validator think it is a
 // recursive call and throw an exception, and this would hide the exception that would otherwise be
 // thrown by the provider itself.
 internal static void Reset(this CyclicDependencyValidator validator)
 {
     if (validator != null)
     {
         validator.RollBack();
     }
 }
 // Prevents any recursive calls from taking place.
 // This method will be inlined by the JIT.
 internal static void CheckForRecursiveCalls(this CyclicDependencyValidator validator)
 {
     if (validator != null)
     {
         validator.Check();
     }
 }
コード例 #3
0
        public void CyclicValidatorTest_LinearDependencyChain_MultipleEdgeToComponent3_NoCycles()
        {
            //root -> comp1 -> comp2 -> comp 3
            //           |----------------|

            IComponent rootComp  = new Component(GetConfig("root", "1.0", "FileShare"));
            IComponent sideComp1 = new Component(GetConfig("sideComp1", "1.0", "FileShare"));
            IComponent sideComp2 = new Component(GetConfig("sideComp2", "1.0", "FileShare"));
            IComponent sideComp3 = new Component(GetConfig("sideComp3", "1.0", "FileShare"));

            IDependency depRootSideComp1 = new Dependency(rootComp, sideComp1, new ComponentVersion("1.*"));
            IDependency depRootSideComp2 = new Dependency(sideComp1, sideComp2, new ComponentVersion("1.*"));
            IDependency depRootSideComp3 = new Dependency(sideComp2, sideComp3, new ComponentVersion("1.*"));
            IDependency depRootSideComp4 = new Dependency(sideComp1, sideComp3, new ComponentVersion("1.*"));

            rootComp.AddSuccessor(depRootSideComp1);
            sideComp1.AddSuccessor(depRootSideComp2);
            sideComp1.AddSuccessor(depRootSideComp4);
            sideComp2.AddSuccessor(depRootSideComp3);

            var    validator = new CyclicDependencyValidator();
            IGraph graph     = new Graph(rootComp, "C:\\");

            var actual = validator.Validate(graph);

            Assert.AreEqual(0, actual.Count());
        }
コード例 #4
0
        public void CyclicValidatorTest_Validate_CyclicDependencyHavingMultiplePaths()
        {
            IComponent rootComp  = new Component(GetConfig("root", "1.0", "FileShare"));
            IComponent sideComp1 = new Component(GetConfig("sideComp1", "1.0", "FileShare"));
            IComponent sideComp2 = new Component(GetConfig("sideComp2", "1.0", "FileShare"));
            IComponent sideComp3 = new Component(GetConfig("sideComp3", "1.0", "FileShare"));

            IDependency depRootSideComp1 = new Dependency(rootComp, sideComp1, new ComponentVersion("1.*"));
            IDependency depRootSideComp2 = new Dependency(sideComp1, sideComp2, new ComponentVersion("1.*"));
            IDependency depRootSideComp3 = new Dependency(sideComp1, sideComp3, new ComponentVersion("1.*"));
            IDependency depRootSideComp4 = new Dependency(sideComp2, sideComp1, new ComponentVersion("1.*"));
            IDependency depRootSideComp5 = new Dependency(sideComp3, sideComp1, new ComponentVersion("1.*"));

            rootComp.AddSuccessor(depRootSideComp1);
            sideComp1.AddSuccessor(depRootSideComp2);
            sideComp1.AddSuccessor(depRootSideComp3);
            sideComp2.AddSuccessor(depRootSideComp4);
            sideComp3.AddSuccessor(depRootSideComp5);

            var    validator = new CyclicDependencyValidator();
            IGraph graph     = new Graph(rootComp, "C:\\");

            var actual = validator.Validate(graph);

            Assert.AreEqual(2, actual.Count(), "Expected exactly one cyclic dependency for sideComp1");
        }
コード例 #5
0
        /// <summary>
        /// Initializes static members of the <see cref="ValidatorFactory"/> class.
        /// </summary>
        static ValidatorFactory()
        {
            Validators = new Dictionary <string, IValidator>(StringComparer.OrdinalIgnoreCase);

            var sidebyside = new SideBySideValidator();

            Validators.Add(sidebyside.Name, sidebyside);

            var cyclic = new CyclicDependencyValidator();

            Validators.Add(cyclic.Name, cyclic);
        }
コード例 #6
0
        public void CyclicValidatorTest_Validate_SelfDepedency_Cycle()
        {
            //sideComp1 -> sideComp1 ...

            IComponent  sideComp1        = new Component(GetConfig("sideComp1", "1.0", "FileShare"));
            IDependency depRootSideComp1 = new Dependency(sideComp1, sideComp1, new ComponentVersion("1.*"));

            sideComp1.AddSuccessor(depRootSideComp1);

            var    validator = new CyclicDependencyValidator();
            IGraph graph     = new Graph(sideComp1, "C:\\");

            var actual = validator.Validate(graph);

            Assert.AreEqual(1, actual.Count(), "Expected exactly one conflict for sideComp1");
        }