public void WriteTestFile(OutputSpecification spec) { string outputPath = Path.Combine(workDirectory, spec.OutputPath); IResultWriter outputWriter = null; switch (spec.Format) { case "nunit3": outputWriter = new NUnit3XmlOutputWriter(); break; case "cases": outputWriter = new TestCaseOutputWriter(); break; case "user": Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase); string dir = Path.GetDirectoryName(uri.LocalPath); outputWriter = new XmlTransformOutputWriter(Path.Combine(dir, spec.Transform)); break; default: throw new ArgumentException( string.Format("Invalid XML output format '{0}'", spec.Format), "spec"); } outputWriter.WriteResultFile(result, outputPath); Console.WriteLine("Tests ({0}) saved as {1}", spec.Format, outputPath); }
private void CheckOutputPathWritability(OutputSpecification spec) { string outputPath = Path.Combine(_workDirectory, spec.OutputPath); try { GetResultWriter(spec).CheckWritability(outputPath); } catch (SystemException ex) { throw new NUnitEngineException( String.Format( "The path specified in --result {0} could not be written to", spec.OutputPath), ex); } }
private IResultWriter GetResultWriter(OutputSpecification spec) { return(_resultService.GetResultWriter(spec.Format, new object[] { spec.Transform })); }