Esempio n. 1
0
            /// <summary/>
            public RunAssembly(Executor executor, object _handler)
            {
                ExecutorCallback handler = ExecutorCallback.Wrap(_handler);

                executor.RunOnSTAThreadWithPreservedWorkingDirectory(() =>
                {
                    bool @continue         = true;
                    AssemblyResult results =
                        new AssemblyResult(executor.assemblyFilename,
                                           AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);

                    foreach (Type type in executor.assembly.GetExportedTypes())
                    {
                        ITestClassCommand testClassCommand = TestClassCommandFactory.Make(type);

                        if (testClassCommand != null)
                        {
                            ClassResult classResult =
                                TestClassCommandRunner.Execute(testClassCommand,
                                                               null,
                                                               command => @continue = OnTestStart(command, handler),
                                                               result => @continue  = OnTestResult(result, handler));

                            results.Add(classResult);
                        }

                        if (!@continue)
                        {
                            break;
                        }
                    }

                    OnTestResult(results, handler);
                });
            }
Esempio n. 2
0
            public RunTests(Executor executor, string _type, List <string> _methods, object _handler)
            {
                Guard.ArgumentNotNull("_type", _type);
                Guard.ArgumentNotNull("_methods", _methods);

                ExecutorCallback handler  = ExecutorCallback.Wrap(_handler);
                Type             realType = executor.assembly.GetType(_type);

                Guard.ArgumentValid("_type", "Type " + _type + " could not be found", realType != null);

                ITypeInfo         type             = Reflector.Wrap(realType);
                ITestClassCommand testClassCommand = TestClassCommandFactory.Make(type);

                List <IMethodInfo> methods = new List <IMethodInfo>();

                foreach (string _method in _methods)
                {
                    try
                    {
                        IMethodInfo method = type.GetMethod(_method);
                        Guard.ArgumentValid("_methods", "Could not find method " + _method + " in type " + _type, method != null);
                        methods.Add(method);
                    }
                    catch (AmbiguousMatchException)
                    {
                        throw new ArgumentException("Ambiguous method named " + _method + " in type " + _type);
                    }
                }

                if (testClassCommand == null)
                {
                    ClassResult result = new ClassResult(type.Type);
                    OnTestResult(result, handler);
                    return;
                }

                executor.RunOnSTAThreadWithPreservedWorkingDirectory(() =>
                                                                     TestClassCommandRunner.Execute(testClassCommand,
                                                                                                    methods,
                                                                                                    command => OnTestStart(command, handler),
                                                                                                    result => OnTestResult(result, handler)));
            }
Esempio n. 3
0
            public RunTests(Executor executor, string _type, List<string> _methods, object _handler)
            {
                Guard.ArgumentNotNull("_type", _type);
                Guard.ArgumentNotNull("_methods", _methods);

                ExecutorCallback handler = ExecutorCallback.Wrap(_handler);
                Type realType = executor.assembly.GetType(_type);
                Guard.ArgumentValid("_type", "Type " + _type + " could not be found", realType != null);

                ITypeInfo type = Reflector.Wrap(realType);
                ITestClassCommand testClassCommand = TestClassCommandFactory.Make(type);

                List<IMethodInfo> methods = new List<IMethodInfo>();

                foreach (string _method in _methods)
                {
                    try
                    {
                        IMethodInfo method = type.GetMethod(_method);
                        Guard.ArgumentValid("_methods", "Could not find method " + _method + " in type " + _type, method != null);
                        methods.Add(method);
                    }
                    catch (AmbiguousMatchException)
                    {
                        throw new ArgumentException("Ambiguous method named " + _method + " in type " + _type);
                    }
                }

                if (testClassCommand == null)
                {
                    ClassResult result = new ClassResult(type.Type);
                    OnTestResult(result, handler);
                    return;
                }

                executor.RunOnSTAThreadWithPreservedWorkingDirectory(() =>
                    TestClassCommandRunner.Execute(testClassCommand,
                                                   methods,
                                                   command => OnTestStart(command, handler),
                                                   result => OnTestResult(result, handler)));
            }
Esempio n. 4
0
            /// <summary/>
            public RunAssembly(Executor executor, object _handler)
            {
                ExecutorCallback handler = ExecutorCallback.Wrap(_handler);

                executor.RunOnSTAThreadWithPreservedWorkingDirectory(() =>
                    {
                        bool @continue = true;
                        AssemblyResult results =
                            new AssemblyResult(executor.assemblyFilename,
                                               AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);

                        foreach (Type type in executor.assembly.GetExportedTypes())
                        {
                            ITestClassCommand testClassCommand = TestClassCommandFactory.Make(type);

                            if (testClassCommand != null)
                            {
                                ClassResult classResult =
                                    TestClassCommandRunner.Execute(testClassCommand,
                                                                   null,
                                                                   command => @continue = OnTestStart(command, handler),
                                                                   result => @continue = OnTestResult(result, handler));

                                results.Add(classResult);
                            }

                            if (!@continue)
                                break;
                        }

                        OnTestResult(results, handler);
                    });
            }