public void ShouldCreateIndependentOfProjectRuleWithPassedIds() { //GIVEN var ruleViolationFactory = Any.Instance <IDependencyPathRuleViolationFactory>(); var ruleFactory = new DependencyPathRuleFactory(ruleViolationFactory); var dependingId = Any.Pattern(); var dependencyId = Any.Instance <Glob>(); var independentRuleComplementDto = new IndependentRuleComplementDto( DependencyPathRuleFactory.ProjectDependencyType, dependingId, dependencyId); //WHEN var rule = ruleFactory.CreateDependencyRuleFrom(independentRuleComplementDto); //THEN rule.GetType().Should().Be <IndependentRule>(); rule.Should().DependOn(dependingId); rule.Should().DependOnTypeChain( typeof(JoinedDescribedCondition), typeof(IsFollowingAssemblyCondition)); rule.Should().DependOnTypeChain( typeof(JoinedDescribedCondition), typeof(HasAssemblyNameMatchingPatternCondition)); rule.Should().DependOn(dependencyId); rule.Should().DependOn(ruleViolationFactory); }
public IDependencyRule CreateDependencyRuleFrom(IndependentRuleComplementDto independentRuleComplementDto) { var dependingAssemblyNamePattern = independentRuleComplementDto.DependingPattern; if (independentRuleComplementDto.DependencyType == ProjectDependencyType) { return(CreateIndependentOfProjectRule( dependingAssemblyNamePattern, independentRuleComplementDto.DependencyPattern, independentRuleComplementDto.DependencyType)); } else if (independentRuleComplementDto.DependencyType == PackageDependencyType) { return(CreateIndependentOfPackageRule( dependingAssemblyNamePattern, independentRuleComplementDto.DependencyPattern, independentRuleComplementDto.DependencyType)); } else if (independentRuleComplementDto.DependencyType == AssemblyDependencyType) { return(CreateIndependentOfAssemblyRule( dependingAssemblyNamePattern, independentRuleComplementDto.DependencyPattern, independentRuleComplementDto.DependencyType)); } else { throw new InvalidRuleException(independentRuleComplementDto.DependencyType); } }
public static RuleDescription Format(IndependentRuleComplementDto dto) { return(FormatIndependentRule( dto.DependingPattern.Text(), dto.RuleName, dto.DependencyType, dto.DependencyPattern.Pattern)); }
public void ShouldCreateIndependentOfAssemblyRuleWithPassedIds() { //GIVEN var ruleViolationFactory = Any.Instance <IDependencyPathRuleViolationFactory>(); var ruleFactory = new DependencyPathRuleFactory(ruleViolationFactory); var dependingNamePattern = Any.Pattern(); var assemblyNamePattern = Any.Instance <Glob>(); var independentRuleComplementDto = new IndependentRuleComplementDto( DependencyPathRuleFactory.AssemblyDependencyType, dependingNamePattern, assemblyNamePattern); //WHEN var rule = ruleFactory.CreateDependencyRuleFrom(independentRuleComplementDto); //THEN rule.Should().BeOfType <IndependentRule>(); rule.Should().DependOnTypeChain(typeof(DescribedCondition), typeof(HasAssemblyReferenceMatchingCondition)); rule.Should().DependOn(dependingNamePattern); rule.Should().DependOn(assemblyNamePattern); rule.Should().DependOn(ruleViolationFactory); }
public void Log(IndependentRuleComplementDto dto) { }
public virtual void Visit(IndependentRuleComplementDto dto) { AssertionLambdas.FailWhen <IndependentRuleComplementDto>()(dto); }
public void Log(IndependentRuleComplementDto dto) { _writeLine($"{DiscoveredRule}{IndependentRuleMetadata.Format(dto)}"); }
public void Visit(IndependentRuleComplementDto dto) { _support.Log(dto); }
public static TestedRuleDefinition From(IndependentRuleComplementDto dto) { return(new TestedRuleDefinition($"{dto.DependingPattern.Text()} {dto.RuleName} {dto.DependencyType}:{dto.DependencyPattern.Pattern}")); }
public void Visit(IndependentRuleComplementDto dto) { var rule = _dependencyBasedRuleFactory.CreateDependencyRuleFrom(dto); _pathRules.Add(rule); }
public void Log(IndependentRuleComplementDto dto) { Log(IndependentRuleMetadata.Format(dto)); }
public override void Visit(IndependentRuleComplementDto dto) { _action(dto); }