예제 #1
0
 public void InvalidNames()
 {
     {
         Assert.Throws <ArgumentNullException>(() => new RouteConfiguration().DeclareRoute(new SubRouteConfiguration(null, x => true)));
         Assert.Throws <ArgumentNullException>(() => new RouteConfiguration().AddAction(new TestActionConfiguration(null)));
     }
     RouteConfiguration c;
     {
         c = new RouteConfiguration()
             .DeclareRoute(new SubRouteConfiguration("", x => true)
                           .DeclareRoute(new SubRouteConfiguration("", x => true)));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Null, "A route name can be empty but not 2 can be empty at the same time. The name of the root RouteConfiguration is always the empty string.");
     }
     {
         c = new RouteConfiguration()
             .AddAction(new TestActionConfiguration(""));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Null);
     }
     {
         c = new RouteConfiguration()
             .AddAction(new TestActionConfiguration("/"));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Null);
     }
     {
         c = new RouteConfiguration()
             .AddAction(new TestActionConfiguration("A/B"));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Null);
     }
 }
예제 #2
0
        public void RoutesAndActions()
        {
            RouteConfiguration c =
                new RouteConfiguration()
                .AddAction(
                    new ActionSequenceConfiguration("FirstGroup")
                    .AddAction(new TestActionConfiguration("Sink1"))
                    .AddAction(new TestActionConfiguration("Sink2"))
                    .AddAction(new ActionParallelConfiguration("Parallel n°1")
                               .AddAction(new TestActionConfiguration("Sink3"))
                               .AddAction(new TestActionConfiguration("Sink4")))
                    .AddAction(new ActionParallelConfiguration("Parallel n°2")
                               .AddAction(new TestActionConfiguration("Sink3"))
                               .AddAction(new TestActionConfiguration("Sink4"))))
                .AddAction(new TestActionConfiguration("SecondGlobal"))
                .DeclareRoute(
                    new SubRouteConfiguration("CKTask", name => name.StartsWith("CKTask:"))
                    .AddAction(new TestActionConfiguration("TaskSink"))
                    .RemoveAction("SecondGlobal"))
                .AddAction(new TestActionConfiguration("ForAllExceptCKTask"))
                .DeclareRoute(
                    new SubRouteConfiguration("Request", name => name.Contains("/request/"))
                    .RemoveAction("FirstGroup")
                    .AddAction(new TestActionConfiguration("RequestSink"))
                    .AddAction(new TestActionConfiguration("AnotherRequestSink"))
                    .DeclareRoute(
                        new SubRouteConfiguration("NoBugInRequest", name => name.Contains("/BugFree/"))
            {
                ImportParentActions = false
            }));

            var resolved = c.Resolve(TestHelper.ConsoleMonitor);

            Assert.That(resolved, Is.Not.Null);
            Assert.That(resolved.AllSubRoutes.Count, Is.EqualTo(3));

            var root = resolved.Root;

            Assert.That(root, Is.Not.Null);
            Assert.That(root.ActionsResolved, Is.Not.Null.And.Count.EqualTo(3));

            var ckTask = resolved.FindSubRouteByName("CKTask");

            Assert.That(ckTask, Is.Not.Null);
            Assert.That(ckTask.ActionsResolved, Is.Not.Null.And.Count.EqualTo(2));

            var request = resolved.FindSubRouteByName("Request");

            Assert.That(request, Is.Not.Null);
            Assert.That(request.ActionsResolved, Is.Not.Null.And.Count.EqualTo(4));

            var noBug = resolved.FindSubRouteByName("NoBugInRequest");

            Assert.That(noBug, Is.Not.Null);
            Assert.That(noBug.ActionsResolved, Is.Not.Null.And.Count.EqualTo(0));
        }
예제 #3
0
 public void ActionNamesConflict()
 {
     RouteConfiguration c;
     {
         c = new RouteConfiguration()
             .AddAction(new TestActionConfiguration("Name"))
             .AddAction(new TestActionConfiguration("Name"));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Null);
     }
     {
         c = new RouteConfiguration()
             .AddAction(new ActionParallelConfiguration("Parallel")
                        .AddAction(new TestActionConfiguration("Name"))
                        .AddAction(new TestActionConfiguration("Name")));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Null);
     }
     {
         c = new RouteConfiguration()
             .AddAction(new ActionSequenceConfiguration("Sequence")
                        .AddAction(new TestActionConfiguration("Name"))
                        .AddAction(new TestActionConfiguration("Name")));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Null);
     }
     {
         c = new RouteConfiguration()
             .AddAction(new TestActionConfiguration("Name"))
             .AddAction(new ActionSequenceConfiguration("FirstGroup")
                        .AddAction(new TestActionConfiguration("Name")));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Not.Null, "Sequence acts as a namespace.");
     }
     {
         c = new RouteConfiguration()
             .AddAction(new ActionSequenceConfiguration("G1")
                        .AddAction(new TestActionConfiguration("Name")))
             .AddAction(new ActionSequenceConfiguration("G2")
                        .AddAction(new TestActionConfiguration("Name")));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Not.Null, "Sequence hide names below them.");
     }
     {
         c = new RouteConfiguration()
             .AddAction(new ActionSequenceConfiguration("G1")
                        .AddAction(new TestActionConfiguration("Name")))
             .AddAction(new ActionParallelConfiguration("P1")
                        .AddAction(new TestActionConfiguration("Name")))
             .AddAction(new ActionParallelConfiguration("P2")
                        .AddAction(new TestActionConfiguration("Name")))
             .AddAction(new ActionSequenceConfiguration("G2")
                        .AddAction(new TestActionConfiguration("Name")));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Not.Null, "Parallels also hide names below them.");
     }
 }
예제 #4
0
 public void RouteNamesConflict()
 {
     RouteConfiguration c;
     {
         c = new RouteConfiguration()
             .DeclareRoute(new SubRouteConfiguration("Name", x => true))
             .DeclareRoute(new SubRouteConfiguration("Name", x => true));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Null);
     }
     {
         c = new RouteConfiguration()
             .DeclareRoute(new SubRouteConfiguration("Name", x => true)
                           .DeclareRoute(new SubRouteConfiguration("Name", x => true)));
         Assert.That(c.Resolve(TestHelper.ConsoleMonitor), Is.Null);
     }
 }