Ejemplo n.º 1
0
        public void IsMatching_ExactMatch_NoMatch()
        {
            var scope = NamespaceScope.Parse("mynamespace.other");

            scope.IsMatching("mynamespace.othe").Should().BeFalse();
            scope.IsMatching("mynamespace.other2").Should().BeFalse();
            scope.IsMatching("mynamespace.other.deep").Should().BeFalse();
        }
Ejemplo n.º 2
0
        public void Compare_All_Tests()
        {
            var ns1 = NamespaceScope.Parse("mynamespace");
            var ns2 = NamespaceScope.Parse("mynamespace.other");

            ns1.CompareTo(NamespaceScope.All).Should().Be(-1);
            ns2.CompareTo(NamespaceScope.All).Should().Be(-1);
            NamespaceScope.All.CompareTo(ns1).Should().Be(1);
            NamespaceScope.All.CompareTo(ns2).Should().Be(1);
        }
Ejemplo n.º 3
0
        public void ParseConfig_FailureTests()
        {
            Action runParse = () => NamespaceScope.Parse("my*name");

            runParse.ShouldThrow <Exception>();
            runParse = () => NamespaceScope.Parse("");
            runParse.ShouldThrow <Exception>().And.Message.Should().Contain("empty");
            runParse = () => NamespaceScope.Parse("my.other.");
            runParse.ShouldThrow <Exception>();
            runParse = () => NamespaceScope.Parse("my.other*");
            runParse.ShouldThrow <Exception>();
        }
Ejemplo n.º 4
0
        public void Parse_GeneralParsingTests()
        {
            var result = NamespaceScope.Parse("mynamespace");

            result.ToString().Should().Be("mynamespace");
            result = NamespaceScope.Parse("mynamespace.other");
            result.ToString().Should().Be("mynamespace.other");
            result = NamespaceScope.Parse("mynamespace.other.*");
            result.ToString().Should().Be("mynamespace.other.*");
            result = NamespaceScope.Parse("mynamespace.other+*");
            result.ToString().Should().Be("mynamespace.other+*");
        }
Ejemplo n.º 5
0
        public void Compare_MatchType_Tests()
        {
            var ns1 = NamespaceScope.Parse("mynamespace");
            var ns2 = NamespaceScope.Parse("mynamespace.*");
            var ns3 = NamespaceScope.Parse("mynamespace+*");

            ns1.CompareTo(ns2).Should().Be(-1);
            ns2.CompareTo(ns1).Should().Be(1);
            ns1.CompareTo(ns3).Should().Be(-1);
            ns3.CompareTo(ns1).Should().Be(1);
            ns2.CompareTo(ns3).Should().Be(-1);
            ns3.CompareTo(ns2).Should().Be(1);
        }
Ejemplo n.º 6
0
        public void Compare_Length_Tests()
        {
            var ns1 = NamespaceScope.Parse("mynamespace");
            var ns2 = NamespaceScope.Parse("mynamespace.other");
            var ns3 = NamespaceScope.Parse("mynamespace.other.deep");

            ns1.CompareTo(ns2).Should().Be(1);
            ns2.CompareTo(ns1).Should().Be(-1);
            ns1.CompareTo(ns3).Should().Be(1);
            ns3.CompareTo(ns1).Should().Be(-1);
            ns2.CompareTo(ns3).Should().Be(1);
            ns3.CompareTo(ns2).Should().Be(-1);
        }
