public virtual void ValidateFieldLengths(IBankMessage result) { foreach (BankMessageField bankMessageField in result.PostParameters.Where(field => field.Value != null)) { if (bankMessageField.Value.Length > bankMessageField.MaxLength) { throw new FieldLengthOutOfRangeException(bankMessageField, result); } } }
public void SetUp() { _validator = new Validator(); _parameters = new List <BankMessageField> { new BankMessageField { FieldName = "NAME", MaxLength = 1, Value = "X" }, new BankMessageField { FieldName = "LANG", MaxLength = 3, Value = "ENG" }, new BankMessageField { FieldName = "SERVICE_CODE", MaxLength = 4, Value = "1011" }, }; _bankMessage = Mock.Of <IBankMessage>(bankMsg => bankMsg.PostParameters == _parameters); }
public FieldLengthOutOfRangeException(BankMessageField invalidField, IBankMessage bankMessage) { InvalidField = invalidField; BankMessage = bankMessage; }