Inheritance: NAnt.Core.Element
コード例 #1
0
ファイル: NUNit2TestCollection.cs プロジェクト: RoastBoy/nant
 /// <summary>
 /// Adds a <see cref="NUnit2Test"/> to the end of the collection.
 /// </summary>
 /// <param name="item">The <see cref="NUnit2Test"/> to be added to the end of the collection.</param> 
 /// <returns>The position into which the new element was inserted.</returns>
 public int Add(NUnit2Test item) {
     return base.List.Add(item);
 }
コード例 #2
0
ファイル: NUNit2TestCollection.cs プロジェクト: RoastBoy/nant
 /// <summary>
 /// Adds the elements of a <see cref="NUnit2Test"/> array to the end of the collection.
 /// </summary>
 /// <param name="items">The array of <see cref="NUnit2Test"/> elements to be added to the end of the collection.</param> 
 public void AddRange(NUnit2Test[] items) {
     for (int i = 0; (i < items.Length); i = (i + 1)) {
         Add(items[i]);
     }
 }
コード例 #3
0
ファイル: NUNit2TestCollection.cs プロジェクト: RoastBoy/nant
 /// <summary>
 /// Removes a member from the collection.
 /// </summary>
 /// <param name="item">The <see cref="NUnit2Test"/> to remove from the collection.</param>
 public void Remove(NUnit2Test item) {
     base.List.Remove(item);
 }
コード例 #4
0
ファイル: NUNit2TestCollection.cs プロジェクト: RoastBoy/nant
 /// <summary>
 /// Initializes a new instance of the <see cref="NUnit2TestCollection"/> class
 /// with the specified array of <see cref="NUnit2Test"/> instances.
 /// </summary>
 public NUnit2TestCollection(NUnit2Test[] value) {
     AddRange(value);
 }
コード例 #5
0
        private bool TestWithNUnit(string outputFilePath)
        {
            bool hasErrors = false;
            #region <nunit2>
            var task = new NUnit2Task();
            // this little assignment makes the whole TestTask very difficult to unit test
            // unless maybe we subclass Project for testing?
            task.Project = Project;

            #region <formatter type="Plain" />
            var formatter = new FormatterElement();
            formatter.Type = FormatterType.Plain;
            task.FormatterElements.Add(formatter);
            #endregion

            #region <test assemblyname="outputFilePath" />
            var test = new NUnit2Test();
            test.AssemblyFile = new FileInfo(outputFilePath);
            task.Tests.Add(test);
            #endregion

            try
            {
                task.Execute();
            }
            catch (BuildException be)
            {
                hasErrors = true;
                Log(Level.Error, be.Message);
            }
            #endregion
            return hasErrors;
        }
コード例 #6
0
ファイル: NUNit2TestCollection.cs プロジェクト: RoastBoy/nant
 /// <summary>
 /// Inserts a <see cref="NUnit2Test"/> into the collection at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
 /// <param name="item">The <see cref="NUnit2Test"/> to insert.</param>
 public void Insert(int index, NUnit2Test item) {
     base.List.Insert(index, item);
 }
コード例 #7
0
ファイル: NUNit2TestCollection.cs プロジェクト: RoastBoy/nant
 /// <summary>
 /// Determines whether a <see cref="NUnit2Test"/> is in the collection.
 /// </summary>
 /// <param name="item">The <see cref="NUnit2Test"/> to locate in the collection.</param> 
 /// <returns>
 /// <see langword="true" /> if <paramref name="item"/> is found in the 
 /// collection; otherwise, <see langword="false" />.
 /// </returns>
 public bool Contains(NUnit2Test item) {
     return base.List.Contains(item);
 }
