Пример #1
0
        public void GiveMeComplaints_ForbiddenExplicitRuleWithPrivateAssetsAndGenericRule_MatchesPrivateAssetsToo(bool?isPrivateAssetsAllSet, bool hasComplaints)
        {
            var ruler = new ReferencesRuler(
                patternParser: new RegexPatternParser(),
                rules: new [] { new ReferenceRule(".*", ".*", RuleKind.Forbidden, description: "no no", isPrivateAssetsAllSet: isPrivateAssetsAllSet) });

            var complaints = ruler.GiveMeComplaints(new Reference(from: "a", to: "b", isPrivateAssetsAllSet: true, versionOrNull: null));

            Assert.Equal(hasComplaints, !string.IsNullOrEmpty(complaints));
        }
Пример #2
0
        public void GiveMeComplaints_NoRules_NoComplaints()
        {
            var ruler = new ReferencesRuler(
                patternParser: new RegexPatternParser(),
                rules: new List <ReferenceRule>());

            var complaints = ruler.GiveMeComplaints(new Reference(from: "a", to: "b", isPrivateAssetsAllSet: true, versionOrNull: null));

            Assert.True(string.IsNullOrEmpty(complaints));
        }
Пример #3
0
        public void GiveMeComplaints_ForbiddenGeneralRule_ReturnsComplaints()
        {
            var ruler = new ReferencesRuler(
                patternParser: new RegexPatternParser(),
                rules: new [] { new ReferenceRule(".*", "b", RuleKind.Forbidden, description: "no no") });

            var complaints = ruler.GiveMeComplaints(new Reference(from: "a", to: "b", isPrivateAssetsAllSet: true, versionOrNull: null));

            Assert.False(string.IsNullOrEmpty(complaints));
            Assert.Equal("Reference from a to b broke:\nno no", complaints);
        }
Пример #4
0
        public void GiveMeComplaints_ForbiddenGeneralRuleWithExplicitOverridingRule_NoComplaints()
        {
            var ruler = new ReferencesRuler(
                patternParser: new RegexPatternParser(),
                rules: new []
            {
                new ReferenceRule("*", "b", RuleKind.Forbidden, description: "no no"),
                new ReferenceRule("a", "b", RuleKind.Allowed, description: "yes yes")
            });

            var complaints = ruler.GiveMeComplaints(new Reference(from: "a", to: "b", isPrivateAssetsAllSet: true, versionOrNull: null));

            Assert.True(string.IsNullOrEmpty(complaints));
        }
Пример #5
0
        public void GiveMeComplaints_ForbiddenExplicitRuleWithVersionAndException_MatchesVersionAndAllowsForTheException()
        {
            var ruler = new ReferencesRuler(
                patternParser: new RegexPatternParser(),
                rules: new []
            {
                new ReferenceRule(".*", ".*", RuleKind.Forbidden, description: "no no", version: "3.2.1"),
                new ReferenceRule(".*", ".*", RuleKind.Allowed, description: "no no", version: "1.2.3")
            });

            var complaints = ruler.GiveMeComplaints(new Reference(from: "a", to: "b", isPrivateAssetsAllSet: true, versionOrNull: "1.2.3"));

            Assert.True(string.IsNullOrEmpty(complaints));
        }