public bool Add(PinCode pinCode) { if (_pinCodeDictionary.ContainsKey(pinCode.ToString())) { return(false); } _pinCodeDictionary.Add(pinCode.ToString(), pinCode); return(true); }
public IPinCodeCollection Generate(int batchSize) { var pinCodeCollection = _pinCodeCollectionFactory(); if (batchSize <= 0) { return(pinCodeCollection); } var i = 0; do { PinCode pinCode = GeneratePinCode(); if (_pinCodeValidator.IsPinCodeValid(pinCode)) { if (pinCodeCollection.Add(pinCode)) { i++; } } } while (i < batchSize); return(pinCodeCollection); }