Ejemplo n.º 1
0
        /// <summary>
        /// Adds a trait to the settings, to exclude in test execution.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="name">The trait name.</param>
        /// <param name="values">The trait values.</param>
        /// <returns>The same <see cref="XUnit2Settings"/> instance so that multiple calls can be chained.</returns>
        public static XUnit2Settings ExcludeTrait(this XUnit2Settings settings, string name, params string[] values)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

            if (values.Any(v => v == null))
            {
                throw new ArgumentException("values may not contain a null value.", "values");
            }

            if (!settings.TraitsToExclude.ContainsKey(name))
            {
                settings.TraitsToExclude.Add(name, new List <string>());
            }

            foreach (var value in values.Where(v => v != null))
            {
                settings.TraitsToExclude[name].Add(value);
            }

            return(settings);
        }
Ejemplo n.º 2
0
        public static void XUnit2(this ICakeContext context, string pattern, XUnit2Settings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var assemblies = context.Globber.GetFiles(pattern);

            XUnit2(context, assemblies, settings);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a method name to the settings, to include in test execution. Method name should be fully qualified; i.e., MyNameSpace.MyClassName.MyMethod
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="methodNameToInclude">The method name to include.</param>
        /// <returns>The same <see cref="XUnit2Settings"/> instance so that multiple calls can be chained.</returns>
        public static XUnit2Settings IncludeMethod(this XUnit2Settings settings, string methodNameToInclude)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (string.IsNullOrEmpty(methodNameToInclude))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(methodNameToInclude));
            }

            settings.MethodsToInclude.Add(methodNameToInclude);

            return(settings);
        }
Ejemplo n.º 4
0
        public static void XUnit2(this ICakeContext context, string pattern, XUnit2Settings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var assemblies = context.Globber.GetFiles(pattern).ToArray();

            if (assemblies.Length == 0)
            {
                context.Log.Verbose("The provided pattern did not match any files.");
                return;
            }

            XUnit2(context, assemblies, settings);
        }
Ejemplo n.º 5
0
 internal static FilePath GetReportFileName(IReadOnlyList <FilePath> assemblyPaths, XUnit2Settings settings)
 {
     if (string.IsNullOrEmpty(settings.ReportName))
     {
         return(assemblyPaths.Count == 1
             ? assemblyPaths[0].GetFilename()
             : new FilePath("TestResults"));
     }
     else
     {
         return(settings.ReportName);
     }
 }
Ejemplo n.º 6
0
        public static void XUnit2(this ICakeContext context, IEnumerable <FilePath> assemblies, XUnit2Settings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException("assemblies");
            }
            if (assemblies == null)
            {
                throw new ArgumentNullException("assemblies");
            }

            var runner = new XUnit2Runner(context.FileSystem, context.Environment, context.Globber, context.ProcessRunner);

            foreach (var assembly in assemblies)
            {
                runner.Run(assembly, settings);
            }
        }
Ejemplo n.º 7
0
        public static void XUnit2(this ICakeContext context, IEnumerable <string> assemblies, XUnit2Settings settings)
        {
            if (assemblies == null)
            {
                throw new ArgumentNullException("assemblies");
            }
            var paths = assemblies.Select(p => new FilePath(p));

            XUnit2(context, paths, settings);
        }
Ejemplo n.º 8
0
        public static void XUnit2(this ICakeContext context, IEnumerable <FilePath> assemblies, XUnit2Settings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(assemblies));
            }
            if (assemblies == null)
            {
                throw new ArgumentNullException(nameof(assemblies));
            }

            var runner = new XUnit2Runner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);

            runner.Run(assemblies, settings);
        }