Esempio n. 1
0
 public void ArchRuleExtensionsTest()
 {
     _architecture.CheckRule(_trueRule);
     _trueRule.Check(_architecture);
     Assert.Throws <AssertionException>(() => _architecture.CheckRule(_falseRule));
     Assert.Throws <AssertionException>(() => _falseRule.Check(_architecture));
     Assert.AreEqual(_expectedErrorMessage,
                     Assert.Catch <AssertionException>(() => _architecture.CheckRule(_falseRule)).Message);
     Assert.AreEqual(_expectedErrorMessage,
                     Assert.Catch <AssertionException>(() => _falseRule.Check(_architecture)).Message);
 }
        public void ClassesShouldAdhereToShoppingExampleConsideringOnlyDependenciesInDiagram()
        {
            var filename = "./Resources/shopping_example.puml";

            IArchRule adhereToPlantUmlDiagram = Types().Should().AdhereToPlantUmlDiagram(filename);

            adhereToPlantUmlDiagram.Check(Architecture);
        }
        public void ExampleLayerShouldNotAccessForbiddenLayer()
        {
            //you can give your rules a custom reason, which is displayed when it fails (together with the types that failed the rule)
            IArchRule exampleLayerShouldNotAccessForbiddenLayer = Types().That().Are(ExampleLayer).Should()
                                                                  .NotDependOnAny(ForbiddenLayer).Because("it's forbidden");

            exampleLayerShouldNotAccessForbiddenLayer.Check(Architecture);
        }
Esempio n. 4
0
        public void Meeting_BoundedContext_Shoud_Not_Depend_Of_Certificate_BoundedContext()
        {
            IArchRule rule = Types()
                             .That().Are(MeetingManagementBoundedContext)
                             .Should().NotDependOnAny(CertificateManagementBoundedContext)
                             .Because("it's forbidden");

            rule.Check(Architecture);
        }
Esempio n. 5
0
        public void CertificateManagement_BoundedContext_Shoud_Not_Depend_On_Any_Infrastructure_Layer()
        {
            IArchRule rule = Types()
                             .That().Are(CertificateManagementBoundedContext)
                             .Should().NotDependOnAny(AdapterLayer)
                             .Because("it's forbidden");

            rule.Check(Architecture);
        }
Esempio n. 6
0
 public void ArchRuleExtensionsTest()
 {
     _architecture.CheckRule(_trueRule);
     _trueRule.Check(_architecture);
     Assert.ThrowsException <AssertFailedException>(() => _architecture.CheckRule(_falseRule));
     Assert.ThrowsException <AssertFailedException>(() => _falseRule.Check(_architecture));
     Assert.AreEqual(_expectedErrorMessage,
                     RemoveAssertionText(Assert.ThrowsException <AssertFailedException>(() => _architecture.CheckRule(_falseRule)).Message));
     Assert.AreEqual(_expectedErrorMessage,
                     RemoveAssertionText(Assert.ThrowsException <AssertFailedException>(() => _falseRule.Check(_architecture)).Message));
 }
        public void TypesShouldBeInCorrectLayer()
        {
            //you can use the fluent API to write your own rules
            IArchRule exampleClassesShouldBeInExampleLayer =
                Classes().That().Are(ExampleClasses).Should().Be(ExampleLayer);
            IArchRule forbiddenInterfacesShouldBeInForbiddenLayer =
                Interfaces().That().Are(ForbiddenInterfaces).Should().Be(ForbiddenLayer);

            //check if your architecture fulfils your rules
            exampleClassesShouldBeInExampleLayer.Check(Architecture);
            forbiddenInterfacesShouldBeInForbiddenLayer.Check(Architecture);

            //you can also combine your rules
            IArchRule combinedArchRule =
                exampleClassesShouldBeInExampleLayer.And(forbiddenInterfacesShouldBeInForbiddenLayer);

            combinedArchRule.Check(Architecture);
        }
Esempio n. 8
0
        public void CheckArchRuleTest()
        {
            TrueArchRule1.Check(Architecture);
            TrueArchRule2.Check(Architecture);
            var exception1 =
                Assert.Throws <FailedArchRuleException>(() => WrongArchRule1.Check(Architecture));
            var exception2 =
                Assert.Throws <FailedArchRuleException>(() => WrongArchRule2.Check(Architecture));
            var exception3 =
                Assert.Throws <FailedArchRuleException>(() => WrongArchRule3.Check(Architecture));
            var exception4 =
                Assert.Throws <FailedArchRuleException>(() => WrongArchRule4.Check(Architecture));
            var exception5 =
                Assert.Throws <FailedArchRuleException>(() => WrongArchRule5.Check(Architecture));
            var exception6 =
                Assert.Throws <FailedArchRuleException>(() => WrongArchRule6.Check(Architecture));
            var exception7 =
                Assert.Throws <FailedArchRuleException>(() => WrongArchRule7.Check(Architecture));
            var exception8 =
                Assert.Throws <FailedArchRuleException>(() => WrongArchRule8.Check(Architecture));
            var exception1And3 =
                Assert.Throws <FailedArchRuleException>(() => WrongArchRule1AndWrongArchRule3.Check(Architecture));
            var exception4And8 =
                Assert.Throws <FailedArchRuleException>(() => WrongArchRule4AndWrongArchRule8.Check(Architecture));

            Assert.Equal(_expectedWrongArchRule1ErrorMessage, exception1.Message);
            Assert.Equal(_expectedWrongArchRule2ErrorMessage, exception2.Message);
            Assert.Equal(_expectedWrongArchRule3ErrorMessage, exception3.Message);
            Assert.Equal(_expectedWrongArchRule4ErrorMessage, exception4.Message);
            Assert.Equal(_expectedWrongArchRule5ErrorMessage, exception5.Message);
            Assert.Equal(_expectedWrongArchRule6ErrorMessage, exception6.Message);
            Assert.Equal(_expectedWrongArchRule7ErrorMessage, exception7.Message);
            Assert.Equal(_expectedWrongArchRule8ErrorMessage, exception8.Message);
            Assert.Equal(_expectedWrongArchRule1AndWrongArchRule3ErrorMessage, exception1And3.Message);
            Assert.Equal(_expectedWrongArchRule4AndWrongArchRule8ErrorMessage, exception4And8.Message);
        }