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); }
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); }
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 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]); }