コード例 #8
0
ファイル: NUnit2Task.cs プロジェクト: julianhaslinger/nant
        private void FormatResult(NUnit2Test testElement, TestResult result)
        {
            // temp file for storing test results
            string xmlResultFile = Path.GetTempFileName();

            try {
                XmlResultWriter resultWriter = new XmlResultWriter(xmlResultFile);
                resultWriter.SaveTestResult(result);

                foreach (FormatterElement formatter in FormatterElements) {
                    // permanent file for storing test results
                    string outputFile = result.Name + "-results" + formatter.Extension;

                    if (formatter.Type == FormatterType.Xml) {
                        if (formatter.UseFile) {

                            if (formatter.OutputDirectory != null) {
                                // ensure output directory exists
                                if (!formatter.OutputDirectory.Exists) {
                                    formatter.OutputDirectory.Create();
                                }

                                // combine output directory and result filename
                                outputFile = Path.Combine(formatter.OutputDirectory.FullName,
                                    Path.GetFileName(outputFile));
                            }

                            // copy the temp result file to permanent location
                            File.Copy(xmlResultFile, outputFile, true);
                        } else {
                            using (StreamReader reader = new StreamReader(xmlResultFile)) {
                                // strip off the xml header
                                reader.ReadLine();
                                StringBuilder builder = new StringBuilder();
                                while (reader.Peek() > -1) {
                                    builder.Append(reader.ReadLine().Trim()).Append(
                                        Environment.NewLine);
                                }
                                Log(Level.Info, builder.ToString());
                            }
                        }
                    } else if (formatter.Type == FormatterType.Plain) {
                        TextWriter writer;
                        if (formatter.UseFile) {

                            if (formatter.OutputDirectory != null) {
                                // ensure output directory exists
                                if (!formatter.OutputDirectory.Exists) {
                                    formatter.OutputDirectory.Create();
                                }

                                // combine output directory and result filename
                                outputFile = Path.Combine(formatter.OutputDirectory.FullName,
                                    Path.GetFileName(outputFile));
                            }

                            writer = new StreamWriter(outputFile);
                        } else {
                            writer = new LogWriter(this, Level.Info, CultureInfo.InvariantCulture);
                        }
                        CreateSummaryDocument(xmlResultFile, writer, testElement);
                        writer.Close();
                    }
                }
            } catch (Exception ex) {
                throw new BuildException("Test results could not be formatted.",
                    Location, ex);
            } finally {
                // make sure temp file with test results is removed
                File.Delete(xmlResultFile);
            }
        }
コード例 #9
0
 /// <summary>
 /// Removes a member from the collection.
 /// </summary>
 /// <param name="item">The <see cref="NUnit2Test"/> to remove from the collection.</param>
 public void Remove(NUnit2Test item)
 {
     base.List.Remove(item);
 }
コード例 #10
0
 /// <summary>
 /// Adds a <see cref="NUnit2Test"/> to the end of the collection.
 /// </summary>
 /// <param name="item">The <see cref="NUnit2Test"/> to be added to the end of the collection.</param>
 /// <returns>The position into which the new element was inserted.</returns>
 public int Add(NUnit2Test item)
 {
     return(base.List.Add(item));
 }
コード例 #11
0
 /// <summary>
 /// Inserts a <see cref="NUnit2Test"/> into the collection at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
 /// <param name="item">The <see cref="NUnit2Test"/> to insert.</param>
 public void Insert(int index, NUnit2Test item)
 {
     base.List.Insert(index, item);
 }
コード例 #12
0
 /// <summary>
 /// Retrieves the index of a specified <see cref="NUnit2Test"/> object in the collection.
 /// </summary>
 /// <param name="item">The <see cref="NUnit2Test"/> object for which the index is returned.</param>
 /// <returns>
 /// The index of the specified <see cref="NUnit2Test"/>. If the <see cref="NUnit2Test"/> is not currently a member of the collection, it returns -1.
 /// </returns>
 public int IndexOf(NUnit2Test item)
 {
     return(base.List.IndexOf(item));
 }
