Exemplo n.º 1
0
        public virtual Repository Load()
        {
            var repository = new Repository();

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                if (IsDesiredAssembly(assembly))
                {
                    foreach (var type in assembly.GetTypes())
                    {
                        foreach (var method in type.GetMethods(StepDefinition.MethodFlags))
                        {
                            if (StepDefinition.IsValidMethod(method))
                            {
                                repository.StepDefinitions.Add(new StepDefinition(method));
                                _objectFactory.AddClass(method.ReflectedType);
                            }
                            if (BeforeHook.IsValidMethod(method))
                            {
                                repository.BeforeHooks.Add(new BeforeHook(method));
                                _objectFactory.AddClass(method.ReflectedType);
                            }
                            if (AfterHook.IsValidMethod(method))
                            {
                                repository.AfterHooks.Add(new AfterHook(method));
                                _objectFactory.AddClass(method.ReflectedType);
                            }
                        }
                    }
                }
            }

            return(repository);
        }
Exemplo n.º 2
0
        public virtual Repository Load()
        {
            var repository = new Repository();

            foreach (var assemblyPath in _assemblyPaths)
            {
                var assembly = Assembly.LoadFrom(assemblyPath);
                foreach (var type in assembly.GetTypes())
                {
                    foreach (var method in type.GetMethods(StepDefinition.MethodFlags))
                    {
                        if (StepDefinition.IsValidMethod(method))
                        {
                            repository.StepDefinitions.Add(new StepDefinition(method));
                            _objectFactory.AddClass(method.ReflectedType);
                        }
                        if (BeforeHook.IsValidMethod(method))
                        {
                            repository.BeforeHooks.Add(new BeforeHook(method));
                            _objectFactory.AddClass(method.ReflectedType);
                        }
                        if (AfterHook.IsValidMethod(method))
                        {
                            repository.AfterHooks.Add(new AfterHook(method));
                            _objectFactory.AddClass(method.ReflectedType);
                        }
                    }
                }
            }

            return(repository);
        }
Exemplo n.º 3
0
 public AfterHook(MethodInfo method)
     : base(method)
 {
     if (!AfterHook.IsValidMethod(method))
     {
         throw new ArgumentException(String.Format("<{0}> is not a valid After hook method.", method));
     }
     Method = method;
 }
 public void Should_not_load_Before_method()
 {
     var method = Reflection.GetMethod(typeof(InvalidHooks), "Before1");
     var hook = new AfterHook(method);
 }
 public void Should_load_After_method_successfully()
 {
     var method = Reflection.GetMethod(typeof(ValidHooks), "After1");
     var hook = new AfterHook(method);
     Assert.That(hook.Method, Is.EqualTo(method));
 }