Ejemplo n.º 7
0
        public void Sorting_NamespaceDefinitionTypeOrder()
        {
            var def1 = new AssemblyLevelTraceOnDefinition(NamespaceScope.Parse("rootnamespace"), TraceTargetVisibility.All, TraceTargetVisibility.All);
            var def2 = new AssemblyLevelTraceOnDefinition(NamespaceScope.Parse("rootnamespace.*"), TraceTargetVisibility.All, TraceTargetVisibility.All);
            var def3 = new AssemblyLevelTraceOnDefinition(NamespaceScope.Parse("rootnamespace+*"), TraceTargetVisibility.All, TraceTargetVisibility.All);

            var list = new List <AssemblyLevelTraceDefinition>()
            {
                def1, def2, def3
            };

            list.Sort(new AssemblyLevelTraceDefinitionComparer());

            list[0].Should().BeSameAs(def1);
            list[1].Should().BeSameAs(def2);
            list[2].Should().BeSameAs(def3);
        }
        public void Sorting_TraceOnNoTraceOrder()
        {
            AssemblyLevelTraceOnDefinition def1 = new AssemblyLevelTraceOnDefinition(NamespaceScope.Parse("rootnamespace"), TraceTargetVisibility.All, TraceTargetVisibility.All);
            AssemblyLevelTraceOnDefinition def2 = new AssemblyLevelTraceOnDefinition(NamespaceScope.Parse("rootnamespace.other"), TraceTargetVisibility.All, TraceTargetVisibility.All);
            AssemblyLevelNoTraceDefinition def3 = new AssemblyLevelNoTraceDefinition(NamespaceScope.Parse("rootnamespace"));
            AssemblyLevelNoTraceDefinition def4 = new AssemblyLevelNoTraceDefinition(NamespaceScope.Parse("rootnamespace.other"));

            List <AssemblyLevelTraceDefinition> list = new List <AssemblyLevelTraceDefinition>()
            {
                def1, def2, def3, def4
            };

            list.Sort(new AssemblyLevelTraceDefinitionComparer());

            list[0].Should().BeSameAs(def4);
            list[1].Should().BeSameAs(def2);
            list[2].Should().BeSameAs(def3);
            list[3].Should().BeSameAs(def1);
        }
Ejemplo n.º 9
0
        public void Sorting_MethodVisibility()
        {
            var def1 = new AssemblyLevelTraceOnDefinition(NamespaceScope.Parse("rootnamespace.other"), TraceTargetVisibility.All, TraceTargetVisibility.All);
            var def2 = new AssemblyLevelTraceOnDefinition(NamespaceScope.Parse("rootnamespace.other"), TraceTargetVisibility.All, TraceTargetVisibility.InternalOrMoreVisible);
            var def3 = new AssemblyLevelTraceOnDefinition(NamespaceScope.Parse("rootnamespace.other"), TraceTargetVisibility.All, TraceTargetVisibility.Public);
            var def4 = new AssemblyLevelTraceOnDefinition(NamespaceScope.Parse("rootnamespace.other"), TraceTargetVisibility.All, TraceTargetVisibility.ProtectedOrMoreVisible);
            var def5 = new AssemblyLevelTraceOnDefinition(NamespaceScope.Parse("rootnamespace.other"), TraceTargetVisibility.All, TraceTargetVisibility.None);

            var list = new List <AssemblyLevelTraceDefinition>()
            {
                def1, def2, def3, def4, def5
            };

            list.Sort(new AssemblyLevelTraceDefinitionComparer());

            list[0].Should().BeSameAs(def5);
            list[1].Should().BeSameAs(def3);
            list[2].Should().BeSameAs(def2);
            list[3].Should().BeSameAs(def4);
            list[4].Should().BeSameAs(def1);
        }
Ejemplo n.º 10
0
        public void IsMatching_OnlyChildren_DeepChild_Match()
        {
            var scope = NamespaceScope.Parse("mynamespace.other.*");

            scope.IsMatching("mynamespace.other.child.deep").Should().BeTrue();
        }
Ejemplo n.º 11
0
        public void IsMatching_OnlyChildren_Overstring_NoMatch()
        {
            var scope = NamespaceScope.Parse("mynamespace.other.*");

            scope.IsMatching("mynamespace.othe").Should().BeFalse();
        }
Ejemplo n.º 12
0
        public void IsMatching_ExactMatch_Match()
        {
            var scope = NamespaceScope.Parse("mynamespace.other");

            scope.IsMatching("mynamespace.other").Should().BeTrue();
        }
Ejemplo n.º 13
0
        public void IsMatching_SelfAndChildren_Child_Match()
        {
            var scope = NamespaceScope.Parse("mynamespace.other+*");

            scope.IsMatching("mynamespace.other.child").Should().BeTrue();
        }
Ejemplo n.º 14
0
        public void IsMatching_SelfAndChildren_Substring_NoMatch()
        {
            var scope = NamespaceScope.Parse("mynamespace.other+*");

            scope.IsMatching("mynamespace.other2").Should().BeFalse();
        }