[NUI] Rebase develnui (DevelNUI only patches --> master) (#3910)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Devel.Tests.Ubuntu / nunit.framework / Common / OutputSpecification.cs
1 // ***********************************************************************
2 // Copyright (c) 2011 Charlie Poole
3 //
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:
11 // 
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 // 
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 // ***********************************************************************
23 #define PORTABLE
24 #define TIZEN
25 #define NUNIT_FRAMEWORK
26 #define NUNITLITE
27 #define NET_4_5
28 #define PARALLEL
29 using System;
30
31 namespace NUnit.Common
32 {
33     /// <summary>
34     /// OutputSpecification encapsulates a file output path and format
35     /// for use in saving the results of a run.
36     /// </summary>
37     public class OutputSpecification
38     {
39         #region Constructor
40
41         /// <summary>
42         /// Construct an OutputSpecification from an option value.
43         /// </summary>
44         /// <param name="spec">The option value string.</param>
45         public OutputSpecification(string spec)
46         {
47             if (spec == null)
48                 throw new NullReferenceException("Output spec may not be null");
49
50             string[] parts = spec.Split(';');
51             this.OutputPath = parts[0];
52
53             for (int i = 1; i < parts.Length; i++)
54             {
55                 string[] opt = parts[i].Split('=');
56
57                 if (opt.Length != 2)
58                     throw new ArgumentException();
59
60                 switch (opt[0].Trim())
61                 {
62                     case "format":
63                         string fmt = opt[1].Trim();
64
65                         if (this.Format != null && this.Format != fmt)
66                             throw new ArgumentException(
67                                 string.Format("Conflicting format options: {0}", spec));
68
69                         this.Format = fmt;
70                         break;
71
72                     case "transform":
73                         string val = opt[1].Trim();
74
75                         if (this.Transform != null && this.Transform != val)
76                             throw new ArgumentException(
77                                 string.Format("Conflicting transform options: {0}", spec));
78
79                         if (this.Format != null && this.Format != "user")
80                             throw new ArgumentException(
81                                 string.Format("Conflicting format options: {0}", spec));
82
83                         this.Format = "user";
84                         this.Transform = opt[1].Trim();
85                         break;
86                 }
87             }
88
89             if (Format == null)
90                 Format = "nunit3";
91         }
92
93         #endregion
94
95         #region Properties
96
97         /// <summary>
98         /// Gets the path to which output will be written
99         /// </summary>
100         public string OutputPath { get; private set; }
101
102         /// <summary>
103         /// Gets the name of the format to be used
104         /// </summary>
105         public string Format { get; private set; }
106
107         /// <summary>
108         /// Gets the file name of a transform to be applied
109         /// </summary>
110         public string Transform { get; private set; }
111
112         #endregion
113     }
114 }