public void UnwrapsTargetInvocationWhenCreating(string exceptionMessage)
        {
            var sut = new ConstructorInvokingObjectFactory(typeof (AClassThatThrowsExceptionWhenConstructed), new object[] {exceptionMessage});

            var thrown = Assert.Throws<Exception>(() => sut.CreateInstance());
            Assert.Equal(exceptionMessage, thrown.Message);
        }
        public void UsesCorrectType(Type requestedType, object[] arguments)
        {
            var sut = new ConstructorInvokingObjectFactory(requestedType, arguments);
            var actual = sut.CreateInstance();

            Assert.IsType(requestedType, actual);
        }
        public void PassesCorrectArguments(string argument)
        {
            var sut = new ConstructorInvokingObjectFactory(typeof (AClassWithStringArgument), new object[] {argument});

            var expected = new AClassWithStringArgument(argument);
            var actual = sut.CreateInstance();

            Assert.IsType<AClassWithStringArgument>(actual);
            Assert.That((AClassWithStringArgument)actual, Is.StructurallyEqualTo(expected));
        }
 public void SavesPassedInArguments()
 {
     var constructorArguments = new object[0];
     var sut = new ConstructorInvokingObjectFactory(typeof(AClassWithStringArgument), constructorArguments);
     Assert.Same(constructorArguments, sut.ConstructorArguments);
 }
 public void SavesPassedInType(Type typeToPassIn)
 {
     var sut = new ConstructorInvokingObjectFactory(typeToPassIn, new object[0]);
     Assert.Equal(typeToPassIn, sut.TestClassType);
 }