Ejemplo n.º 1
0
        public void decorate_closed_type_uses_filter()
        {
            var policy = new DecoratorPolicy(typeof(IWidget), typeof(WidgetDecorator), i => i.Name == "ok");

            policy.DetermineInterceptors(typeof(IWidget), new SmartInstance <AWidget>().Named("not right"))
            .Any().ShouldBeFalse();

            policy.DetermineInterceptors(typeof(IWidget), new SmartInstance <AWidget>().Named("ok"))
            .Any().ShouldBeTrue();
        }
Ejemplo n.º 2
0
        public void decorate_closed_type_no_filter_does_not_match_on_plugin_type()
        {
            var policy = new DecoratorPolicy(typeof(IWidget), typeof(WidgetDecorator));

            policy.DetermineInterceptors(typeof(AWidget), new SmartInstance <AWidget>())
            .Any().ShouldBeFalse();
        }
Ejemplo n.º 3
0
        public void open_generics_happy_path()
        {
            var policy = new DecoratorPolicy(typeof(IFoo <,>), typeof(DecoratedFoo <,>));

            policy.DetermineInterceptors(typeof(IFoo <string, int>), new SmartInstance <Foo <string, int> >())
            .Single()
            .ShouldBeOfType <DecoratorInterceptor>()
            .Instance.PluggedType
            .ShouldBe(typeof(DecoratedFoo <string, int>));
        }
Ejemplo n.º 4
0
        public void decorate_closed_type_no_filter_matches_on_plugin_type()
        {
            var policy = new DecoratorPolicy(typeof(IWidget), typeof(WidgetDecorator));

            policy.DetermineInterceptors(typeof(IWidget), new SmartInstance <AWidget>())
            .Single()
            .ShouldBeOfType <DecoratorInterceptor>()
            .Instance
            .PluggedType
            .ShouldBe(typeof(WidgetDecorator));
        }