コード例 #13
0
 /// <summary>
 /// Determines whether a <see cref="NUnit2Test"/> is in the collection.
 /// </summary>
 /// <param name="item">The <see cref="NUnit2Test"/> to locate in the collection.</param>
 /// <returns>
 /// <see langword="true" /> if <paramref name="item"/> is found in the
 /// collection; otherwise, <see langword="false" />.
 /// </returns>
 public bool Contains(NUnit2Test item)
 {
     return(base.List.Contains(item));
 }
コード例 #14
0
ファイル: NUnit2Task.cs プロジェクト: skolima/NAnt
 private void CreateSummaryDocument(string resultFile, TextWriter writer, NUnit2Test test)
 {
     XPathDocument originalXPathDocument = new XPathDocument(resultFile);
     XslTransform summaryXslTransform = new XslTransform();
     XmlTextReader transformReader = GetTransformReader(test);
     summaryXslTransform.Load(transformReader);
     summaryXslTransform.Transform(originalXPathDocument, null, writer);
 }
コード例 #15
0
ファイル: NUNit2TestCollection.cs プロジェクト: RoastBoy/nant
 /// <summary>
 /// Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.        
 /// </summary>
 /// <param name="array">The one-dimensional array that is the destination of the elements copied from the collection. The array must have zero-based indexing.</param> 
 /// <param name="index">The zero-based index in <paramref name="array"/> at which copying begins.</param>
 public void CopyTo(NUnit2Test[] array, int index) {
     base.List.CopyTo(array, index);
 }
コード例 #16
0
ファイル: NUnit2Task.cs プロジェクト: julianhaslinger/nant
 private void CreateSummaryDocument(string resultFile, TextWriter writer, NUnit2Test test)
 {
     XPathDocument originalXPathDocument = new XPathDocument(resultFile);
     // Using XslTransform instead of XslCompiledTransform because the latter
     // does not display nunit output for unknown reasons.
     XslTransform summaryXslTransform = new XslTransform();
     XmlTextReader transformReader = GetTransformReader(test);
     summaryXslTransform.Load(transformReader);
     summaryXslTransform.Transform(originalXPathDocument, null, writer);
 }
コード例 #17
0
ファイル: NUNit2TestCollection.cs プロジェクト: RoastBoy/nant
 /// <summary>
 /// Retrieves the index of a specified <see cref="NUnit2Test"/> object in the collection.
 /// </summary>
 /// <param name="item">The <see cref="NUnit2Test"/> object for which the index is returned.</param> 
 /// <returns>
 /// The index of the specified <see cref="NUnit2Test"/>. If the <see cref="NUnit2Test"/> is not currently a member of the collection, it returns -1.
 /// </returns>
 public int IndexOf(NUnit2Test item) {
     return base.List.IndexOf(item);
 }
コード例 #18
0
ファイル: NUnit2Task.cs プロジェクト: julianhaslinger/nant
        private XmlTextReader GetTransformReader(NUnit2Test test)
        {
            XmlTextReader transformReader;
            if (test.XsltFile == null) {
                Assembly assembly = Assembly.GetAssembly(typeof(XmlResultWriter));
                ResourceManager resourceManager = new ResourceManager("NUnit.Util.Transform", assembly);
                string xmlData = (string) resourceManager.GetObject("Summary.xslt", CultureInfo.InvariantCulture);
                transformReader = new XmlTextReader(new StringReader(xmlData));
            } else {
                if (!test.XsltFile.Exists) {
                    throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                        "Transform file '{0}' does not exist.", test.XsltFile.FullName),
                        Location);
                }
                transformReader = new XmlTextReader(test.XsltFile.FullName);
            }

            return transformReader;
        }
コード例 #19
0
ファイル: NUnit2ExTask.cs プロジェクト: sillsdev/WorldPad
		private StringCollection GetTestAssemblies(NUnit2Test test)
		{
			StringCollection files = new StringCollection();

			if ( test.AssemblyFile.FullName != null )
				files.Add(test.AssemblyFile.FullName);
			else
				files = test.Assemblies.FileNames;

			return files;
		}