public void All_Interfaces_Are_In_Contracts_Namespace()
        {
            IArchRule interfacesShouldBeInContractsLayer =
                ArchRuleDefinition.Interfaces().That().Are(Interfaces).Should().Be(InterfaceLayer);

            Assert.IsTrue(interfacesShouldBeInContractsLayer.HasNoViolations(Architecture));
        }
Example #2
0
        public void All_Classes_Have_Correct_Namespace()
        {
            IArchRule classesHaveCorrectNamespace =
                ArchRuleDefinition.Classes().That().Are(Classes).Should().Be(Layer);
            IArchRule interfacesHaveCorrectNamespace =
                ArchRuleDefinition.Interfaces().That().Are(Interfaces).Should().Be(Layer);

            IArchRule combinedArchRule =
                classesHaveCorrectNamespace.And(interfacesHaveCorrectNamespace);

            Assert.IsTrue(combinedArchRule.HasNoViolations(Architecture));
        }
Example #3
0
        public void Check_Infrastructure_Dependencies()
        {
            IArchRule infrastructureLayerShouldNotAccessControllerLayer =
                ArchRuleDefinition.Types().That().Are(InfrastructureLayer).Should().NotDependOnAny(ControllerLayer);

            IArchRule infrastructureLayerShouldAccessDomainLayer =
                ArchRuleDefinition.Types().That().Are(InfrastructureLayer).Should().DependOnAny(DomainLayer);

            IArchRule infrastructureLayerShouldNotAccessApplicationLayer =
                ArchRuleDefinition.Types().That().Are(InfrastructureLayer).Should().NotDependOnAny(ApplicationLayer);

            IArchRule combinedArchRule =
                infrastructureLayerShouldNotAccessControllerLayer
                .And(infrastructureLayerShouldAccessDomainLayer)
                .And(infrastructureLayerShouldNotAccessApplicationLayer);

            Assert.IsTrue(combinedArchRule.HasNoViolations(Architecture));
        }
Example #4
0
 public ArchitectureSpecSetup()
 {
     Architecture = new ArchLoader()
                    .LoadAssemblyIncludingDependencies(typeof(TStartup).Assembly)
                    .Build();
     InfrastructureLayer = ArchRuleDefinition.Types().That()
                           .ResideInNamespace(DomainSpecificApiProjectNamespaces, true)
                           .Or().ResideInNamespace(ApiCommonProjectNamespaces, true)
                           .Or().ResideInNamespace(DomainSpecificStorageProjectNamespaces, true)
                           .Or().ResideInNamespace(StorageCommonProjectNamespaces, true)
                           .Or().ResideInNamespace(InfrastructureCommonProjectsNamespaces, true)
                           .Or().ResideInNamespace(ExternalCommonProjectsNamespaces, true)
                           .As("Infrastructure Layer");
     ApplicationLayer = ArchRuleDefinition.Types().That()
                        .ResideInNamespace(DomainSpecificApplicationProjectNamespaces, true)
                        .Or().ResideInNamespace(ApplicationCommonProjectNamespaces, true)
                        .As("Application Layer");
     DomainLayer = ArchRuleDefinition.Types().That()
                   .ResideInNamespace(DomainSpecificProjectNamespaces, true)
                   .Or().ResideInNamespace(DomainCommonProjectNamespaces, true)
                   .As("Domain Layer");
 }
Example #5
0
        //Relation Condition Negations

        public ShouldRelateToTypesThat <TRuleTypeShouldConjunction, IType, TRuleType> NotBeAssignableToTypesThat()
        {
            _ruleCreator.BeginComplexCondition(ArchRuleDefinition.Types(),
                                               TypeConditionsDefinition <TRuleType> .NotBeAssignableToTypesThat());
            return(new ShouldRelateToTypesThat <TRuleTypeShouldConjunction, IType, TRuleType>(_ruleCreator));
        }
Example #6
0
        //Relation Condition Negations

        public ShouldRelateToTypesThat <TRuleTypeShouldConjunction, IType, TRuleType> NotDependOnAnyTypesThat()
        {
            _ruleCreator.BeginComplexCondition(ArchRuleDefinition.Types(true),
                                               ObjectConditionsDefinition <TRuleType> .NotDependOnAnyTypesThat());
            return(new ShouldRelateToTypesThat <TRuleTypeShouldConjunction, IType, TRuleType>(_ruleCreator));
        }
Example #7
0
        //Relation Conditions

        public ShouldRelateToTypesThat <TRuleTypeShouldConjunction, IType, TRuleType> BeDeclaredInTypesThat()
        {
            _ruleCreator.BeginComplexCondition(ArchRuleDefinition.Types(),
                                               MemberConditionsDefinition <TRuleType> .BeDeclaredInTypesThat());
            return(new ShouldRelateToTypesThat <TRuleTypeShouldConjunction, IType, TRuleType>(_ruleCreator));
        }