Beispiel #1
0
        public void ReturnMaxCombinationForAPinsLength()
        {
            // Arrange
            var pinLength = 4;

            // Act: We can mock the Func<> params
            var result = _randomPinService.MaxPinCombinations(pinLength);

            // Assert
            Assert.AreEqual(10000, result, "Max combinations for 4 digit pin is 10 000");
        }
        public HashSet <string> GetPins(int batchSize, int pinLength)
        {
            // Must not exceed max combinations for the length of the pin
            if (batchSize < _randomPinService.MaxPinCombinations(pinLength))
            {
                var pinHashset = new HashSet <string>();

                while (pinHashset.Count() < batchSize)
                {
                    pinHashset.Add(_randomPinService.GeneratePin(pinLength));
                }

                return(pinHashset);
            }

            throw new ArgumentOutOfRangeException("Batch size exceeds max combinations for pin length");
        }