public void Execute_ResultAlreadySet_NoInstanceCreated()
        {
            //Assign
            var task = new WindsorConstruction();


            var context = Context.Create(DependencyResolver.CreateStandardResolver());
            var typeConfig = Substitute.For<AbstractTypeConfiguration>();
            typeConfig.Type = typeof(StubClass);

            var args = new ObjectConstructionArgs(context, null, typeConfig, null);
            var result = new StubClass2();
            args.Result = result;

            Assert.IsNotNull(args.Result);

            //Act
            task.Execute(args);

            //Assert
            Assert.IsNotNull(args.Result);
            Assert.IsTrue(args.Result is StubClass2);
            Assert.AreEqual(result, args.Result);

        }
        public void Execute_RequestInstanceOfClass_ReturnsInstance()
        {
            //Assign
            var task = new WindsorConstruction();

            
            var context = Context.Create(DependencyResolver.CreateStandardResolver());
            var typeConfig = Substitute.For<AbstractTypeConfiguration>();
            typeConfig.Type = typeof (StubClass);

            var typeCreationContext = Substitute.For<AbstractTypeCreationContext>();
            var service = Substitute.For<AbstractService>();

            var args = new ObjectConstructionArgs(context, typeCreationContext, typeConfig, service);

            Assert.IsNull(args.Result);

            //Act
            task.Execute(args);

            //Assert
            Assert.IsNotNull(args.Result);
            Assert.IsTrue(args.Result is StubClass);

        }
        public void Execute_RequestInstanceOfInterface_ReturnsNullInterfaceNotSupported()
        {
            //Assign
            var task = new WindsorConstruction();


            var context = Context.Create(DependencyResolver.CreateStandardResolver());
            var typeConfig = Substitute.For<AbstractTypeConfiguration>();
            typeConfig.Type = typeof(StubInterface);

            var typeCreationContext = Substitute.For<AbstractTypeCreationContext>();

            var args = new ObjectConstructionArgs(context, typeCreationContext, typeConfig, null);



            Assert.IsNull(args.Result);

            //Act
            task.Execute(args);

            //Assert
            Assert.IsNull(args.Result);

        }
        public void Execute_RequestInstanceOfClassWithParameters_NoInstanceReturnedDoesntHandle()
        {
            //Assign
            var task = new WindsorConstruction();


            var context = Context.Create(DependencyResolver.CreateStandardResolver());
            var typeConfig = Substitute.For<AbstractTypeConfiguration>();
            typeConfig.Type = typeof(StubClassWithParameters);

            string param1 = "test param1";
            int param2 = 450;
            double param3 = 489;
            string param4 = "param4 test";

            var typeCreationContext = Substitute.For<AbstractTypeCreationContext>();
            typeCreationContext.ConstructorParameters = new object[]{param1, param2, param3, param4};


            var args = new ObjectConstructionArgs(context, typeCreationContext, typeConfig, null);

            Assert.IsNull(args.Result);

            //Act
            task.Execute(args);

            //Assert
            Assert.IsNull(args.Result);


        }
        public void Execute_RequestInstanceOfClassWithService_ReturnsInstanceWithService()
        {
            //Assign
            var task = new WindsorConstruction();

            var resolver = DependencyResolver.CreateStandardResolver() as DependencyResolver;
            var context = Context.Create(resolver);
            var service = Substitute.For<AbstractService>();

            resolver.Container.Register(
                Component.For<StubServiceInterface>().ImplementedBy<StubService>().LifestyleTransient()
                );
            
            var typeConfig = Substitute.For<AbstractTypeConfiguration>();
            typeConfig.Type = typeof(StubClassWithService);

            var typeCreationContext = Substitute.For<AbstractTypeCreationContext>();


            var args = new ObjectConstructionArgs(context, typeCreationContext, typeConfig, service );

            Assert.IsNull(args.Result);

            //Act
            task.Execute(args);

            //Assert
            Assert.IsNotNull(args.Result);
            Assert.IsTrue(args.Result is StubClassWithService);
            
            var stub = args.Result as StubClassWithService;

            Assert.IsNotNull(stub.Service);
            Assert.IsTrue(stub.Service is StubService);

        }