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 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 ShouldReportAllSatisfiedRules() { //GIVEN var context = new NScanDriver(); context.HasProject("A"); context.HasProject("B"); context.Add(RuleDemandingThat().Project("A") .IndependentOfProject("B")); //WHEN context.PerformAnalysis(); //THEN context.ReportShouldContain( ProjectIndependentOfMessage.ProjectIndependentOfProject("A", "B").Ok()); context.ShouldIndicateSuccess(); }
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 ShouldReportSuccessWhenPatternExclusionRulesOutDependingThatWouldOtherwiseMatch() { //GIVEN var context = new NScanDriver(); context.HasProject("CompositionRoot"); context.HasProject("CompositionRootSpecification").WithReferences("CompositionRoot"); context.Add(RuleBuilder.RuleDemandingThat() .Project("*") .Except("*Specification*") .IndependentOfProject("*CompositionRoot*")); //WHEN context.PerformAnalysis(); //THEN context.ReportShouldContain( ProjectIndependentOfMessage.ProjectIndependentOfProject( "* except *Specification*", "*CompositionRoot*" ).Ok()); context.ShouldIndicateSuccess(); }