Example #1
0
        public void ThrowsAnExceptionWhenTheTypeDoesNotHaveAPublicParameterlessConstructorOrAConstructorWhoseParametersAllHaveADefaultValue()
        {
            var assemblyQualifiedName = typeof(Baz).AssemblyQualifiedName;

            Assert.That(
                () => SlowFactory.CreateInstance <IBaz>(assemblyQualifiedName),
                Throws.Exception.Message.ContainsSubstring("Unable to find suitable constructor for"));
        }
Example #2
0
        public void ThrowsAnExceptionWhenTheTypeIsNotAssignableToTheGenericTypeArgument()
        {
            var assemblyQualifiedName = typeof(Foo).AssemblyQualifiedName;

            Assert.That(
                () => SlowFactory.CreateInstance <IBar>(assemblyQualifiedName),
                Throws.Exception.Message.ContainsSubstring("type is not assignable to the"));
        }
Example #3
0
        public void ThrowsAnExceptionWhenTheTypeIsAbstract()
        {
            var assemblyQualifiedName = typeof(IFoo).AssemblyQualifiedName;

            Assert.That(
                () => SlowFactory.CreateInstance <IFoo>(assemblyQualifiedName),
                Throws.Exception.Message.ContainsSubstring("Unable to create instance of abstract type"));
        }
Example #4
0
        public void ThrowsAnExceptionWhenTheAssemblyQualifiedNameCanNotBeLocated()
        {
            const string assemblyQualifiedName = "this string is not the assembly qualified name of any type";

            Assert.That(
                () => SlowFactory.CreateInstance <IFoo>(assemblyQualifiedName),
                Throws.Exception.Message.ContainsSubstring("Unable to locate a type with the name of"));
        }
Example #5
0
        public void ReturnsAnInstanceOfATypeThatHasAPublicParameterlessConstructor()
        {
            var assemblyQualifiedName = typeof(Foo).AssemblyQualifiedName;

            Assert.That(SlowFactory.CreateInstance <IFoo>(assemblyQualifiedName), Is.InstanceOf <Foo>());
        }
Example #6
0
        public void ReturnsAnInstanceOfATypeThatHasAPublicConstructorWhoseParametersAllHaveADefaultValue()
        {
            var assemblyQualifiedName = typeof(Bar).AssemblyQualifiedName;

            Assert.That(SlowFactory.CreateInstance <IBar>(assemblyQualifiedName), Is.InstanceOf <Bar>());
        }