public void ShouldResolveNoDependencies()
        {
            var configs = new[]
            {
                DepTestHelper.CreateTestConfiguration("A")
            };

            DepTestHelper.GroomConfigs(configs);

            var sut = configs[0].Resolve <ConfigurationDependencyResolver>();

            sut.Dependencies.Length.Should().Be(0);
            sut.Dependents.Length.Should().Be(0);
        }
Пример #2
0
        public void ShouldNotResolveRejectedImplicitDependencies_WithWildcards()
        {
            var configs = new[]
            {
                DepTestHelper.CreateImplicitTestConfiguration("Alpha", Tuple.Create("master", "/sitecore/content")),
                DepTestHelper.CreateImplicitTestConfiguration("Beta", new [] { "A*" }, Tuple.Create("master", "/sitecore/content/Home"))
            };

            DepTestHelper.GroomConfigs(configs);

            var sut = configs[1].Resolve <ConfigurationDependencyResolver>();

            sut.Dependencies.Length.Should().Be(0);
        }
Пример #3
0
        public void ShouldResolveImplicitDependencies_WithSimilarPathRoots()
        {
            var configs = new[]
            {
                DepTestHelper.CreateImplicitTestConfiguration("A", Tuple.Create("master", "/sitecore/content")),
                DepTestHelper.CreateImplicitTestConfiguration("B", Tuple.Create("master", "/sitecore/contented/Home"))
            };

            DepTestHelper.GroomConfigs(configs);

            var sut = configs[1].Resolve <ConfigurationDependencyResolver>();

            sut.Dependencies.Should().BeEmpty();
        }
Пример #4
0
        public void IdenticalPaths_ShouldNotBeImplicitDependencies()
        {
            var configs = new[]
            {
                DepTestHelper.CreateImplicitTestConfiguration("A", Tuple.Create("master", "/sitecore/content")),
                DepTestHelper.CreateImplicitTestConfiguration("B", Tuple.Create("master", "/sitecore/content"))
            };

            DepTestHelper.GroomConfigs(configs);

            var sut = configs[1].Resolve <ConfigurationDependencyResolver>();

            sut.Dependencies.Should().BeEmpty();
        }
        public void ShouldResolveExplicitDependents()
        {
            var configs = new[]
            {
                DepTestHelper.CreateTestConfiguration("A"),
                DepTestHelper.CreateTestConfiguration("B", "A")
            };

            DepTestHelper.GroomConfigs(configs);

            var sut = configs[0].Resolve <ConfigurationDependencyResolver>();

            sut.Dependents.Length.Should().Be(1);
            sut.Dependents[0].Name.Should().Be("B");
        }
Пример #6
0
        public void ShouldResolveImplicitDependencies()
        {
            var configs = new[]
            {
                DepTestHelper.CreateImplicitTestConfiguration("A", Tuple.Create("master", "/sitecore/content")),
                DepTestHelper.CreateImplicitTestConfiguration("B", Tuple.Create("master", "/sitecore/content/Home"))
            };

            DepTestHelper.GroomConfigs(configs);

            var sut = configs[1].Resolve <ConfigurationDependencyResolver>();

            sut.Dependencies.Length.Should().Be(1);
            sut.Dependencies[0].Configuration.Name.Should().Be("A");
        }
        public void ShouldThrowWhenTransitiveRecursiveDependencyExists()
        {
            // expected order = items without deps first, followed by items with dependencies ordered in dependency order
            var configs = new[]
            {
                DepTestHelper.CreateTestConfiguration("A", "B"),
                DepTestHelper.CreateTestConfiguration("B", "C"),
                DepTestHelper.CreateTestConfiguration("C", "A")
            };

            var sut = new InterconfigurationDependencyResolver();

            DepTestHelper.GroomConfigs(configs);

            Assert.Throws <InvalidOperationException>(() => sut.OrderByDependencies(configs));
        }
        public void ShouldResolveExplicitWildcardDependencies()
        {
            var configs = new[]
            {
                DepTestHelper.CreateTestConfiguration("Alpha"),
                DepTestHelper.CreateTestConfiguration("Alpha One"),
                DepTestHelper.CreateTestConfiguration("B", "Alpha*")
            };

            DepTestHelper.GroomConfigs(configs);

            var sut = configs[2].Resolve <ConfigurationDependencyResolver>();

            sut.Dependencies.Length.Should().Be(2);
            sut.Dependencies.Should().Contain(dep => dep.Configuration.Name.Equals("Alpha"));
            sut.Dependencies.Should().Contain(dep => dep.Configuration.Name.Equals("Alpha One"));
        }
        public void ShouldResolveWithDependencies()
        {
            var configs = new[]
            {
                DepTestHelper.CreateTestConfiguration("B", "A"),
                DepTestHelper.CreateTestConfiguration("A")
            };

            var sut = new InterconfigurationDependencyResolver();

            DepTestHelper.GroomConfigs(configs);

            var result = sut.OrderByDependencies(configs);

            result.Length.Should().Be(2);
            result[0].Name.Should().Be("A");
            result[1].Name.Should().Be("B");
        }
        public void ShouldPreserveInputOrderWithDependencies()
        {
            // expected order = items without deps first, followed by items with dependencies ordered in dependency order
            var configs = new[]
            {
                DepTestHelper.CreateTestConfiguration("A", "C"),
                DepTestHelper.CreateTestConfiguration("B", "A"),
                DepTestHelper.CreateTestConfiguration("C"),
                DepTestHelper.CreateTestConfiguration("D")
            };

            var sut = new InterconfigurationDependencyResolver();

            DepTestHelper.GroomConfigs(configs);

            var result = sut.OrderByDependencies(configs);

            result.Length.Should().Be(4);
            result[0].Name.Should().Be("C");
            result[1].Name.Should().Be("D");
            result[2].Name.Should().Be("A");
            result[3].Name.Should().Be("B");
        }