예제 #1
0
        public async Task Should_Infer_Command_Behvaior_Pipelines()
        {
            var bee     = new Bee();
            var handler = new FilteredHandler();
            var resp    = await handler.CommandAsync <Bee>(bee);

            Assert.IsInstanceOfType(resp, typeof(Bee));
            Assert.AreEqual(1, bee.Filters.Count);
            Assert.IsInstanceOfType(bee.Filters[0], typeof(LogBehavior <Command, object>));
        }
예제 #2
0
        public async Task Should_Infer_Promise_Pipelines()
        {
            var boo     = new Boo();
            var handler = new FilteredHandler();
            var resp    = await handler.CommandAsync <Boo>(boo);

            Assert.IsInstanceOfType(resp, typeof(Boo));
            Assert.AreEqual(1, boo.Filters.Count);
            Assert.IsInstanceOfType(boo.Filters[0], typeof(LogBehavior <Boo, Boo>));
        }
예제 #3
0
        public async Task Should_Infer_Task_Pipelines()
        {
            var baz     = new Baz();
            var handler = new FilteredHandler();
            var resp    = await handler.CommandAsync <Baz>(baz);

            Assert.IsInstanceOfType(resp, typeof(SuperBaz));
            Assert.AreEqual(1, baz.Filters.Count);
            Assert.IsInstanceOfType(baz.Filters[0], typeof(LogBehaviorT <Baz, SuperBaz>));
        }
예제 #4
0
        public async Task Should_Promote_Promise_Behvaior_Pipelines()
        {
            var foo     = new Foo();
            var handler = new FilteredHandler();
            var resp    = await handler.CommandAsync <Foo>(foo);

            Assert.IsInstanceOfType(resp, typeof(SuperFoo));
            Assert.AreEqual(1, foo.Filters.Count);
            Assert.IsInstanceOfType(foo.Filters[0], typeof(LogBehavior <Foo, SuperFoo>));
        }
예제 #5
0
        public void Should_Infer_Pipelines()
        {
            var foo     = new Foo();
            var handler = new FilteredHandler();
            var resp    = handler.Command <Foo>(foo);

            Assert.IsInstanceOfType(resp, typeof(SuperFoo));
            Assert.AreEqual(1, foo.Filters.Count);
            Assert.IsInstanceOfType(foo.Filters[0], typeof(LogBehavior <Foo, SuperFoo>));
        }
예제 #6
0
        public void Should_Create_Pipelines()
        {
            var bar     = new Bar();
            var handler = new FilteredHandler();

            Assert.IsTrue(handler.Handle(bar));
            Assert.AreEqual(2, bar.Handled);
            Assert.AreEqual(2, bar.Filters.Count);
            Assert.AreSame(handler, bar.Filters[0]);
            Assert.IsInstanceOfType(bar.Filters[1], typeof(LogFilter <Bar, object>));
        }
예제 #7
0
 public IEventAggregator AddListener(Action <object> listener, Predicate <object> filter)
 {
     lock (_locker)
     {
         var filteredHandler = new FilteredHandler <object>(listener, filter);
         if (_filteredHandlers.Contains(filteredHandler))
         {
             return(this);
         }
         _filteredHandlers.Add(filteredHandler);
     }
     return(this);
 }