public void CheckIfItsValid_Error_NamespaceNotFoundForLayer() { var constraints = new ArchitecturalConstraints() { Rules = new List <ArchitecturalRule>() { new ArchitecturalRule() { OriginLayer = "Origin", TargetLayer = "Target", RuleOperator = RuleOperator.NeedToRelate } }, Layers = new Dictionary <string, NamespacesGroupingMethod>() { { "Origin", new NamespacesExplicitlyGrouped() }, { "Target", new NamespacesExplicitlyGrouped() } } }; var result = Assert.Throws <ConstraintsException>(() => { constraints.CheckIfItsValid(); }); Assert.Equal(nameof(ConstraintsError.NamespaceNotFoundForLayer), result.Key); }
public void CheckIfItsValid_Error_LayersNotDefined() { var constraints = new ArchitecturalConstraints() { Rules = new List <ArchitecturalRule>() { new ArchitecturalRule() { OriginLayer = "Origin", TargetLayer = "Target", RuleOperator = RuleOperator.NeedToRelate } }, Layers = new Dictionary <string, NamespacesGroupingMethod>() { { "Services", new NamespacesExplicitlyGrouped(new List <string>() { "Service" }) } } }; var result = Assert.Throws <ConstraintsException>(() => { constraints.CheckIfItsValid(); }); Assert.Equal(ConstraintsError.LayerOfRuleNotDefined.Key, result.Key); }
public void CheckIfItsValid_Error_ConstraintEmpty() { var constraints = new ArchitecturalConstraints(); var result = Assert.Throws <ConstraintsException>(() => { constraints.CheckIfItsValid(); }); Assert.Equal(ConstraintsError.ConstraintsNullOrEmpty.Key, result.Key); }
public void CheckIfItsValid_Error_NullReference() { ArchitecturalConstraints constraints = null; var result = Assert.Throws <ConstraintsException>(() => { constraints.CheckIfItsValid(); }); Assert.Equal(ConstraintsError.ConstraintsNullOrEmpty.Key, result.Key); }
/// <summary> /// Receives a C# solution file path and a set of architectural constraints, /// and returns all it's architectural violations. /// </summary> /// <param name="solutionFilePath">Solution file path</param> /// <param name="constraints">Set of architectural constraints</param> /// <returns>List of architectural violations</returns> public static Task <ArchitecturalConformanceCheck> CheckArchitecturalConformanceAsync( string solutionFilePath, ArchitecturalConstraints constraints, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(solutionFilePath)) { throw new SolutionException( SolutionError.SolutionFileNotFound); } var solutionFile = new FileInfo(solutionFilePath); if (!solutionFile.Exists) { throw new SolutionException( SolutionError.SolutionFileNotFound); } constraints.CheckIfItsValid(); return(ExecuteCheckArchitecturalConformanceAsync( solutionFile.FullName, solutionFile.Name, constraints, cancellationToken)); }