Exemplo n.º 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.That(ex.Message.Contains(typeof(string).ToString()));
        }
Exemplo n.º 2
0
        public void ActivateInstance_ReturnsResultOfInvokingSuppliedDelegate()
        {
            var instance = new object();

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

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