Example #1
0
        public void wrap_negative()
        {
            var policy = new DecoratorPolicy <ISomething, WrappedThing>();

            var instance = new ObjectInstance(GetType(), this);

            policy.TryWrap(instance, out var wrapped).ShouldBeFalse();

            wrapped.ShouldBeNull();
        }
Example #2
0
        public void wrap_positive()
        {
            var policy = new DecoratorPolicy <ISomething, WrappedThing>();

            var instance = new ConstructorInstance(typeof(ISomething), typeof(InnerThing), ServiceLifetime.Transient);

            policy.TryWrap(instance, out var wrapped).ShouldBeTrue();
            var configured = wrapped.ShouldBeOfType <ConstructorInstance>();

            configured.ServiceType.ShouldBe(typeof(ISomething));
            configured.ImplementationType.ShouldBe(typeof(WrappedThing));


            configured.InlineDependencies.Single().ShouldBeSameAs(instance);
        }