示例#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"));
        }
示例#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"));
        }
示例#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"));
        }
示例#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"));
        }
示例#5
0
        public void ReturnsAnInstanceOfATypeThatHasAPublicParameterlessConstructor()
        {
            var assemblyQualifiedName = typeof(Foo).AssemblyQualifiedName;

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

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