Пример #1
0
        public void WhenActivationDelegateReturnsNull_ExceptionDescribesLimitType()
        {
            var target = new DelegateActivator(typeof(string), (c, p) => null);

            var ex = Assert.Throws <DependencyResolutionException>(
                () => target.ActivateInstance(new ContainerBuilder().Build(), Enumerable.Empty <Parameter>()));

            Assert.Contains(typeof(string).ToString(), ex.Message);
        }
Пример #2
0
        public void ActivateInstance_ReturnsResultOfInvokingSuppliedDelegate()
        {
            var instance = new object();

            var target =
                new DelegateActivator(typeof(object), (c, p) => instance);

            Assert.Same(instance, target.ActivateInstance(new ContainerBuilder().Build(), Enumerable.Empty <Parameter>()));
        }