Example #1
0
 public void Should_invoke_method_successfully()
 {
     ObjectFactory objectFactory = new ObjectFactory();
     objectFactory.AddClass(typeof(ValidHooks));
     objectFactory.CreateObjects();
     var method = Reflection.GetMethod(typeof(ValidHooks), "Before1");
     var hook = new Hook(method);
     hook.Invoke(objectFactory);
 }
Example #2
0
 public void Invoke_should_throw_when_method_throws()
 {
     ObjectFactory objectFactory = new ObjectFactory();
     objectFactory.AddClass(typeof(ValidHooks));
     objectFactory.CreateObjects();
     var method = Reflection.GetMethod(typeof(ValidHooks), "ThrowsException");
     var hook = new Hook(method);
     hook.Invoke(objectFactory);
 }
Example #3
0
 public void Constructor_should_throw_given_invalid_method()
 {
     var method = Reflection.GetMethod(typeof(InvalidHooks), "Before1");
     var hook = new Hook(method);
 }
Example #4
0
 public void Constructor_should_take_a_method_for_Method_property()
 {
     var method = Reflection.GetMethod(typeof(ValidHooks), "Before1");
     var hook = new Hook(method);
     Assert.That(hook.Method, Is.EqualTo(method));
 }
 public void Should_invoke_tagged_hook_when_scenario_has_matching_tag()
 {
     ObjectFactory objectFactory = new ObjectFactory();
     objectFactory.AddClass(typeof(ValidHooks));
     objectFactory.CreateObjects();
     var method = Reflection.GetMethod(typeof(ValidHooks), "BeforeWithTagThrowsException");
     var hook = new Hook(method);
     Assert.Throws<Exception>(() => hook.Invoke(objectFactory, new string[] {"my_tag"}));
 }
 public void Constructor_should_set_HasTags_to_true_when_tags_on_attribute()
 {
     var method = Reflection.GetMethod(typeof(ValidHooks), "BeforeWithTag");
     var hook = new Hook(method);
     Assert.That(hook.HasTags, Is.True);
 }
 public void Constructor_should_get_tag_from_attribute()
 {
     var method = Reflection.GetMethod(typeof(ValidHooks), "BeforeWithTag");
     var hook = new Hook(method);
     Assert.That(hook.Tag, Is.EqualTo("my_tag"));
 }
 public void Should_not_invoke_tagged_hook_when_scenario_has_no_tags()
 {
     ObjectFactory objectFactory = new ObjectFactory();
     objectFactory.AddClass(typeof(ValidHooks));
     objectFactory.CreateObjects();
     var method = Reflection.GetMethod(typeof(ValidHooks), "BeforeWithTagThrowsException");
     var hook = new Hook(method);
     hook.Invoke(objectFactory, new string[0]);
 }