// // Copyright © 2018 Ranorex All rights reserved // using System; using Ranorex.Core.Testing; namespace Ranorex.AutomationHelpers.UserCodeCollections { /// /// A collection of string helper methods. /// [UserCodeCollection] public static class StringLibrary { /// /// Concatenates two strings and returns the new string. /// /// First string /// Second string /// Concatenated string [UserCodeMethod] public static string ConcatStrings(string value1, string value2) { return String.Concat(value1, value2); } /// /// Creates and returns a random string. /// /// Length of the returned string in characters. Default = 35. Lower values increase /// chance of duplicate strings. /// Random string [UserCodeMethod] public static string GetRandomString(string length = "35") { string returnValue = ""; Int32 len = Int32.Parse(length); if (len > 35) { returnValue = GetRandomString((len - 36).ToString()); return returnValue + Guid.NewGuid().ToString(); } else { returnValue = Guid.NewGuid().ToString().Substring(0, len); } return returnValue; } } }