OpenKeyWord  Version: 426, Datum:
Log2TestClipboard.cs
1 #region Header
2 /*
3  ==============================================================================
4  Author: Zoltan Hrabovszki <zh@openkeyword.de>
5 
6  Copyright © 2012, 2013, 2014, 2015 IT-Beratung Hrabovszki
7  www.OpenKeyWord.de
8  ==============================================================================
9 
10  This file is part of OpenKeyWord.
11 
12  OpenKeyWord is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  OpenKeyWord is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with OpenKeyWord. If not, see <http://www.gnu.org/licenses/>.
24 
25  Diese Datei ist Teil von OpenKeyWord.
26 
27  OpenKeyWord ist Freie Software: Sie können es unter den Bedingungen
28  der GNU General Public License, wie von der Free Software Foundation,
29  Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
30  veröffentlichten Version, weiterverbreiten und/oder modifizieren.
31 
32  OpenKeyWord wird in der Hoffnung, dass es nützlich sein wird, aber
33  OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
34  Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
35  Siehe die GNU General Public License für weitere Details.
36 
37  Sie sollten eine Kopie der GNU General Public License zusammen mit
38  OpenKeyWord erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
39 */
40 #endregion Header
41 
42 namespace OKW.Log
43 {
44  using System;
45  using System.Collections.Generic;
46  using System.Text;
47 
48  using OKW.GUI.Test;
49 
64  public class Log2TestClipboard : ILogger
65  {
66  #region Fields
67 
68  string BlanksBefore = string.Empty;
69  int LevelCounter = 0;
70 
71  #endregion Fields
72 
73  #region Methods
74 
80  public void LogError(string fps_Message)
81  {
82  OKW_TestClipboard.Instance.LogValueAdd(this.BlanksBefore + "Error: " + fps_Message);
83  }
84 
91  public void LogException(string fps_Message)
92  {
93  OKW_TestClipboard.Instance.LogValueAdd(this.BlanksBefore + "Exception: " + fps_Message);
94  }
95 
101  public void LogFunctionEnd()
102  {
103  this.LogPrint("-------");
104  this.ResCloseList();
105  }
106 
112  public void LogFunctionEnd(string fps_Return)
113  {
114  this.ResOpenList("Return...");
115  this.LogPrint(fps_Return);
116  this.ResCloseList();
117  this.LogPrint("-------");
118  this.ResCloseList();
119  }
120 
126  public void LogFunctionEnd(bool fpb_Return)
127  {
128  this.ResOpenList("Return...");
129  this.LogPrint(OKW_Helper.Boolean2String(fpb_Return));
130  this.ResCloseList();
131  this.LogPrint("-------");
132  this.ResCloseList();
133  }
134 
140  public void LogFunctionEnd(List<string> fpls_Return)
141  {
142  this.ResOpenList("Return...");
143 
144  foreach (string Value in fpls_Return)
145  {
146  this.LogPrint(Value);
147  }
148 
149  this.ResCloseList();
150  this.LogPrint("-------");
151  this.ResCloseList();
152  }
153 
159  public void LogFunctionStart(string fps_FunctionName, params string[] fpsParameter)
160  {
161  this.ResOpenList(fps_FunctionName);
162  this.ResOpenList("Parameter...");
163 
164  for (int i = 0; i < fpsParameter.Length; i += 2)
165  {
166  this.LogPrint(fpsParameter[i] + ": >>" + fpsParameter[i + 1] + "<<");
167  }
168 
169  this.ResCloseList();
170  this.LogPrint("-------");
171 
172  return;
173  }
174 
180  public void LogKeyWordEnd()
181  {
182  this.ResCloseList();
183  }
184 
190  public void LogKeyWordStart(string fps_KeyWordName, params string[] fpsParameter)
191  {
192  String String2Print = fps_KeyWordName;
193 
194  // Keyword without parameter
195  if (fpsParameter.Length == 0)
196  {
197  // Keyword with one Parameter
198  String2Print = String2Print + "()";
199  }
200  // Keyword with one Parameter
201  else if (fpsParameter.Length == 1)
202  {
203  String2Print = String2Print + ": \"" + fpsParameter[0] + "\"";
204  }
205  // Keyword with two Parameters
206  else if (fpsParameter.Length == 2)
207  {
208  String2Print = String2Print + ": \"" + fpsParameter[0] + "\" = \"" + fpsParameter[1] + "\"";
209  }
210  // Keyword with more then two Parameters
211  else
212  {
213  String2Print = String2Print + "(\"" + fpsParameter[0] + "\"";
214 
215  for (int i = 1; i < fpsParameter.Length; i++)
216  {
217  String2Print = String2Print + ", \"" + fpsParameter[i] + "\"";
218  }
219 
220  String2Print = String2Print + ")";
221  }
222 
223  this.ResOpenList(String2Print);
224 
225  return;
226  }
227 
233  public void LogPrint(string fps_Message)
234  {
235  OKW_TestClipboard.Instance.LogValueAdd(this.BlanksBefore + fps_Message);
236  }
237 
243  public void LogVerify(string fps_Actual, string fps_Expected)
244  {
245  OKW_TestClipboard.Instance.LogValueAdd(this.BlanksBefore + "Expected = >>" + fps_Expected + "<<");
246  OKW_TestClipboard.Instance.LogValueAdd(this.BlanksBefore + " Actual = >>" + fps_Actual + "<<");
247  }
248 
254  public void LogWarning(string fps_Message)
255  {
256  OKW_TestClipboard.Instance.LogValueAdd(this.BlanksBefore + "Warning: " + fps_Message);
257  }
258 
264  public void ResCloseList()
265  {
266  if (this.LevelCounter > 0)
267  {
268  this.LevelCounter--;
269  }
270  else
271  {
272  this.LevelCounter = 0;
273  }
274 
275  this.BlankBefore();
276  }
277 
283  public void ResOpenList(string fps_Name)
284  {
285  this.LogPrint(fps_Name);
286  this.LevelCounter++;
287  this.BlankBefore();
288  }
289 
295  private void BlankBefore()
296  {
297  this.BlanksBefore = new string(' ', this.LevelCounter);
298  }
299 
300  #endregion Methods
301  }
302 }
void ResCloseList()
Closes the outline level.
void LogFunctionStart(string fps_FunctionName, params string[] fpsParameter)
void LogWarning(string fps_Message)
LogWarning Function: Logs a warning to the results file.
Klasse enthält OKW-Hilfsfunktionen.
Definition: OKW_Helper.cs:63
void LogFunctionEnd(List< string > fpls_Return)
void LogVerify(string fps_Actual, string fps_Expected)
Klasse dient zur Test der Logging-Ausgaben.
void LogFunctionEnd(bool fpb_Return)
void LogPrint(string fps_Message)
LogPrint Function: Prints the values of expressions to the results file.
void LogFunctionEnd(string fps_Return)
void LogError(string fps_Message)
LogError Function: Logs an error message to the results file.
Singelton Object. Stores a VAlue for Unittest Assertion.
Debug Logs are not a part of Interface. This functions are Implemented in Logger.cs a Log*Debug funct...
Definition: ILogger.cs:62
void LogKeyWordStart(string fps_KeyWordName, params string[] fpsParameter)
static string Boolean2String(bool fpbTrueOrFalse)
Konvertiert bool true/false nach string "true"/"false".
Definition: OKW_Helper.cs:108
void ResOpenList(string fps_Name)
Definition: Core.cs:40
void LogException(string fps_Message)
LogException Function: Logs a Script Exception to the results file.