Пример #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);
 }