public void GenerateARandomNumberThatIsDifferentToTheOriginalValue() { var originalValue = 999999; var newValue = systemUnderTest.GenerateRandomNumber(originalValue.ToString(), GenerateValidArgs()); newValue.Should().NotBe(originalValue); }
public void ReplaceTheDefaultMinMaxValuesIfThosArgumentsArePassed() { var originalValue = 999999; var newValue = FormattingOptionProcessor.GenerateRandomNumber(originalValue.ToString(CultureInfo.InvariantCulture), GenerateValidArgs()); newValue.Should().NotBe(originalValue); }
public void ThrowArgumentOutOfRangeExceptionIfTheMinValueIsHigherThanTheMax() { var originalValue = 999999; Action action = () => FormattingOptionProcessor.GenerateRandomNumber(originalValue.ToString(CultureInfo.InvariantCulture), GenerateInvalidArgs()); action.Should().Throw <ArgumentOutOfRangeException>(); }
public void GenerateARandomNumberThatIsDifferentToTheOriginalValue() { var originalValue = 867489; var newValue = FormattingOptionProcessor.GenerateRandomNumber(originalValue.ToString(CultureInfo.InvariantCulture), GenerateValidArgs()); newValue.Should().NotBe(originalValue); }
private string Format(string originalValue, FieldToBeObfuscated field, Dictionary <string, object> metadataParameters) { List <string> obfuscatedStrings = new List <string>(); foreach (var arg in field.ObfuscationFormatArgs) { switch (arg.FormatType) { case ObfuscationFormatType.RandomString: obfuscatedStrings.Add(optionProcessor.GenerateRandomString(originalValue, arg)); break; case ObfuscationFormatType.RandomNumber: obfuscatedStrings.Add(optionProcessor.GenerateRandomNumber(originalValue, arg).ToString(CultureInfo.InvariantCulture)); break; case ObfuscationFormatType.Lookup: obfuscatedStrings.Add(optionProcessor.GenerateFromLookup(originalValue, arg)); break; } } string replacementString = string.Format(CultureInfo.InvariantCulture, field.ObfuscationFormat, obfuscatedStrings.ToArray()); if (metadataParameters != null && metadataParameters.ContainsKey("maxlength")) { var maxLength = (int)metadataParameters["maxlength"]; if (replacementString.Length > maxLength) { replacementString = replacementString.Substring(0, maxLength); } } return(replacementString); }