public void ShouldDetectMultipleIndirectRuleBreaksWithMultipleViolationPaths() { //GIVEN var context = new NScanDriver(); context.HasProject("A").WithReferences("B", "C"); context.HasProject("B").WithReferences("D"); context.HasProject("C").WithReferences("D"); context.HasProject("D"); context.Add(RuleDemandingThat().Project("A").IndependentOfProject("D")); context.Add(RuleDemandingThat().Project("A").IndependentOfProject("B")); //WHEN context.PerformAnalysis(); //THEN context.ReportShouldContain( ProjectIndependentOfMessage.ProjectIndependentOfProject("A", "D").Error() .ViolationPath("A", "B", "D") .ViolationPath("A", "C", "D")); context.ReportShouldContain( ProjectIndependentOfMessage.ProjectIndependentOfProject("A", "B").Error() .ViolationPath("A", "B")); context.ShouldIndicateFailure(); }
public void ShouldReportFailureWhenPatternExclusionDoesNotRuleOutDependingThatMatchAlone() { //GIVEN var context = new NScanDriver(); context.HasProject("CompositionRoot"); context.HasProject("CompositionRootSpecification").WithReferences("CompositionRoot"); context.HasProject("CompositionRootTests").WithReferences("CompositionRoot"); context.Add(RuleBuilder.RuleDemandingThat() .Project("*") .Except("*Tests*") .IndependentOfProject("*CompositionRoot*")); //WHEN context.PerformAnalysis(); //THEN context.ReportShouldContain( ProjectIndependentOfMessage.ProjectIndependentOfProject( "* except *Tests*", "*CompositionRoot*").Error() .ViolationPath("CompositionRootSpecification", "CompositionRoot")); context.ReportShouldNotContainText("CompositionRootTests"); context.ShouldIndicateFailure(); }
public void ShouldDetectRuleBreakWithGlobExpression() { //GIVEN var context = new NScanDriver(); context.HasProject("Posts.Domain").WithReferences("Posts.Ports"); context.HasProject("Posts.Ports"); context.Add(RuleDemandingThat().Project("*.Domain").IndependentOfProject("*.Ports")); //WHEN context.PerformAnalysis(); //THEN context.ReportShouldContain( ProjectIndependentOfMessage.ProjectIndependentOfProject("*.Domain", "*.Ports").Error() .ViolationPath("Posts.Domain", "Posts.Ports")); context.ShouldIndicateFailure(); }
public void ShouldReportFailureWhenProjectsHasSpecifiedPackageReferenceDirectly() { //GIVEN var projectName = Any.String(); var packageName = Any.String(); var context = new NScanDriver(); context.HasProject(projectName).WithPackages(packageName); context.Add(RuleDemandingThat().Project(projectName).IndependentOfPackage(packageName)); //WHEN context.PerformAnalysis(); //THEN context.ReportShouldContain( ProjectIndependentOfMessage.ProjectIndependentOfPackage(projectName, packageName).Error() .ViolationPath(projectName)); context.ShouldIndicateFailure(); }
public void ShouldReportIndirectRuleBreak() { //GIVEN var projectName = Any.String("project1"); var projectName2 = Any.String("project2"); var assemblyName = Any.String("assembly"); var context = new NScanDriver(); context.HasProject(projectName).WithReferences(projectName2); context.HasProject(projectName2).WithAssemblyReferences(assemblyName); context.Add(RuleDemandingThat().Project(projectName).IndependentOfAssembly(assemblyName)); //WHEN context.PerformAnalysis(); //THEN context.ReportShouldContain( ProjectIndependentOfAssembly(projectName, assemblyName).Error() .ViolationPath(projectName, projectName2)); context.ShouldIndicateFailure(); }