/// <summary> /// Initalizes a <see cref="FixedLengthFieldString"/> object with a definition of a set of fixed-length fields /// and a string. The string will be parsed and values stored in the string will be assigned to the fields. /// </summary> /// <param name="fields">Defintion of fields in the string.</param> /// <param name="s">The string to be parsed in to the fields.</param> public FixedLengthFieldString(FixedLengthFieldCollection fields, string s) { ParameterGuard.NullCheck(s, nameof(s)); ParameterGuard.NullCheck(fields, nameof(fields)); Fields = fields; Parse(s); }
public static void Log(ILogDefinition def, params object[] args) { ILogger logger = _logger; ParameterGuard.NullCheck(logger, nameof(_logger)); logger.Log(def, args); }
public void ParameterGuard_NullCheck_CheckNullValueWithoutGivenMessage_ShouldThrowArgumentNullExceptionWithGivenParamNameAndMessage() { try { ParameterGuard.NullCheck <object>(null, ParameterName); } catch (ArgumentNullException ex) { ValidateExceptionParameterName(ex, ParameterName); // If value of ex.ParamName is expected, rethrow the ArgumentNullException to // make the test pass. throw; } }
public static string Pad(this string s, int length, PaddingCharPosition position, char paddingChar) { ParameterGuard.NullCheck(s, nameof(s)); switch (position) { case PaddingCharPosition.Left: return(s.PadLeft(length, paddingChar)); case PaddingCharPosition.Right: return(s.PadRight(length, paddingChar)); default: throw new NotSupportedException($"The value of {nameof(position)} ({position}) is not supported."); } }
public static string TrimPaddingChar(this string s, PaddingCharPosition position, char paddingChar) { ParameterGuard.NullCheck(s, nameof(s)); switch (position) { case PaddingCharPosition.Left: return(s?.TrimStart(paddingChar)); case PaddingCharPosition.Right: return(s?.TrimEnd(paddingChar)); default: throw new NotSupportedException($"The value of {nameof(position)} ({position}) is not supported."); } }
public void ParameterGuard_NullCheck_CheckNonNullValueWithoutGivenMessage_ShouldNotThrowException() { object nonNullObject = new object(); ParameterGuard.NullCheck(nonNullObject, ParameterName); }