Exemplo n.º 1
0
        public void Should_support_delivery()
        {
            Vane<Message> vane = VaneFactory.New<Message>(x =>
                {
                    x.Consumer(() => new TestConsumer(), xc =>
                        {
                            xc.Consume<A>(c => c.Consume);
                            xc.Consume<B>(c => c.Consume);
                        });
                });

            var a = new A {Value = "Hello"};
            Payload<Message> payload = new MessagePayload<A>(a);

            vane.Execute(payload, CancellationToken.None);

            var b = new B {Value = "World"};
            payload = new MessagePayload<B>(b);

            vane.Execute(payload, CancellationToken.None);

            var visitor = new StringVaneVisitor();
            visitor.Visit(vane);
            Console.WriteLine(visitor.ToString());
        }
Exemplo n.º 2
0
        public void Should_display_the_types_of_all_the_vanes()
        {
            var ms = new MemoryStream();
            var sw = new StreamWriter(ms);

            Vane<TestSubject> wired = VaneFactory.Success<TestSubject>();

            var typeRouter = new TypeRouterFeather<TestSubject>(x => typeof(ISubjectA));
            typeRouter.Add(VaneFactory.Success<ISubjectA>(), x => x);
            typeRouter.Add(VaneFactory.Success<ISubjectB>(), x => x);

            Vane<TestSubject> vane = VaneFactory.Success(new LogFeather<TestSubject>(sw, x => ""),
                new WireTapFeather<TestSubject>(wired),
                new ProfilerFeather<TestSubject>(sw, TimeSpan.FromMilliseconds(2)),
                new TransactionFeather<TestSubject>(),
                new Test(),
                typeRouter);

            var visitor = new StringVaneVisitor();
            visitor.Visit(vane);

            Console.WriteLine(visitor);
        }