Exemplo n.º 1
0
        /// <summary>
        /// Runs the tests.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="uniqueSpecName">Name of the unique spec.</param>
        /// <param name="resultFormatter">The result formatter.</param>
        /// <returns></returns>
        public async Task<NSpecResultModel> RunTests(string assembly, string uniqueSpecName, IFormatterWithOutput resultFormatter)
        {
            var task = Task.Run(() =>
            {
                var tags = GetTags(assembly, uniqueSpecName);
                var runnerInvocation = new ContextRunnerInvocator(assembly, tags, resultFormatter, false);
                _activeDomain = new NSpecTestDomain(assembly);
                return _activeDomain.Run(runnerInvocation, t => t.Run());
            });

            return await task;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Runs the tests.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="uniqueSpecName">Name of the unique spec.</param>
        /// <param name="resultFormatter">The result formatter.</param>
        /// <returns></returns>
        public async Task <NSpecResultModel> RunTests(string assembly, string uniqueSpecName, IFormatterWithOutput resultFormatter)
        {
            var task = Task.Run(() =>
            {
                var tags             = GetTags(assembly, uniqueSpecName);
                var runnerInvocation = new ContextRunnerInvocator(assembly, tags, resultFormatter, false);
                _activeDomain        = new NSpecTestDomain(assembly);
                return(_activeDomain.Run(runnerInvocation, t => t.Run()));
            });

            return(await task);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads the assembly.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <returns></returns>
        public async Task <NSpecResultModel> LoadAssembly(string assembly)
        {
            var task = Task.Run(() =>
            {
                var runnerInvocation = new ContextRunnerInvocator(assembly, string.Empty);
                _activeDomain        = new NSpecTestDomain(assembly);
                var result           = _activeDomain.Run(runnerInvocation, t => t.BuildContexts());;
                _loadedAssemblies.Add(assembly, result);
                return(result);
            });

            return(await task);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads the assembly.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <returns></returns>
        public async Task<NSpecResultModel> LoadAssembly(string assembly)
        {
            var task = Task.Run(() =>
            {
                var runnerInvocation = new ContextRunnerInvocator(assembly, string.Empty);
                _activeDomain = new NSpecTestDomain(assembly);
                var result = _activeDomain.Run(runnerInvocation, t => t.BuildContexts()); ;
                _loadedAssemblies.Add(assembly, result);
                return result;
            });

            return await task;
        }
Exemplo n.º 5
0
        public NSpecResultModel Run(ContextRunnerInvocator invocation, Func <ContextRunnerInvocator, NSpecResultModel> action)
        {
            var type = typeof(Wrapper);

            var assemblyName = type.Assembly.GetName().Name;

            var typeName = type.FullName;

            CurrentDomain.AssemblyResolve += Resolve;

            var wrapper = (Wrapper)CurrentDomain.CreateInstanceAndUnwrap(assemblyName, typeName);

            NSpecResultModel failures = wrapper.Execute(invocation, action);

            AppDomain.Unload(CurrentDomain);

            CurrentDomain = null;

            return(failures);
        }
Exemplo n.º 6
0
        public NSpecResultModel Run(ContextRunnerInvocator invocation, Func<ContextRunnerInvocator, NSpecResultModel> action)
        {
            var type = typeof(Wrapper);

            var assemblyName = type.Assembly.GetName().Name;

            var typeName = type.FullName;

            CurrentDomain.AssemblyResolve += Resolve;

            var wrapper = (Wrapper)CurrentDomain.CreateInstanceAndUnwrap(assemblyName, typeName);

            NSpecResultModel failures = wrapper.Execute(invocation, action);

            AppDomain.Unload(CurrentDomain);

            CurrentDomain = null;

            return failures;
        }
Exemplo n.º 7
0
 /// <summary>
 ///  Executes the specified invocation.
 /// </summary>
 /// <param name="invocation">The invocation.</param>
 /// <param name="action">The action.</param>
 /// <returns></returns>
 public NSpecResultModel Execute(ContextRunnerInvocator invocation, Func<ContextRunnerInvocator, NSpecResultModel> action)
 {
     return action(invocation);
 }
Exemplo n.º 8
0
 /// <summary>
 ///  Executes the specified invocation.
 /// </summary>
 /// <param name="invocation">The invocation.</param>
 /// <param name="action">The action.</param>
 /// <returns></returns>
 public NSpecResultModel Execute(ContextRunnerInvocator invocation, Func <ContextRunnerInvocator, NSpecResultModel> action)
 {
     return(action(invocation));
 }