Exemple #1
0
 public void ButIfFactoryMethodIsMissing_ThenCreateFromFactoryMethodAttributeConstructorThrows()
 {
     Assert.Throws <InvalidOperationException>(() =>
     {
         new CreateFromFactoryMethod(typeof(AClass),
                                     typeof(AFactory),
                                     "BuildMethodNameWhichDoesntExist");
     });
 }
Exemple #2
0
        public void ButIfFactoryMethodIsMissing_ThenAAThrows_WithOrWithoutAnAnchor()
        {
            var rules = new[] { new CreateFromFactoryMethod(typeof(AClass), "BuildMethodNameWhichDoesntExist") };

            //
            Assert.Throws <InvalidOperationException>(
                () => new AnythingActivator(rules, andUseDefaultRules: false).New <AClass>()
                );
            Assert.Throws <InvalidOperationException>(
                () => new AnythingActivator(
                    this,
                    instances: null,
                    rules: rules,
                    andUseDefaultRules: false)
                .New <AClass>()
                );
        }