public void CanSupplyASpecificInstanceForPredefinedParameterTypes()
        {
            var testImpl = new TestImpl();
            var injector = new MethodParameterInjector(new object[] { "string", 5 },
                new[] { new KeyValuePair<Type, object>(typeof(ITestInterface), testImpl) });

            injector.GetParameters(_method3, new object[] { this });
            Assert.That(injector.GetParameters(_method3, new object[] { this })[1], Is.SameAs(testImpl));
        }
 internal void Execute(ConsoleApplicationBase app, object command, MethodParameterInjector injector)
 {
     try
     {
         var parameters = injector.GetParameters(_method, new[] { command });
         MethodInvoker.Invoke(_method, app, parameters);
     }
     catch (Exception e)
     {
         Toolkit.HandleException(e, command, injector);
     }
 }
Ejemplo n.º 3
0
 private void Execute(object command, MethodParameterInjector injector)
 {
     try
     {
         var parameters = injector.GetParameters(_method, new [] {command});
         MethodInvoker.Invoke(_method, _handler, parameters);
     }
     catch (Exception e)
     {
         Toolkit.HandleException(e, command, injector);
     }
 }
 public void Execute(ConsoleApplicationBase app, object command, IConsoleAdapter console, MethodParameterInjector injector, CommandExecutionMode executionMode)
 {
     try
     {
         var parameters = injector.GetParameters(_method, new[] { command });
         MethodInvoker.Invoke(_method, command, parameters);
     }
     catch (Exception e)
     {
         Toolkit.HandleException(e, command, injector);
     }
 }
        public void ConstructorProvidedInjectableIsUsed()
        {
            var injector = new MethodParameterInjector(new object[]{this});

            Assert.That(injector.GetParameters(_method1, new object[] {}), Is.EqualTo(new object[] {this}));
        }
        public void AnExceptionIsThrownIfTheParametersCannotBeInjected()
        {
            var injector = new MethodParameterInjector(new object[]{5});

            injector.GetParameters(_method2, new object[] {this});
        }
        public void SpecificInstancesCanBeInjectedAfterConstruction()
        {
            var testImpl = new TestImpl();
            var injector = new MethodParameterInjector(new object[] { "string", 5 });

            injector.AddInstance<ITestInterface>(testImpl);

            injector.GetParameters(_method3, new object[] { this });
            Assert.That(injector.GetParameters(_method3, new object[] { this })[1], Is.SameAs(testImpl));
        }
        public void MultipleParametersAreInjected()
        {
            var injector = new MethodParameterInjector(new object[]{5, "string"});

            Assert.That(injector.GetParameters(_method2, new object[] {this}), Is.EqualTo(new object[] {this, 5, "string"}));
        }