diff --git a/App.config b/App.config
deleted file mode 100644
index 952ad67..0000000
--- a/App.config
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Detokenizer.cs b/Detokenizer.cs
deleted file mode 100644
index 6140b3c..0000000
--- a/Detokenizer.cs
+++ /dev/null
@@ -1,348 +0,0 @@
-using System;
-using System.Globalization;
-using System.Linq;
-using System.Text;
-
-namespace TeamControlium.Utilities
-{
- public class Detokenizer
- {
- private static readonly char tokenStartChar = '{';
- private static readonly char tokenEndChar = '}';
- private static Random RandomGenerator { get; } = new Random();
-
- ///
- /// Delegate for processing custom tokens if required. If a token cannot be resolved internally, the token (split based on the delimiter) is passed to
- /// the CustomTokenProcessor, if defined. CustomTokenProcessor returns a null string if token not resolved.
- ///
- static public Func CustomTokenProcessor { get; set; }
-
- //[DebuggerStepThrough]
- public static string ProcessTokensInString(string stringWithTokens)
- {
- var detokenizedString = new StringBuilder();
- var startIndex = 0;
- var foundTokenStart = false;
-
- //
- // Find the start of a token, ignoring doubles {{'s as they are litterals)
- //
- while (!foundTokenStart && startIndex < stringWithTokens.Length)
- {
- if (stringWithTokens[startIndex] == tokenStartChar)
- {
- // We are looking at a token start char...
- if ((startIndex < stringWithTokens.Length - 1) && (stringWithTokens[startIndex + 1] == tokenStartChar))
- {
- // Next char is also a start char, so ignore and skip past
- startIndex += 1;
- }
- else
- {
- // Next char not a start char so we have found a token!
- foundTokenStart = true;
- }
- }
- startIndex += 1;
- }
-
- //
- // startIndex is now pointing to first char of a token
- //
-
- if (foundTokenStart)
- {
- var foundTokenEnd = false;
- var endIndex = startIndex; // We start searching for the end of the token from the first character of the
- //
- // Find the end of the token.
- //
- while (!foundTokenEnd && endIndex < stringWithTokens.Length)
- {
- if ((stringWithTokens[endIndex] == tokenStartChar) &&
- !((startIndex < stringWithTokens.Length - 1) && (stringWithTokens[startIndex + 1] == tokenStartChar)))
- {
- //
- // Another start token (and it is NOT a dounble!!!!) We have nested tokens by golly.
- // So, start the process again, but from the new start of the nested token. Hah, this
- // is a quick easy way of dealing with nested tokens!
- //
- startIndex = endIndex + 1;
- }
- else if (stringWithTokens[endIndex] == tokenEndChar)
- {
- if ((endIndex < stringWithTokens.Length - 1) && (stringWithTokens[endIndex + 1] == tokenEndChar))
- {
- // Next char is also an end char, so ignore and skip past
- endIndex += 1;
- }
- else
- {
- // Next char not a start char so we have found a token!
- foundTokenEnd = true;
- }
- }
- endIndex += 1;
- }
- if (foundTokenEnd)
- {
- detokenizedString.Append(stringWithTokens.Substring(0, startIndex - 1));
- string token = stringWithTokens.Substring(startIndex, endIndex - startIndex - 1);
- try
- {
- detokenizedString.Append(ProcessToken(token));
- }
- catch (Exception ex)
- {
- throw new Exception($"Error processing token {{{token}}} ({ex.Message})", ex);
- }
- detokenizedString.Append(stringWithTokens.Substring(endIndex, stringWithTokens.Length - endIndex));
- }
- else
- {
- throw new Exception($"Found token start {{ found at index {startIndex} but no closing }} found: [{stringWithTokens}]");
- }
- // Now, we call ourself again to process any more tokens....
- detokenizedString = new StringBuilder(ProcessTokensInString(detokenizedString.ToString()));
- }
- else
- {
- // So no token found. We will convert all doubles back to singles and return the string...
- detokenizedString.Append(stringWithTokens).Replace("{{", "{").Replace("}}", "}");
- }
- return detokenizedString.ToString();
- }
-
- private static string ProcessToken(string token)
- {
- char delimiter = ';';
- string processedToken = "";
- if (string.IsNullOrEmpty(token)) throw new Exception("Empty token!");
- string[] splitToken = token.Split(new char[] { delimiter }, 2);
- switch (splitToken[0].ToLower().Trim())
- {
- case "random":
- if (splitToken.Length < 2) throw new Exception($"Random token [{token}] needs 3 parts {{random;;}}");
- processedToken = DoRandomToken(delimiter, splitToken[1]);
- break;
- case "date":
- if (splitToken.Length < 2) throw new Exception($"Date token [{token}] needs 3 parts {{date;;}}");
- processedToken = DoDateToken(delimiter, splitToken[1]);
- break;
- case "financialyearstart":
- if (splitToken.Length < 2) throw new Exception($"FinancialYearStart token [{token}] needs 3 parts {{FinancialYearStart;;}}");
- processedToken = DoFinancialYearToken(delimiter, splitToken[1], true);
- break;
- case "financialyearend":
- if (splitToken.Length < 2) throw new Exception($"FinancialYearEnd token [{token}] needs 3 parts {{FinancialYearEnd;;}}");
- processedToken = DoFinancialYearToken(delimiter, splitToken[1], false);
- break;
-// case "seleniumkeys":
-// case "seleniumkey":
-// if (splitToken.Length < 2) throw new Exception($"SeleniumKey token [{token}] needs 2 parts {{SeleniumKey;}}");
-// processedToken = DoSeleniumKey(splitToken[1]);
-// break;
- default:
- if (CustomTokenProcessor!=null)
- {
- try
- {
- processedToken = CustomTokenProcessor(delimiter, splitToken);
- }
- catch (Exception ex)
- {
- throw new Exception($"Error thrown by Custom Token Processor for [{splitToken[0]}] in {token}", ex);
- }
- }
- if (processedToken == null)
- {
- throw new Exception($"Unsupported token [{splitToken[0]}] in {token}");
- }
- break;
- }
-
- return processedToken;
- }
-
- private static string DoRandomToken(char delimiter, string TypeAndLength)
- {
- string[] typeAndLengthOrFormat = TypeAndLength.Split(new char[] { delimiter }, 2);
- string result;
- string select = "";
- string verb = typeAndLengthOrFormat[0].ToLower().Trim();
- if (verb.StartsWith("date("))
- {
- result = DoRandomDate(verb.Substring(verb.IndexOf('(') + 1, verb.Length - 2 - verb.IndexOf('('))).ToString(typeAndLengthOrFormat[1]);
- }
- else if (verb.StartsWith("float("))
- {
- result = DoRandomFloat(verb.Substring(verb.IndexOf('(') + 1, verb.Length - 2 - verb.IndexOf('('))).ToString(typeAndLengthOrFormat[1]);
- }
- else
- {
- // {random,from(ASDF),5} - 5 characters selected from ASDF
- if (verb.StartsWith("from("))
- {
- select = typeAndLengthOrFormat[0].Trim().Substring(verb.IndexOf('(') + 1, verb.Length - 2 - verb.IndexOf('('));
- }
- else
- {
- switch (verb)
- {
- case "letters":
- select = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- break;
- case "lowercaseletters":
- select = "abcdefghijklmnopqrstuvwxyz";
- break;
- case "uppercaseletters":
- select = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- break;
- case "digits":
- select = "01234567890";
- break;
- case "alphanumerics":
- select = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
- break;
- case "acn":
- return ProcessTokensInString("{random;digits;9}");
- case "abn":
- {
- string acn = ProcessTokensInString("{random;acn}");
- return ProcessTokensInString($"{{ABNFromACN;{acn}}}");
- }
- default:
- throw new Exception($"Unrecognised random Type [{typeAndLengthOrFormat[0]}] - Expect letters, lowercaseletters, uppercaseletters digits or alphanumerics");
- }
- }
- if (!int.TryParse(typeAndLengthOrFormat[1], out int number)) throw new Exception($"Invalid number of characters in Random token {{random;;}}");
- result = new string(Enumerable.Repeat(select, number).Select(s => s[RandomGenerator.Next(s.Length)]).ToArray());
- }
-
- return result;
- }
-
- private static string DoDateToken(char delimiter, string OffsetAndFormat)
- {
- string[] offsetAndFormat = OffsetAndFormat.Split(new char[] { delimiter }, 2);
-
- if (offsetAndFormat.Length != 2)
- {
- throw new Exception("Date token does not have a format parameter; example: {date" + delimiter + "today" + delimiter + "dd-MM-yyyy}");
- }
-
- DateTime dt;
- string verb = offsetAndFormat[0].ToLower().Trim();
- if (verb.StartsWith("random("))
- {
- dt = DoRandomDate(verb.Substring(verb.IndexOf('(') + 1, verb.Length - 2 - verb.IndexOf('(')));
- }
- else
- {
- switch (verb)
- {
- case "today":
- dt = DateTime.Now;
- break;
- case "yesterday":
- dt = DateTime.Now.AddDays(-1);
- break;
- case "tomorrow":
- dt = DateTime.Now.AddDays(1);
- break;
- default:
- {
- if (offsetAndFormat[0].Contains('(') && offsetAndFormat[0].EndsWith(")"))
- {
- string[] activeOffset = verb.Substring(0, verb.Length - 1).Split(new char[] { '(' }, 2);
- switch (activeOffset[0].Trim())
- {
- case "addyears":
- dt = DateTime.Now.AddYears(int.Parse(activeOffset[1]));
- break;
- case "addmonths":
- dt = DateTime.Now.AddMonths(int.Parse(activeOffset[1]));
- break;
- case "adddays":
- dt = DateTime.Now.AddDays(int.Parse(activeOffset[1]));
- break;
- default:
- throw new Exception($"Invalid Active Date offset. Expect AddYears(n) AddMonths(n) or AddDays(n). Got [{activeOffset[0].Trim()}]");
- }
- }
- else
- {
- throw new Exception($"Invalid Active Date offset. Open or Closing paranthesis missing. Expect example {{date;AddYears(-30);dd-MM-yyyy}}");
- }
- break;
- }
- }
- }
-
- return dt.ToString(offsetAndFormat[1]);
- }
-
- private static string DoFinancialYearToken(char delimiter, string DateToWorkFromAndFormat, bool Start)
- {
- string[] dateToWorkFromAndFormat = DateToWorkFromAndFormat.Split(new char[] { delimiter }, 2);
-
- if (!DateTime.TryParseExact(dateToWorkFromAndFormat[0], new string[] { "dd/MM/yyyy", "d/MM/yyyy", "dd/M/yyyy", "d/M/yyyy", "dd/MM/yy", "d/MM/yy", "dd/M/yy", "d/M/yy" }, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateToWorkFrom))
- {
- throw new ArgumentException("Cannot parse date. Must be in format d/M/y", "DateToWorkFromAndFormat (first element)");
- }
-
- string year;
- if (dateToWorkFrom.Month >= 7)
- year = Start ? dateToWorkFrom.Year.ToString() : (dateToWorkFrom.Year + 1).ToString();
- else
- year = Start ? (dateToWorkFrom.Year - 1).ToString() : dateToWorkFrom.Year.ToString();
-
- DateTime returnDate = DateTime.ParseExact((Start ? "01/07/" : "30/06/") + year, "dd/MM/yyyy", CultureInfo.InvariantCulture);
- return returnDate.ToString(dateToWorkFromAndFormat[1]);
- }
-
- static private float DoRandomFloat(string MaxAndMinFloats)
- {
- char delimiter = ',';
- string[] MaxAndMin = MaxAndMinFloats.Split(delimiter);
- if (MaxAndMin.Length != 2)
- throw new Exception($"Invalid Maximum and Minimum floats. Expect {{random.float(min;max),}}. Max/min was: [{MaxAndMinFloats}]");
-
- if (!float.TryParse(MaxAndMin[0], out float Min))
- throw new Exception($"Invalid Minimum float. Expect {{random.float(min;max),}}. Max/min was: [{MaxAndMinFloats}]");
- if (!float.TryParse(MaxAndMin[1], out float Max))
- throw new Exception($"Invalid Maximum float. Expect {{random.float(min;max),}}. Max/min was: [{MaxAndMinFloats}]");
-
- return DoRandomFloat(Min, Max);
- }
-
- static public float DoRandomFloat(float MinFloat, float MaxFloat)
- {
- if (MinFloat >= MaxFloat)
- throw new Exception($"Maximum float less than Minimum float! Expect {{random.float(min,max),}} Min = {MinFloat.ToString()}, Max = {MaxFloat.ToString()}");
- return (float)RandomGenerator.NextDouble() * (MaxFloat - MinFloat) + MinFloat;
- }
-
- static private DateTime DoRandomDate(string MaxAndMinDates)
- {
- char delimiter = ',';
- string[] MaxAndMin = MaxAndMinDates.Split(delimiter);
- if (MaxAndMin.Length != 2)
- throw new Exception($"Invalid Maximum and Minimum dates. Expect {{random;date(dd-MM-yyyy,dd-MM-yyyy);}}. Max/min was: [{MaxAndMinDates}]");
-
- if (!DateTime.TryParseExact(MaxAndMin[0], "d-M-yyyy", CultureInfo.InstalledUICulture, DateTimeStyles.None, out DateTime Min))
- throw new Exception($"Invalid Minimum date. Expect {{random;date(dd-MM-yyyy,dd-MM-yyyy);}}. Max/min was: [{MaxAndMinDates}]");
- if (!DateTime.TryParseExact(MaxAndMin[1], "d-M-yyyy", CultureInfo.InstalledUICulture, DateTimeStyles.None, out DateTime Max))
- throw new Exception($"Invalid Maximum date. Expect {{random;date(dd-MM-yyyy,dd-MM-yyyy);}}. Max/min was: [{MaxAndMinDates}]");
-
- return DoRandomDate(Min, Max);
- }
-
- static public DateTime DoRandomDate(DateTime MinDate, DateTime MaxDate)
- {
- if (MinDate > MaxDate)
- throw new Exception($"Maximum date earlier than Maximum date! Expect {{random;date(dd-MM-yyyy,dd-MM-yyyy);}} Mindate = {MinDate.ToString("dd/MM/yyyy")}, Maxdate = {MaxDate.ToString("dd/MM/yyyy")}");
- return MinDate.AddDays(RandomGenerator.Next((MaxDate - MinDate).Days));
- }
- }
-}
\ No newline at end of file
diff --git a/Documentation/.gitignore b/Documentation/.gitignore
new file mode 100644
index 0000000..7ffc278
--- /dev/null
+++ b/Documentation/.gitignore
@@ -0,0 +1,11 @@
+##
+## We only want the .shfbproj file, .png and .aml files
+##
+##
+
+# Ignore everything
+
+# But not these...
+!*.shfbproj
+!*.png
+!*.aml
\ No newline at end of file
diff --git a/Documentation/Content/Welcome.aml b/Documentation/Content/Welcome.aml
new file mode 100644
index 0000000..a42768e
--- /dev/null
+++ b/Documentation/Content/Welcome.aml
@@ -0,0 +1,23 @@
+
+
+
+
+ The TeamControlium test Utilities is a standalone collection of automated-test framework utilities designed to assist .NET Core based automated-test frameworks.
+ Tool and testing phase (IE. Unit, Functional regression, systems etc...) agnostic, the utilities are designed to assist any type of automation-framework.
+ Originally built by Test Automation Engineers as part of an Automation PoC project in 2014-2015, the utilities library has evolved into the multi-facited general-use library it is today. Ported into both Java and (partially) UFT the library continues to evolve and embody the latest test automation technologies. The TeamControlium Controlium library is dependent on this Utilities library, however the Utilities library can be used standalone if the Controlium library is not used.
+
+
+
+ Utilities library members
+
+ The Utilities library consists of a number of member classes made available to consumers:
+
+
+
+ Log - Provides test logging functionality to enable test/framework information and debug level logging. Log output is to Console as default but can be directed to delegated consumer for custom output (IE. HTML/XML wrapping, file output etc...).
+
+
+
+
+
+
diff --git a/Documentation/Documentation.shfbproj b/Documentation/Documentation.shfbproj
new file mode 100644
index 0000000..0471760
--- /dev/null
+++ b/Documentation/Documentation.shfbproj
@@ -0,0 +1,101 @@
+
+
+
+
+ Debug
+ AnyCPU
+ 2.0
+ 24cce119-e46f-4577-b518-55cb69152b9f
+ 2017.9.26.0
+
+ Documentation
+ Documentation
+ Documentation
+
+ Cross-platform (.NET Core/.NET Standard)
+ ..\Docs\
+ Documentation
+ en-US
+
+
+
+
+
+
+
+
+
+
+
+
+ Website
+ C#
+ VS2013
+ True
+ False
+ False
+ False
+ OnlyWarningsAndErrors
+ 100
+ False
+ Working\
+ TeamControlium - Utilities library
+ 1.0.0.0
+ Guid
+ BelowNamespaces
+ False
+ False
+ 2
+ True
+ https://github.com/TeamControlium/Utilities.net/blob/master/LICENSE.txt
+ ©%3b MIT License
+ Blank
+ Summary, Parameter, Returns, AutoDocumentCtors, TypeParameter, AutoDocumentDispose
+ Hello arrse
+
+
+ info%40teamcontrolium.com
+ TeamControlium
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ OnBuildSuccess
+
+
\ No newline at end of file
diff --git a/Documentation/icons/Help.png b/Documentation/icons/Help.png
new file mode 100644
index 0000000..945e89f
Binary files /dev/null and b/Documentation/icons/Help.png differ
diff --git a/General.cs b/General.cs
deleted file mode 100644
index 8f7d256..0000000
--- a/General.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-using HtmlAgilityPack;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text.RegularExpressions;
-
-namespace TeamControlium.Utilities
-{
- public class General
- {
-
- ///
- /// If object is a string and has been set, tokens with the string are processed
- ///
- /// is called recursively until string returned matches string sent. Ensures all tokens and nested tokens removed.
- /// Returns same object type as submitted
- /// Object to process
- /// Processed object
- public static T DetokeniseString(T ObjectToProcess)
- {
- // Only do any processing if the object is a string.
- if (typeof(T) == typeof(String))
- {
- //
- // Call the TokenProcessor in a loop until the string returned is the same as the string passed in. This indicates any processing has been
- // completed. Doing this allows token values to themselves contain tokens)
- //
- string StringToProcess = string.Empty;
- string ProcessedString = (string)(object)ObjectToProcess;
- Logger.Write(Logger.LogLevels.FrameworkDebug, "Object is a string [{0}]. ", ProcessedString ?? string.Empty);
- while (!StringToProcess.Equals(ProcessedString))
- {
- StringToProcess = string.Copy(ProcessedString);
-
- ProcessedString = Detokenizer.ProcessTokensInString(StringToProcess);
- Logger.WriteLine(Logger.LogLevels.FrameworkDebug, "Processed [{0}] to [{1}]", StringToProcess, ProcessedString ?? string.Empty);
- }
- return (T)(object)ProcessedString;
- }
- else
- {
- Logger.WriteLine(Logger.LogLevels.FrameworkDebug, "Object [{0}] not a string. Not processed", typeof(T).Name);
- return ObjectToProcess;
- }
- }
-
- ///
- /// Returns true if string does not start with 0 or starts with t(rue), y(es) or o(n)
- ///
- /// value to check
- /// true if string first digit is not 0 or is true, yes or on
- public static bool IsValueTrue(string Value)
- {
- if (string.IsNullOrEmpty(Value)) return false;
- if (int.TryParse(Value, out int i))
- if (i > 0) return true; else return false;
- return Value.ToLower().StartsWith("t") || Value.ToLower().StartsWith("y") || Value.ToLower().StartsWith("on");
- }
-
- ///
- /// Normalises single and double quotes for XPath use
- ///
- /// String containing single and double quotes
- /// String for XPath use
- public static string CleanStringForXPath(string original)
- {
- if (!original.Contains("'"))
- return '\'' + original + '\'';
-
- else if (!original.Contains("\""))
- return '"' + original + '"';
-
- else
- return "concat('" + original.Replace("'", "',\"'\",'") + "')";
- }
-
- ///
- /// Makes string filename friendly
- ///
- /// Possible unfriendly filename string
- /// String that can be used in a filename
- public static string CleanStringForFilename(string original)
- {
- string invalidChars = Regex.Escape(new string(System.IO.Path.GetInvalidFileNameChars()));
- string invalidRegStr = string.Format(@"([{0}]*\.+$)|([{0}]+)", invalidChars);
- return Regex.Replace(original, invalidRegStr, "_");
- }
-
- ///
- /// Extracts displayed text from an HTML node and desendants
- ///
- /// HTML containing text
- /// Text with HTML stripped out
- public static string GetTextFromHTML(string HtmlData)
- {
- if (string.IsNullOrEmpty(HtmlData)) return string.Empty;
-
- HtmlDocument document = new HtmlDocument();
- document.LoadHtml(HtmlData);
-
- String[] acceptableTags = new String[] { "strong", "em", "u" };
-
- Queue nodes = new Queue(document.DocumentNode.SelectNodes("./*|./text()"));
- while (nodes.Count > 0)
- {
- HtmlNode node = nodes.Dequeue();
- HtmlNode parentNode = node.ParentNode;
-
- if (!acceptableTags.Contains(node.Name) && node.Name != "#text")
- {
- HtmlNodeCollection childNodes = node.SelectNodes("./*|./text()");
-
- if (childNodes != null)
- {
- foreach (var child in childNodes)
- {
- nodes.Enqueue(child);
- parentNode.InsertBefore(child, node);
- }
- }
- parentNode.RemoveChild(node);
- }
- }
-
- return document.DocumentNode.InnerHtml;
- }
- }
-}
diff --git a/Logger.cs b/Logger.cs
deleted file mode 100644
index 2fd0244..0000000
--- a/Logger.cs
+++ /dev/null
@@ -1,408 +0,0 @@
-using System;
-using System.Reflection;
-using System.IO;
-using System.Diagnostics;
-using System.Collections.Generic;
-using System.Threading;
-
-namespace TeamControlium.Utilities
-{
- ///
- /// Enables test scripts to log data that assists in debugging of test scripts and/or framework. Library and
- /// helper classes write to the debug log using log levels Framework
- /// Information and Framework Debug to ensure detailed analysis
- /// is possible.
- /// Debug text redirection is possible if underlying tool supplies its own logging and/or debug output, wired up
- /// to and is set to false.
- /// The timestamp, shown on every line of the log output, is reset on the first call to the Logger.
- ///
- ///
- static public class Logger
- {
- static private bool errorWrittenToEventLog;
- static private Stopwatch testTimer; // Used to keep track of time since first call to Logger class made.
- static private Dictionary testToolStrings; // Used to build string-per-thread as logger Write calls made.
- static private object lockWriteLine = new object(); // Used for locking during a DoWriteLine to ensure thread safety
- static private object lockWrite = new object(); // Used for locking during a DoWrite to ensure thread safety
-
- ///
- /// Instantiates an instant of the Logger static class. Starts the Stopwatch running for timing information in debug data.
- ///
- static Logger()
- {
- errorWrittenToEventLog = false;
- testToolStrings = new Dictionary();
- LoggingLevel = LogLevels.TestInformation; // Default logging level
- ResetTimer();
- }
-
- ///
- /// Levels of logging - Verbose (Maximum) to Exception (Minimum). If level of text being written to
- /// logging is equal to, or higher than the current LoggingLevel the text is written.
- /// This is used to filter logging so that only entries to log are made if the level of the write is equal
- /// or greater than the logging level set by LoggingLevel.
- ///
- public enum LogLevels
- {
- ///
- /// Data written to log if LoggingLevel is FrameworkDebug and Write is FrameworkDebug or higher
- ///
- FrameworkDebug = 0,
- ///
- /// Data written to log if LoggingLevel is FrameworkInformation and Write is FrameworkInformation or higher
- ///
- FrameworkInformation = 1,
- ///
- /// Data written to log if LoggingLevel is TestDebug and Write is TestDebug or higher
- ///
- TestDebug = 2,
- ///
- /// Data written to log if LoggingLevel is TestInformation and Write is TestInformation or Error
- ///
- TestInformation = 3,
- ///
- /// Data always written to results
- ///
- Error = 4
- };
-
-
- ///
- /// Logging level. Lowest is Error (least amount of log data written - only writes at
- /// level Error are written to the log). Most data is written to
- /// the log if level set is FrameworkDebug.
- ///
- static public LogLevels LoggingLevel { get; set; } = LogLevels.FrameworkDebug;
-
- ///
- /// Defines where log lines are written to.
- /// If true (or has not been defined), debug data is written to the Console (stdout)
- /// If false, debug data logging is written to the delegate (if wired up)
- ///
- ///
- /// The default is for log data to be written to the console
- ///
- static public bool WriteToConsole { get; set; }
-
- ///
- /// System delegate to write debug data to if WriteToConsole is false.
- ///
- ///
- static public Action TestToolLog { get; set; }
-
-
- ///
- /// Resets the logger elapsed timer to zero
- ///
- static public void ResetTimer()
- {
- testTimer = new Stopwatch();
- testTimer.Start();
- }
-
- ///
- /// Writes details of a caught exception to the active debug log at level Error
- ///
- ///
- /// If current error logging level is FrameworkDebug the full
- /// exception is written, including stacktrace etc.
- /// With any other Log Level only the exception message is writteIf an exception is thrown during write, Logger
- /// attempts to write the error details if able.
- ///
- /// Exception being logged
- ///
- ///
- /// catch (InvalidHostURI ex)
- /// {
- /// // Log exception and abort the test - we cant talk to the remote Selenium server
- /// Logger.LogException(ex);
- /// toolWrapper.AbortTest("Cannot connect to remote Selenium host");
- /// }
- ///
- ///
- static public void LogException(Exception ex)
- {
- StackFrame stackFrame = new StackFrame(1, true);
- if (LoggingLevel == LogLevels.FrameworkDebug)
- {
- DoWriteLine((stackFrame == null) ? null : stackFrame.GetMethod(), LogLevels.Error,
- string.Format("Exception thrown: {0}", ex.ToString()));
- }
- else
- {
- DoWriteLine((stackFrame == null) ? null : stackFrame.GetMethod(), LogLevels.Error,
- string.Format("Exception thrown: {0}", ex.Message));
- }
- }
- ///
- /// Writes details of a caught exception to the active debug log at level Error
- ///
- ///
- /// If current error logging level is FrameworkDebug the full
- /// exception is written, including stacktrace etc.
- /// With any other Log Level only the exception message is writteIf an exception is thrown during write, Logger
- /// attempts to write the error details if able.
- ///
- /// Exception being logged
- /// Additional string format text to show when logging exception
- /// Arguments shown in string format text
- ///
- ///
- /// catch (InvalidHostURI ex)
- /// {
- /// // Log exception and abort the test - we cant talk to the remote Selenium server
- /// Logger.LogException(ex,"Given up trying to connect to [{0}]",Wherever);
- /// toolWrapper.AbortTest("Cannot connect to remote Selenium host");
- /// }
- ///
- ///
- static public void LogException(Exception ex, string text, params Object[] args)
- {
- StackFrame stackFrame = new StackFrame(1, true);
- DoWrite((stackFrame == null) ? null : stackFrame.GetMethod(), LogLevels.Error, string.Format(text, args));
- if (LoggingLevel == LogLevels.FrameworkDebug)
- {
- DoWriteLine((stackFrame == null) ? null : stackFrame.GetMethod(), LogLevels.Error,
- string.Format("Exception thrown: {0}", ex.ToString()));
- }
- else
- {
- DoWriteLine((stackFrame == null) ? null : stackFrame.GetMethod(), LogLevels.Error,
- string.Format("Exception thrown: {0}", ex.Message));
- }
- }
-
- ///
- /// Writes a line of data to the active debug log with no line termination
- ///
- ///
- ///
- ///
- /// Text to be written
- /// String formatting arguments (if any)
- /// Level of text being written (See for usage of the Log Level)
- /// Write a line of data from our test:
- ///
- /// Logger.WriteLn(LogLevels.TestDebug, "Select member using key (Member: {0})","90986754332");
- /// code>
- static public void Write(LogLevels logLevel, string textString, params Object[] args)
- {
- StackFrame stackFrame = new StackFrame(1, true);
- DoWrite(stackFrame?.GetMethod(), logLevel, string.Format(textString, args));
- }
-
- ///
- /// Writes a line of data to the active debug log.
- /// Data can be formatted in the standard string.format syntax. If an exception is thrown during write, Logger
- /// attempts to write the error deatils if able.
- ///
- /// Level of text being written (See for usage of the Log Level)
- /// Text to be written
- /// String formatting arguments (if any)
- /// Write a line of data from our test:
- ///
- /// Logger.WriteLine(LogLevels.TestDebug, "Select member using key (Member: {0})","90986754332");
- ///
- static public void WriteLine(LogLevels logLevel, string textString, params Object[] args)
- {
- StackFrame stackFrame = new StackFrame(1, true);
- DoWriteLine(stackFrame?.GetMethod(), logLevel, string.Format(textString, args));
- }
-
- ///
- /// Writes given Text to a text file, optionally auto versioning (adding (n) to filename) OR
- /// overwriting.
- ///
- ///
- /// No exception is raised if there is any problem, but details of error is written to Logger log
- ///
- /// Full path and filename to use
- /// If true and file exists. (n) is added to auto-version. If false and file exists, it is overwritten if able
- /// Text to write
- static public void WriteTextToFile(string Filename, bool AutoVersion, string Text)
- {
- try
- {
- string FilenameToUse = Filename;
- if (AutoVersion)
- {
- int count = 1;
- string fileNameOnly = Path.GetFileNameWithoutExtension(Filename);
- string extension = Path.GetExtension(Filename);
- string path = Path.GetDirectoryName(Filename);
- FilenameToUse = Filename;
-
- while (File.Exists(FilenameToUse))
- {
- string tempFileName = string.Format("{0}({1})", fileNameOnly, count++);
- FilenameToUse = Path.Combine(path, tempFileName + extension);
- }
- }
-
- File.WriteAllText(FilenameToUse, Text);
- }
- catch (Exception ex)
- {
- LogException(ex, $"Cannot write data to file [{Filename ?? "Null Filename!"}] (AutoVersion={(AutoVersion ? "Yes" : "No")})");
- }
- }
-
- ///
- /// Gets class-type and Method name of passed MethodBase class.
- ///
- /// MethodBase of class
- /// Formatted string containing Type.Method
- static private string CallingMethodDetails(MethodBase methodBase)
- {
- string methodName = "";
- string typeName = "";
- if (methodBase != null)
- {
- methodName = methodBase.Name ?? methodName;
- if (methodBase.DeclaringType != null)
- {
- typeName = methodBase.DeclaringType.Name ?? typeName;
- }
- }
- return string.Format("{0}.{1}", typeName, methodName);
- }
-
-
- ///
- /// Appends text to currently active line. If the start of line, text is pre-pended with Line header information
- ///
- /// MethodBase of class calling Logger class
- /// Level of debug text to be written
- /// Text string to be written
- /// Text is written if TypeOfWrite is equal to, or higher the current Logging Level
- static private void DoWrite(MethodBase methodBase, LogLevels TypeOfWrite, string textString)
- {
- // Only do write if level of this write is equal to or greater than the current logging level
- if (TypeOfWrite >= LoggingLevel)
- {
- // Ensure thread safety by locking code around the write
- lock (lockWrite)
- {
- //
- // Get the id of the current thread and append text to end of the dictionary item for that
- // thread (create new item if doesnt already exist). If this is
- // first time this thread is doing a write, prepend the PreAmble text first.
- //
- int threadID = Thread.CurrentThread.ManagedThreadId;
- bool writeStart = !testToolStrings.ContainsKey(threadID);
- if (writeStart) testToolStrings[threadID] = GetPreAmble(methodBase, TypeOfWrite);
- testToolStrings[threadID] += textString ?? string.Empty;
- }
- }
- }
-
- ///
- /// Appends text to currently active line and writes line to active log. If new line, text is pre-pended with Line header information
- ///
- /// MethodBase of class calling Logger class
- /// Level of debug text to be written
- /// Text string to be written
- /// Text is written if TypeOfWrite is equal to, or higher the current Logging Level
- static private void DoWriteLine(MethodBase methodBase, LogLevels TypeOfWrite, string textString)
- {
- if (TypeOfWrite >= LoggingLevel)
- {
- var textToWrite = textString;
- lock (lockWriteLine)
- {
- int threadID = Thread.CurrentThread.ManagedThreadId;
- if (testToolStrings.ContainsKey(threadID))
- {
- try
- {
- textToWrite = testToolStrings[threadID] += testToolStrings[threadID].EndsWith(" ") ? "" : " " + textToWrite;
- }
- finally
- {
- testToolStrings.Remove(threadID);
- }
- }
- else
- {
- textToWrite = GetPreAmble(methodBase, TypeOfWrite) + textString ?? string.Empty;
- }
-
- try
- {
- if (WriteToConsole || TestToolLog == null)
- Console.WriteLine(textToWrite);
- else
- TestToolLog(textToWrite);
- }
- catch (Exception ex)
- {
- string details;
- if (!errorWrittenToEventLog)
- {
- using (EventLog appLog = new EventLog("Application"))
- {
- if (WriteToConsole)
- {
- details = "console (STDOUT)";
- }
- else
- {
- details = string.Format("delegate provide by tool{0}.", (TestToolLog == null) ?
- " (Is null! - Has not been implemented!)" :
- "");
- }
- appLog.Source = "Application";
- appLog.WriteEntry(string.Format("AppServiceInterfaceMock - Logger error writing to {0}.\r\n\r\n" +
- "Attempt to write line;\r\n" +
- "{1}\r\n\r\n" +
- "No further log writes to event log will happen in this session", details, textToWrite, ex), EventLogEntryType.Warning, 12791, 1);
- }
- errorWrittenToEventLog = true;
- }
- }
- }
- }
- }
-
- ///
- /// Constructs and returns a log-file pre-amble. Preamble is {Log Type} {Time} [Calling Type.Method]:
- ///
- /// Reference to calling method
- /// Type of write
- /// Line pre-amble text
- static private string GetPreAmble(MethodBase methodBase, LogLevels TypeOfWrite)
- {
- string time = String.Format("[{0:HH:mm:ss.ff}][{1:00000.00}]", DateTime.Now, testTimer.Elapsed.TotalSeconds);
- int totalTimeLength = time.Length + (8 - (int)TypeOfWrite);
- if ((time.Length + 1) <= totalTimeLength) time = time.PadRight(totalTimeLength);
- string preAmble = String.Format("{0} {1} [{2}]: ", WriteTypeString(TypeOfWrite),
- time,
- CallingMethodDetails(methodBase));
- return preAmble;
- }
-
- ///
- /// Returns debug line inital token based on LogLevel of text being written
- ///
- /// Log Level to obtain text for
- /// Textual representation for Debug log line pre-amble
- static private string WriteTypeString(LogLevels TypeOfWrite)
- {
- switch (TypeOfWrite)
- {
- case LogLevels.Error:
- return "LOG-E";
- case LogLevels.FrameworkDebug:
- return "LOG-F";
- case LogLevels.FrameworkInformation:
- return "LOG-R";
- case LogLevels.TestDebug:
- return "LOG-D";
- case LogLevels.TestInformation:
- return "LOG-I";
- default:
- return "LOG-?";
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
deleted file mode 100644
index fee6b96..0000000
--- a/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System.Resources;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Team Controlium Utilities")]
-[assembly: AssemblyDescription("General test automation utilities primarily for use within the Team Controlium suite and associated frameworks")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Team Controlium contributors")]
-[assembly: AssemblyProduct("Utilities.net")]
-[assembly: AssemblyCopyright("Copyright 2018 - Mat Walker and the Team Controlium contributors")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("f8af7786-9221-4b50-a12c-f8a5779671d4")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0")]
-[assembly: AssemblyFileVersion("1.0.0")]
-[assembly: NeutralResourcesLanguage("en-AU")]
-
diff --git a/Settings.StyleCop b/Settings.StyleCop
new file mode 100644
index 0000000..593c2e8
--- /dev/null
+++ b/Settings.StyleCop
@@ -0,0 +1,11 @@
+
+
+
+ Specflow
+ stdout
+ WriteToConsole
+ Detokenizer
+
+ NoMerge
+
+
\ No newline at end of file
diff --git a/TestArguments.cs b/TestArguments.cs
deleted file mode 100644
index 43f1914..0000000
--- a/TestArguments.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-using System.Collections.Specialized;
-using System.Text.RegularExpressions;
-
-namespace TeamControlium.Utilities
-{
- ///
- /// Processes test command-line arguments and presents them to the test script as a string array
- ///
- ///
- /// Thanks to Mike Burns (https://www.linkedin.com/in/maddogmikeb) for original
- ///
- public class TestArguments
- {
- // Variables
- private StringDictionary processedParameters;
-
- ///
- /// Process the test arguments and make available for the test to use.
- ///
- ///
- /// Arguments are space delimited and handle various common parameter preambles
- /// EG. Test.exe -param1 value1 --param2 /param3:"Test-:-work /param4=happy -param5 '--=nice=--'
- ///
- /// String array of arguments for the test to use.
- public TestArguments(string[] argumentsToProcess)
- {
- processedParameters = new StringDictionary();
- Regex Spliter = new Regex(@"^-{1,2}|^/|=|:", RegexOptions.IgnoreCase | RegexOptions.Compiled);
- Regex Remover = new Regex(@"^['""]?(.*?)['""]?$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
-
- string currentParameterBeingBuilt = null;
- string[] argumentParts;
-
- // Valid parameters forms:
- // {-,/,--}param{ ,=,:}((",')value(",'))
- // Examples:
- // -param1 value1 --param2 /param3:"Test-:-work"
- // /param4=happy -param5 '--=nice=--'
- foreach (string currentArgument in argumentsToProcess)
- {
- // Look for new parameters (-,/ or --) and a
- // possible enclosed value (=,:)
- argumentParts = Spliter.Split(currentArgument, 3);
-
- switch (argumentParts.Length)
- {
- // Found a value (for the last parameter
- // found (space separator))
- case 1:
- if (currentParameterBeingBuilt != null)
- {
- if (!processedParameters.ContainsKey(currentParameterBeingBuilt))
- {
- argumentParts[0] =
- Remover.Replace(argumentParts[0], "$1");
-
- processedParameters.Add(currentParameterBeingBuilt, argumentParts[0]);
- }
- currentParameterBeingBuilt = null;
- }
- // else Error: no parameter waiting for a value (skipped)
- break;
-
- // Found just a parameter
- case 2:
- // The last parameter is still waiting.
- // With no value, set it to true.
- if (currentParameterBeingBuilt != null)
- {
- if (!processedParameters.ContainsKey(currentParameterBeingBuilt))
- processedParameters.Add(currentParameterBeingBuilt, "true");
- }
- currentParameterBeingBuilt = argumentParts[1];
- break;
-
- // Parameter with enclosed value
- case 3:
- // The last parameter is still waiting.
- // With no value, set it to true.
- if (currentParameterBeingBuilt != null)
- {
- if (!processedParameters.ContainsKey(currentParameterBeingBuilt))
- processedParameters.Add(currentParameterBeingBuilt, "true");
- }
-
- currentParameterBeingBuilt = argumentParts[1];
-
- // Remove possible enclosing characters (",')
- if (!processedParameters.ContainsKey(currentParameterBeingBuilt))
- {
- argumentParts[2] = Remover.Replace(argumentParts[2], "$1");
- processedParameters.Add(currentParameterBeingBuilt, argumentParts[2]);
- }
-
- currentParameterBeingBuilt = null;
- break;
- }
- }
- // In case a parameter is still waiting
- if (currentParameterBeingBuilt != null)
- {
- if (!processedParameters.ContainsKey(currentParameterBeingBuilt))
- processedParameters.Add(currentParameterBeingBuilt, "true");
- }
- }
-
- ///
- /// Return a named parameter value if it exists
- ///
- /// Parameter to obtain
- /// Value of named parameter. If named parameter does not exist null is returned
- public string this[string Param]
- {
- get
- {
- try
- {
- return (processedParameters[Param]);
- }
- catch
- {
- return null;
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/TestData.cs b/TestData.cs
deleted file mode 100644
index 8d8ae46..0000000
--- a/TestData.cs
+++ /dev/null
@@ -1,273 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace TeamControlium.Utilities
-{
- public class TestData
- {
- private static Dictionary> testData = new Dictionary>();
-
- ///
- /// Repository for all Data used within current test
- ///
- ///
- /// Data persists throughout the lifetime of application instantiating Utilities class
- ///
- ///
- ///
- /// //
- /// // Store the string MyString as item named MyName in the TestData
- /// // repository category MyCategory
- /// //
- /// Utilities.TestData.Repository["MyCategory","MyName"] = "MyString";
- ///
- /// //
- /// // Obtain the item MyName from TestData category MyCategory
- /// //
- /// string myString = Utilities.TestData.Repository["MyCategory","MyName"];
- ///
- ///
- public static TestDataRepository Repository { get; } = new TestDataRepository();
-
- ///
- /// Underlying TestData repository
- ///
- ///
- public sealed class TestDataRepository // : Dictionary>
- {
- ///
- /// Returns the last exception were a TryGetRunCategoryOptions returned false
- ///
- public Exception TryException { get; private set; }
-
- ///
- /// Clears the Test Data repository of all test data
- ///
- public void Clear()
- {
- Logger.WriteLine(Logger.LogLevels.FrameworkDebug, "Clearing Test Data repository");
- testData.Clear();
- }
-
- public bool HasCategory(string key)
- {
- return testData.ContainsKey(key);
- }
-
- ///
- /// Sets or Gets test data item [name] in category [category]
- ///
- ///
- /// If name and/or category does not exist when setting, item is created. If item already exists it is updated with new value
- /// Names of items can be duplicated if in seperate categories but must be unique in a single category
- /// It is the responsibility of the calling software to ensure correct type-casting on a Get
- ///
- /// Category for test data item
- /// Name of item within Category
- /// Item named from defined category
- /// Thrown if category and/or name are null/empty when getting
- /// Thrown if category does not exist or item named does not exist in defined category when getting
- public dynamic this[string category, string name]
- {
- get
- {
- // Ensure name is valid - not null or empty and named category contains it
- if (string.IsNullOrEmpty(name))
- throw new ArgumentException(string.Format("Cannot be null or empty ({0})", name == null ? "Is Null" : "Is empty"), "name");
- if (!this[category].ContainsKey(name))
- throw new ArgumentOutOfRangeException("name", name, string.Format("Category [{0}] does not have item named", category));
-
- // Get item named from category and return it
- dynamic obtainedObject = (this[category])[name];
-
- Logger.Write(Logger.LogLevels.FrameworkDebug, "Got ");
- if (obtainedObject is string)
- {
- Logger.Write(Logger.LogLevels.FrameworkDebug, "string [{0}]", ((string)obtainedObject)?.Length < 50 ? (string)obtainedObject : (((string)obtainedObject).Substring(0, 47) + "...") ?? "");
- }
- else if (obtainedObject is int)
- {
- Logger.Write(Logger.LogLevels.FrameworkDebug, "integer [{0}]", ((int)obtainedObject));
- }
- else if (obtainedObject is float)
- {
- Logger.Write(Logger.LogLevels.FrameworkDebug, "integer [{0}]", ((float)obtainedObject));
- }
- else
- {
- Logger.Write(Logger.LogLevels.FrameworkDebug, "type {0}{1}", obtainedObject.ToString(), (obtainedObject == null) ? " (is null!)" : "");
- }
- Logger.WriteLine(Logger.LogLevels.FrameworkDebug, " from [{0}][{1}]", category, name);
- return obtainedObject;
- }
- set
- {
- Logger.Write(Logger.LogLevels.FrameworkDebug, "Setting [{0}][{1}] to ", category, name);
- if (value is string)
- {
- Logger.Write(Logger.LogLevels.FrameworkDebug, "string [{0}]", ((string)value)?.Length < 50 ? (string)value : (((string)value).Substring(0, 47) + "...") ?? "");
- }
- else if (value is int)
- {
- Logger.Write(Logger.LogLevels.FrameworkDebug, "integer [{0}]", ((int)value));
- }
- else if (value is float)
- {
- Logger.Write(Logger.LogLevels.FrameworkDebug, "integer [{0}]", ((float)value));
- }
- else
- {
- Logger.Write(Logger.LogLevels.FrameworkDebug, "type {0}{1}", value.ToString(), (value == null) ? " (is null!)" : "");
- }
- // Add Category if we dont already have it
- if (!testData.ContainsKey(category))
- testData.Add(category, new Dictionary());
-
- Dictionary wholeCategory = testData[category];
- // Add Name if we dont already have it in the current category, otherwise change contents of name
- if (wholeCategory.ContainsKey(name))
- wholeCategory[name] = value;
- else
- wholeCategory.Add(name, value);
- }
- }
-
- ///
- /// Gets all items in category
- ///
- /// Category to return
- /// Dictionary of all items in named category
- /// Thrown if category argument is null/empty
- /// Thrown if category does not exist
- public new Dictionary this[string category]
- {
- get
- {
- if (string.IsNullOrEmpty(category))
- throw new ArgumentException(string.Format("Cannot be null or empty ({0})", category == null ? "Is Null" : "Is empty"), "Category");
- if (!testData.ContainsKey(category))
- throw new ArgumentOutOfRangeException("category", category, "Category does not exist");
-
- var wholeCategory = testData[category];
- Logger.WriteLine(Logger.LogLevels.FrameworkDebug, "Got category [{0}] ({1} items)", category, wholeCategory.Count);
- return wholeCategory;
- }
- set
- {
- if (string.IsNullOrEmpty(category))
- throw new ArgumentException(string.Format("Cannot be null or empty ({0})", category == null ? "Is Null" : "Is empty"), "Category");
- // Add Category if we dont already have it
- if (!testData.ContainsKey(category))
- testData.Add(category, new Dictionary());
-
- Logger.WriteLine(Logger.LogLevels.FrameworkDebug, "Setting category [{0}] ({1} items)", category, value.Count);
- testData[category] = value;
- }
- }
-
- /// Returns named item from named category
- /// Category to obtain option from
- /// Name of option to get
- /// Expected return Type of object being obtained
- /// Object of Category and Name
- public U GetItem(string category, string name)
- {
- dynamic obtainedObject;
-
- try
- {
- obtainedObject = this[category, name];
-
- if (obtainedObject is U)
- {
- return (U)obtainedObject;
- }
- else if (obtainedObject != null && (typeof(U) == typeof(int) && obtainedObject.GetType().Equals(typeof(string))))
- {
- // We want and int and we got a string. So, try converting it to be helpful....
- try
- {
- return (U)int.Parse(obtainedObject);
- }
- catch { }
- }
- else if (obtainedObject != null && (typeof(U) == typeof(float) && obtainedObject.GetType().Equals(typeof(string))))
- {
- // We want and float and we got a string. So, try converting it to be helpful....
- try
- {
- return (U)float.Parse(obtainedObject);
- }
- catch { }
- }
- }
- catch (Exception ex)
- {
- throw new Exception(string.Format("Exception getting Category.Name ([{0}].[{1}])", category, name), ex);
- }
-
- throw new Exception(string.Format("Expected type [{0}] but got type [{1}].", typeof(U).Name, obtainedObject.GetType()));
- }
-
- /// Returns named option from named category
- /// Category to obtain option from
- /// Name of option to get
- /// Object of Category and Name if successful
- /// Expected return Type of object being obtained
- /// true if object obtained successfullt otherwise false (use TryExeception to exception thrown)
- public bool TryGetItem(string category, string name, out U value)
- {
- try
- {
- value = GetItem(category, name);
- return true;
- }
- catch (Exception ex)
- {
- TryException = new Exception(string.Format("Exception getting Category.Name ([{0}].[{1}])", category, name), ex);
- value = default(U);
- return false;
- }
- }
-
- /// Returns named option from named category. Returns null if object not set
- /// Category to obtain option from
- /// Name of option to get
- /// Expected return Type of object being obtained
- /// Object of Category and Name. If object does not exist returns default value (Null if a reference type)
- public U GetItemOrDefault(string category, string name)
- {
- dynamic obtainedObject;
- try
- {
- obtainedObject = this[category, name];
- }
- catch
- {
- Logger.WriteLine(Logger.LogLevels.FrameworkInformation, "No data found for [{0}.{1}] - returning [Type ({2})] default value.", category, name, typeof(U).Name);
- obtainedObject = default(U);
- }
-
- if (obtainedObject is U)
- return (U)obtainedObject;
- else
- throw new InvalidCastException(string.Format("Expected type [{0}] but got type [{1}].", typeof(U).Name, obtainedObject.GetType().Name));
- }
-
- /// Returns all options defined in passed Category
- /// Category to get options for
- /// Dictionary of KeyValue pairs where Keys are the option names and Values are the option data
- public Dictionary GetCategoryItems(string Category)
- {
- try
- {
- return testData[Category];
- }
- catch (Exception ex)
- {
- throw new Exception(string.Format("Exception getting itms in Category ([{0}])", Category), ex);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/UnitTests/Detokenizer/Detokenizer.feature.cs b/UnitTests/Detokenizer/Detokenizer.feature.cs
deleted file mode 100644
index f7f70f6..0000000
--- a/UnitTests/Detokenizer/Detokenizer.feature.cs
+++ /dev/null
@@ -1,519 +0,0 @@
-// ------------------------------------------------------------------------------
-//
-// This code was generated by SpecFlow (http://www.specflow.org/).
-// SpecFlow Version:2.2.0.0
-// SpecFlow Generator Version:2.2.0.0
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// ------------------------------------------------------------------------------
-#region Designer generated code
-#pragma warning disable
-namespace TeamControlium.Utilities.UnitTests.Detokenizer
-{
- using TechTalk.SpecFlow;
-
-
- [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.2.0.0")]
- [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute()]
- public partial class DetokenizerFeature
- {
-
- private static TechTalk.SpecFlow.ITestRunner testRunner;
-
- private Microsoft.VisualStudio.TestTools.UnitTesting.TestContext _testContext;
-
-#line 1 "Detokenizer.feature"
-#line hidden
-
- public virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext
- {
- get
- {
- return this._testContext;
- }
- set
- {
- this._testContext = value;
- }
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.ClassInitializeAttribute()]
- public static void FeatureSetup(Microsoft.VisualStudio.TestTools.UnitTesting.TestContext testContext)
- {
- testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(null, 0);
- TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Detokenizer", "\tIn order to process tokens\r\n\tAs a test automator\r\n\tI want to be able to convert " +
- "tokens to real texts", ProgrammingLanguage.CSharp, new string[] {
- "Detokenizer"});
- testRunner.OnFeatureStart(featureInfo);
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.ClassCleanupAttribute()]
- public static void FeatureTearDown()
- {
- testRunner.OnFeatureEnd();
- testRunner = null;
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestInitializeAttribute()]
- public virtual void TestInitialize()
- {
- if (((testRunner.FeatureContext != null)
- && (testRunner.FeatureContext.FeatureInfo.Title != "Detokenizer")))
- {
- global::TeamControlium.Utilities.UnitTests.Detokenizer.DetokenizerFeature.FeatureSetup(null);
- }
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCleanupAttribute()]
- public virtual void ScenarioTearDown()
- {
- testRunner.OnScenarioEnd();
- }
-
- public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)
- {
- testRunner.OnScenarioStart(scenarioInfo);
- testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(TestContext);
- }
-
- public virtual void ScenarioCleanup()
- {
- testRunner.CollectScenarioErrors();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Convert today\'s date token to the date we run this test")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ConvertTodaysDateTokenToTheDateWeRunThisTest()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Convert today\'s date token to the date we run this test", ((string[])(null)));
-#line 17
- this.ScenarioSetup(scenarioInfo);
-#line 18
- testRunner.Given("I have a string \"{date;today;dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 19
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 20
- testRunner.Then("the string is today\'s date in the format \"dd/MM/yyyy\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Convert yesterday\'s date token to the day before we run this test")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ConvertYesterdaysDateTokenToTheDayBeforeWeRunThisTest()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Convert yesterday\'s date token to the day before we run this test", ((string[])(null)));
-#line 22
- this.ScenarioSetup(scenarioInfo);
-#line 23
- testRunner.Given("I have a string \"{date;yesterday;dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 24
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 25
- testRunner.Then("the string is yesterday\'s date in the format \"dd/MM/yyyy\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Convert tomorrows\'s date token to the day after we run this test")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ConvertTomorrowssDateTokenToTheDayAfterWeRunThisTest()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Convert tomorrows\'s date token to the day after we run this test", ((string[])(null)));
-#line 27
- this.ScenarioSetup(scenarioInfo);
-#line 28
- testRunner.Given("I have a string \"{date;tomorrow;dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 29
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 30
- testRunner.Then("the string is tomorrows\'s date in the format \"dd/MM/yyyy\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Date command and verb not case sensitive")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void DateCommandAndVerbNotCaseSensitive()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Date command and verb not case sensitive", ((string[])(null)));
-#line 32
- this.ScenarioSetup(scenarioInfo);
-#line 33
- testRunner.Given("I have a string \"{Date;Today;dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 34
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 35
- testRunner.Then("the string is today\'s date in the format \"dd/MM/yyyy\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Get the day of the week when test is run")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void GetTheDayOfTheWeekWhenTestIsRun()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Get the day of the week when test is run", ((string[])(null)));
-#line 41
- this.ScenarioSetup(scenarioInfo);
-#line 42
- testRunner.Given("I have a string \"{date;today;dddd}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 43
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 44
- testRunner.Then("the string is today\'s date in the format \"dddd\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Convert date for a days offset in the past")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ConvertDateForADaysOffsetInThePast()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Convert date for a days offset in the past", ((string[])(null)));
-#line 49
- this.ScenarioSetup(scenarioInfo);
-#line 50
- testRunner.Given("I have a string \"{date;AddDays(-10);dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 51
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 52
- testRunner.Then("the string is the date -10 \"days\" in the format \"dd/MM/yyyy\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Convert date for a days offset in the future")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ConvertDateForADaysOffsetInTheFuture()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Convert date for a days offset in the future", ((string[])(null)));
-#line 54
- this.ScenarioSetup(scenarioInfo);
-#line 55
- testRunner.Given("I have a string \"{date;AddDays(10);dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 56
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 57
- testRunner.Then("the string is the date 10 \"days\" in the format \"dd/MM/yyyy\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Convert date for a days offset in the future (with a plus sign)")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ConvertDateForADaysOffsetInTheFutureWithAPlusSign()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Convert date for a days offset in the future (with a plus sign)", ((string[])(null)));
-#line 59
- this.ScenarioSetup(scenarioInfo);
-#line 60
- testRunner.Given("I have a string \"{date;AddDays(+10);dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 61
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 62
- testRunner.Then("the string is the date 10 \"days\" in the format \"dd/MM/yyyy\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Convert date for a months offset in the past")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ConvertDateForAMonthsOffsetInThePast()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Convert date for a months offset in the past", ((string[])(null)));
-#line 64
- this.ScenarioSetup(scenarioInfo);
-#line 65
- testRunner.Given("I have a string \"{date;AddMonths(-19);dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 66
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 67
- testRunner.Then("the string is the date -19 \"months\" in the format \"dd/MM/yyyy\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Convert date for a months offset in the future")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ConvertDateForAMonthsOffsetInTheFuture()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Convert date for a months offset in the future", ((string[])(null)));
-#line 69
- this.ScenarioSetup(scenarioInfo);
-#line 70
- testRunner.Given("I have a string \"{date;AddMonths(17);dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 71
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 72
- testRunner.Then("the string is the date 17 \"months\" in the format \"dd/MM/yyyy\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Convert date for a years offset in the past")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ConvertDateForAYearsOffsetInThePast()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Convert date for a years offset in the past", ((string[])(null)));
-#line 74
- this.ScenarioSetup(scenarioInfo);
-#line 75
- testRunner.Given("I have a string \"{date;AddYears(-25);dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 76
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 77
- testRunner.Then("the string is the date -25 \"years\" in the format \"dd/MM/yyyy\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Convert date for a years offset in the future")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ConvertDateForAYearsOffsetInTheFuture()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Convert date for a years offset in the future", ((string[])(null)));
-#line 79
- this.ScenarioSetup(scenarioInfo);
-#line 80
- testRunner.Given("I have a string \"{date;AddYears(25);dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 81
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 82
- testRunner.Then("the string is the date 25 \"years\" in the format \"dd/MM/yyyy\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("I can get a random date from a single date")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ICanGetARandomDateFromASingleDate()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can get a random date from a single date", ((string[])(null)));
-#line 94
- this.ScenarioSetup(scenarioInfo);
-#line 95
- testRunner.Given("I have a string \"{random;date(12-07-2001,12-07-2001);dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 96
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 97
- testRunner.Then("the string is a date between \"12/07/2001\" and \"12/07/2001\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("I can get a random date from one of two consequtive dates")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ICanGetARandomDateFromOneOfTwoConsequtiveDates()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can get a random date from one of two consequtive dates", ((string[])(null)));
-#line 99
- this.ScenarioSetup(scenarioInfo);
-#line 100
- testRunner.Given("I have a string \"{random;date(11-07-2001,12-07-2001);dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 101
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 102
- testRunner.Then("the string is a date between \"11/07/2001\" and \"12/07/2001\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("I get correct error if min date after max date")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void IGetCorrectErrorIfMinDateAfterMaxDate()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I get correct error if min date after max date", ((string[])(null)));
-#line 104
- this.ScenarioSetup(scenarioInfo);
-#line 105
- testRunner.Given("I have a string \"{random;date(12-07-2001,11-07-2001);dd/MM/yyyy}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 106
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 107
- testRunner.Then("the string is \"Error processing token {random;date(12-07-2001,11-07-2001);dd/MM/y" +
- "yyy} (Maximum date earlier than Maximum date! Expect {random;date(dd-MM-yyyy,dd-" +
- "MM-yyyy);} Mindate = 12/07/2001, Maxdate = 11/07/2001)\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("I can get a random positive floating point number with no decimal places")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ICanGetARandomPositiveFloatingPointNumberWithNoDecimalPlaces()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can get a random positive floating point number with no decimal places", ((string[])(null)));
-#line 112
- this.ScenarioSetup(scenarioInfo);
-#line 113
- testRunner.Given("I have a string \"{random;float(0,1);0}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 114
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 115
- testRunner.Then("the string matches regular expression \"^[0-9]{1}$\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line 116
- testRunner.And("the string is a number between 0 and 1", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("I can get a random positive floating point number with 1 decimal places")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ICanGetARandomPositiveFloatingPointNumberWith1DecimalPlaces()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can get a random positive floating point number with 1 decimal places", ((string[])(null)));
-#line 118
- this.ScenarioSetup(scenarioInfo);
-#line 119
- testRunner.Given("I have a string \"{random;float(0,1);0.0}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 120
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 121
- testRunner.Then("the string matches regular expression \"^[0-1]{1}\\.[0-9]{1}$\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line 122
- testRunner.And("the string is a number between 0 and 1", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("I can get a random negative floating point number with 1 decimal places")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ICanGetARandomNegativeFloatingPointNumberWith1DecimalPlaces()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can get a random negative floating point number with 1 decimal places", ((string[])(null)));
-#line 124
- this.ScenarioSetup(scenarioInfo);
-#line 125
- testRunner.Given("I have a string \"{random;float(-1,0);0.0}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 126
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 127
- testRunner.Then("the string matches regular expression \"^-[0-9]{1}\\.[0-9]{1}$\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line 128
- testRunner.And("the string is a number between -1 and 0", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("I can get a random positive floating point number between tiny numbers")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ICanGetARandomPositiveFloatingPointNumberBetweenTinyNumbers()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can get a random positive floating point number between tiny numbers", ((string[])(null)));
-#line 130
- this.ScenarioSetup(scenarioInfo);
-#line 131
- testRunner.Given("I have a string \"{random;float(0.0003,0.0004);0.000000}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 132
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 133
- testRunner.Then("the string matches regular expression \"^0{1}\\.0{3}[0-9]{3}$\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line 134
- testRunner.And("the string is a number between 0.0003 and 0.0004", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("I can get a random positive floating point number with leading zeros")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ICanGetARandomPositiveFloatingPointNumberWithLeadingZeros()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can get a random positive floating point number with leading zeros", ((string[])(null)));
-#line 136
- this.ScenarioSetup(scenarioInfo);
-#line 137
- testRunner.Given("I have a string \"{random;float(3,4);000}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 138
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 139
- testRunner.Then("the string matches regular expression \"^0{2}[3-4]{1}$\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line 140
- testRunner.And("the string is a number between 3 and 4", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("I can get a single random character from a given set")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void ICanGetASingleRandomCharacterFromAGivenSet()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can get a single random character from a given set", ((string[])(null)));
-#line 145
- this.ScenarioSetup(scenarioInfo);
-#line 146
- testRunner.Given("I have a string \"{random;from(abc);1}\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 147
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line 148
- testRunner.Then("the string matches regular expression \"^[a-c]{1}$\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
-#line 149
- testRunner.And("the string is 1 characters from \"abc\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
-#line hidden
- this.ScenarioCleanup();
- }
-
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()]
- [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Nested tokens")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "Detokenizer")]
- [Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("Detokenizer")]
- public virtual void NestedTokens()
- {
- TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Nested tokens", ((string[])(null)));
-#line 151
- this.ScenarioSetup(scenarioInfo);
-#line 152
- testRunner.Given("I have a string \"{random;digits;{random;from(2345);1} }\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
-#line 153
- testRunner.When("I process the token to a string", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
-#line hidden
- this.ScenarioCleanup();
- }
- }
-}
-#pragma warning restore
-#endregion
diff --git a/UnitTests/Detokenizer/DetokenizerTestSteps.cs b/UnitTests/Detokenizer/DetokenizerTestSteps.cs
deleted file mode 100644
index 8679355..0000000
--- a/UnitTests/Detokenizer/DetokenizerTestSteps.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
-using System.Globalization;
-using System.Text.RegularExpressions;
-using TechTalk.SpecFlow;
-
-namespace TeamControlium.Utilities
-{
- [Binding]
- public sealed class DetokenizerTestSteps
- {
- [Given(@"I have a string ""(.*)""")]
- public void GivenIHaveAStringWithToken(string stringToBeProcessed)
- {
- ScenarioContext.Current["StringToBeProcessed"] = stringToBeProcessed;
- }
-
- [When(@"I process the token to a string")]
- public void WhenIProcessTheToken()
- {
- string toBeProcessed = (string)ScenarioContext.Current["StringToBeProcessed"];
- string processed;
- try
- {
- processed = Detokenizer.ProcessTokensInString(toBeProcessed);
- }
- catch (Exception ex)
- {
- processed = ex.Message;
- }
- ScenarioContext.Current["ProcessedString"] = processed;
- }
-
- [Then(@"the string is ""(.*)""")]
- public void ThenTheStringIs(string expectedString)
- {
- Assert.AreEqual(expectedString, (string)ScenarioContext.Current["ProcessedString"]);
- }
-
- [Then(@"the string is today's date in the format ""(.*)""")]
- public void ThenTheStringIsTodaySDateInTheFormat(string requiredFormatOfDate)
- {
- string requiredDate = DateTime.Now.ToString(requiredFormatOfDate);
- string actualDate = (string)ScenarioContext.Current["ProcessedString"];
- Assert.AreEqual(requiredDate, actualDate, "Dates and formats match");
- }
-
- [Then(@"the string is yesterday's date in the format ""(.*)""")]
- public void ThenTheStringIsYesterdaySDateInTheFormat(string requiredFormatOfDate)
- {
- string requiredDate = DateTime.Now.AddDays(-1).ToString(requiredFormatOfDate);
- string actualDate = (string)ScenarioContext.Current["ProcessedString"];
- Assert.AreEqual(requiredDate, actualDate, "Dates and formats match");
- }
-
- [Then(@"the string is tomorrows's date in the format ""(.*)""")]
- public void ThenTheStringIsTomorrowsDateInTheFormat(string requiredFormatOfDate)
- {
- string requiredDate = DateTime.Now.AddDays(1).ToString(requiredFormatOfDate);
- string actualDate = (string)ScenarioContext.Current["ProcessedString"];
- Assert.AreEqual(requiredDate, actualDate, "Dates and formats match");
- }
-
- [Then(@"the string is the date (.*) ""(.*)"" in the format ""(.*)""")]
- public void ThenTheStringIsTheDateInTheFormat(int offset, string offsetType, string requiredFormatOfDate)
- {
- DateTime requiredDate;
- switch (offsetType.ToLower().Trim())
- {
- case "days":
- requiredDate = DateTime.Now.AddDays(offset); break;
- case "months":
- requiredDate = DateTime.Now.AddMonths(offset); break;
- case "years":
- requiredDate = DateTime.Now.AddYears(offset); break;
- default:
- throw new ArgumentException("Unknown Offset Type. Expect days, months or years.", "offsetType");
- }
- string actualDate = (string)ScenarioContext.Current["ProcessedString"];
- Assert.AreEqual(requiredDate.ToString(requiredFormatOfDate), actualDate, "Dates and formats match");
- }
-
- [Then(@"the string is a date between ""(.*)"" and ""(.*)""")]
- public void ThenTheStringIsADateBetweenAnd(string minDate, string maxDate)
- {
- var processedString = (string)ScenarioContext.Current["ProcessedString"];
- var actualDate = DateTime.ParseExact(processedString, new string[] { "d/M/yy", "dd/M/yy", "d/MM/yy", "dd/MM/yy", "d/M/yyyy", "dd/M/yyyy", "d/MM/yyyy", "dd/MM/yyyy" }, CultureInfo.InvariantCulture, DateTimeStyles.None);
- var min = DateTime.ParseExact(minDate, "d/M/yyyy", CultureInfo.InvariantCulture);
- var max = DateTime.ParseExact(maxDate, "d/M/yyyy", CultureInfo.InvariantCulture);
-
- if (min > max) throw new Exception($"Minimum date [{minDate}] is later than Maximum date [{maxDate}]!");
- Assert.IsTrue((actualDate >= min) && (actualDate <= max));
- }
-
- [Then(@"the string is a ""(.*)"" number between ""(.*)"" and ""(.*)""")]
- public void ThenTheStringIsANumberBetweenAnd(string format, int minNumber, int maxNumber)
- {
- var processedString = (string)ScenarioContext.Current["ProcessedString"];
-
- }
- [Then(@"the string matches regular expression ""(.*)""")]
- public void ThenTheStringIsAFormattedNumber(string format)
- {
- var processedString = (string)ScenarioContext.Current["ProcessedString"];
- bool result = Regex.IsMatch(processedString, format);
- Assert.IsTrue(result, string.Format("Processed string [{0}] matches regular expression [{1}]", processedString, format));
- }
-
- [Then(@"the string is a number between (.*) and (.*)")]
- public void ThenTheStringIsANumberBetweenAnd(float minNumber, float maxNumber)
- {
- var processedString = (string)ScenarioContext.Current["ProcessedString"];
- float num = float.Parse(processedString);
- Assert.IsTrue((num >= minNumber) && (num <= maxNumber));
- }
-
- [Then(@"the string is (.*) characters from ""(.*)""")]
- public void ThenTheStringIsCharacterFrom(int numberOfCharacters, string possibleCharacters)
- {
- var processedString = (string)ScenarioContext.Current["ProcessedString"];
-
- Assert.AreEqual(numberOfCharacters, processedString.Length);
-
- foreach (char character in processedString)
- {
- // Need to populate this up....
- }
- }
- }
-}
\ No newline at end of file
diff --git a/UnitTests/Logger/Logger.feature b/UnitTests/Logger/Logger.feature
deleted file mode 100644
index b1e0dfc..0000000
--- a/UnitTests/Logger/Logger.feature
+++ /dev/null
@@ -1,64 +0,0 @@
-Feature: Logger
- In order to test log events in the Controlium solution
- As a test automator
- I want to be able to log events
-
-Scenario Outline: Logger only outputs levels equal to higher than the level selected
- Given I have configured Logger WriteToConsole to true
- Given I set Logger to level
- When I call Logger with level and string
- Then the console output contains a Logger line ending with