1 // ***********************************************************************
2 // Copyright (c) 2011 Charlie Poole
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 // ***********************************************************************
25 #define NUNIT_FRAMEWORK
31 namespace NUnit.Common
34 /// OutputSpecification encapsulates a file output path and format
35 /// for use in saving the results of a run.
37 public class OutputSpecification
42 /// Construct an OutputSpecification from an option value.
44 /// <param name="spec">The option value string.</param>
45 public OutputSpecification(string spec)
48 throw new NullReferenceException("Output spec may not be null");
50 string[] parts = spec.Split(';');
51 this.OutputPath = parts[0];
53 for (int i = 1; i < parts.Length; i++)
55 string[] opt = parts[i].Split('=');
58 throw new ArgumentException();
60 switch (opt[0].Trim())
63 string fmt = opt[1].Trim();
65 if (this.Format != null && this.Format != fmt)
66 throw new ArgumentException(
67 string.Format("Conflicting format options: {0}", spec));
73 string val = opt[1].Trim();
75 if (this.Transform != null && this.Transform != val)
76 throw new ArgumentException(
77 string.Format("Conflicting transform options: {0}", spec));
79 if (this.Format != null && this.Format != "user")
80 throw new ArgumentException(
81 string.Format("Conflicting format options: {0}", spec));
84 this.Transform = opt[1].Trim();
98 /// Gets the path to which output will be written
100 public string OutputPath { get; private set; }
103 /// Gets the name of the format to be used
105 public string Format { get; private set; }
108 /// Gets the file name of a transform to be applied
110 public string Transform { get; private set; }