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); }
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"); }
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"); }