Exemplo n.º 1
0
        private string GetTags(string assembly, string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(string.Empty);
            }

            NSpecResultModel model = null;

            if (_loadedAssemblies.TryGetValue(assembly, out model))
            {
                var context = model.ContextCollection.AllContexts().FirstOrDefault(t => t.UniqueName == name);
                if (context != null)
                {
                    return(string.Join(",", context.Tags));
                }
                else
                {
                    var example = model.ContextCollection.Examples().FirstOrDefault(t => t.UniqueName == name);
                    if (example != null)
                    {
                        return(string.Join(",", example.Tags));
                    }
                }
            }

            return(string.Empty);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the test count in assembly.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="testName">Name of the test.</param>
        /// <returns></returns>
        public int GetTestCountInAssembly(string assembly, string testName = null)
        {
            NSpecResultModel model = null;

            if (_loadedAssemblies.TryGetValue(assembly, out model))
            {
                if (!string.IsNullOrWhiteSpace(testName))
                {
                    if (assembly == testName)
                    {
                        return(model.ContextCollection.Examples().Count());
                    }
                    else
                    {
                        var context = model.ContextCollection.AllContexts().FirstOrDefault(t => t.UniqueName == testName);
                        if (context == null)
                        {
                            return(1);
                        }
                        return(context.AllExamples().Count());
                    }
                }
            }
            return(0);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Unloads the assembly.
        /// </summary>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <returns></returns>
        public bool UnloadAssembly(string assemblyName)
        {
            NSpecResultModel model = null;

            if (_loadedAssemblies.TryGetValue(assemblyName, out model))
            {
                _loadedAssemblies.Remove(assemblyName);
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
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);
        }