public void SideBySideValidator_Validate_FourConflictingComponentsMoreComplexGraph()
        {
            IComponent rootComp  = new Component(GetConfig("root", "1.0", "FileShare"));
            IComponent sideComp1 = new Component(GetConfig("sideComp1", "1.0", "FileShare"));
            IComponent sideComp2 = new Component(GetConfig("sideComp1", "1.1", "FileShare"));
            IComponent sideComp3 = new Component(GetConfig("sideComp3", "1.0", "FileShare"));
            IComponent sideComp4 = new Component(GetConfig("sideComp3", "1.1", "FileShare"));

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

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

            sideComp1.AddPredecessor(depRootSideComp1);
            sideComp2.AddPredecessor(depRootSideComp2);
            sideComp3.AddPredecessor(depRootSideComp3);
            sideComp4.AddPredecessor(depRootSideComp4);

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

            var actual = validator.Validate(graph);

            Assert.AreEqual(2, actual.Count(), "Expected two conflicts. One for sideComp1 and one for sideComp3");
            Assert.AreEqual(2, actual.Where(x => x.Components.First().Name.GetName() == "sideComp1").FirstOrDefault().Components.Count(), "Expected exactly two conflicting components for sideComp1");
            Assert.AreEqual(2, actual.Where(x => x.Components.First().Name.GetName() == "sideComp3").FirstOrDefault().Components.Count(), "Expected exactly two conflicting components for sideComp3");
        }
        public void SideBySideValidator_Validate_TwoConflictingComponentsAndTwoNonConflictingComponents()
        {
            IComponent rootComp  = new Component(GetConfig("root", "1.0", "FileShare"));
            IComponent sideComp1 = new Component(GetConfig("sideComp1", "1.0", "FileShare"));
            IComponent sideComp2 = new Component(GetConfig("sideComp1", "1.1", "FileShare"));
            IComponent sideComp3 = new Component(GetConfig("sideComp3", "1.0", "FileShare"));
            IComponent sideComp4 = new Component(GetConfig("sideComp4", "1.1", "FileShare"));

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

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

            sideComp1.AddPredecessor(depRootSideComp1);
            sideComp2.AddPredecessor(depRootSideComp2);
            sideComp3.AddPredecessor(depRootSideComp3);
            sideComp4.AddPredecessor(depRootSideComp4);

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

            var actual = validator.Validate(graph);

            Assert.AreEqual(1, actual.Count(), "Expected exactly one conflict for sideComp1");
            Assert.AreEqual(2, actual.First().Components.Count(), "Expected exactly two conflicting components");
        }
Ejemplo n.º 3
0
        public void GetValidatorTest()
        {
            var expected = new SideBySideValidator();

            var actual = ValidatorFactory.GetValidator(expected.Name);

            Assert.AreEqual(expected.Name, actual.Name);
        }
Ejemplo n.º 4
0
        public void RegisterValidatorTest()
        {
            IValidator validator = new SideBySideValidator();

            ValidatorFactory.RegisterValidator(validator);

            Assert.AreEqual(ValidatorFactory.GetValidator(validator.Name).Name, validator.Name);
        }
Ejemplo n.º 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);
        }