Exemple #1
0
        public void Can_Skip_Non_Unique_Digit()
        {
            //Arrange
            HashSet <Digit> hashSet          = GetHashSetData();
            var             mockDigitCreator = new Mock <IDigitCreator>();
            var             number           = 1;

            mockDigitCreator.Setup(dc => dc.CreateDigit()).
            Returns(() => new Digit()
            {
                Number = number.ToString()
            })
            .Callback(() => new Digit()
            {
                Number = (number++).ToString()
            });

            //Act
            DigitGenerator target = new DigitGenerator(mockDigitCreator.Object, hashSet);
            var            result = target.GenerateDigits(GetHashSetData(), 2).ToList();

            //Assert
            Assert.AreEqual(6, result.Count());
            Assert.IsTrue(result.Where(item => item.Number == "1").Count() == 1);
        }
Exemple #2
0
        public void Can_Generate_Digits()
        {
            //Arrange
            DigitGenerator digitGenerator = new DigitGenerator(new DigitCreator(), new HashSet <Digit>());

            //Act
            var result = digitGenerator.GenerateDigits(null, 4).ToList();

            //Assert
            Assert.AreEqual(4, result.Count());
            Assert.AreEqual(16, result[0].Number.Length);
            Assert.AreEqual(16, result[1].Number.Length);
            Assert.AreEqual(16, result[2].Number.Length);
            Assert.AreEqual(16, result[3].Number.Length);
        }
 static InlineGenerators()
 {
     _alphaCharGenerator   = new AlphaCharGenerator();
     _digitCharGenerator   = new DigitCharGenerator();
     _lowerCaseAlphaChar   = _alphaCharGenerator.AsLowerCase();
     _upperCaseAlphaChar   = _alphaCharGenerator.AsUpperCase();
     _simpleValueGenerator = new SimpleValueGenerator <char>();
     _stringGenerator      = new SimpleValueGenerator <string>();
     _lowercaseString      = new ValueConversion <string, string>(_stringGenerator, s => s.ToLowerInvariant());
     _uppercaseString      = new ValueConversion <string, string>(_stringGenerator, s => s.ToUpperInvariant());
     _lowercaseAlphaString = new ValueConversion <string, string>(
         AlphaString(System.Guid.NewGuid().ToString().Length), s => s.ToLowerInvariant());
     _uppercaseAlphaString = new ValueConversion <string, string>(
         AlphaString(System.Guid.NewGuid().ToString().Length), s => s.ToUpperInvariant());
     _identifierStringGenerator = new IdentifierStringGenerator(_digitCharGenerator, _alphaCharGenerator);
     _uriGenerator       = new SimpleValueGenerator <Uri>();
     _uriStringGenerator = new ValueConversion <Uri, string>(_uriGenerator, u => u.ToString());
     _guid                    = new SimpleValueGenerator <Guid>();
     _intGenerator            = new SimpleValueGenerator <int>();
     _doubleGenerator         = new SimpleValueGenerator <double>();
     _longGenerator           = new SimpleValueGenerator <long>();
     _unsignedLongGenerator   = new SimpleValueGenerator <ulong>();
     _byteGenerator           = new SimpleValueGenerator <byte>();
     _decimalGenerator        = new SimpleValueGenerator <decimal>();
     _uintGenerator           = new SimpleValueGenerator <uint>();
     _ushortGenerator         = new SimpleValueGenerator <ushort>();
     _shortGenerator          = new SimpleValueGenerator <short>();
     _digitGenerator          = new DigitGenerator();
     _positiveDigitGenerator  = new PositiveDigitGenerator(_digitGenerator);
     _ipStringGenerator       = new IpStringGenerator();
     _portNumberGenerator     = new PortNumberGenerator();
     _actionGenerator         = new SimpleInstanceGenerator <Action>();
     _notStartedTaskGenerator = new NotStartedTaskGenerator();
     _ipAddressGenerator      = new SimpleValueGenerator <IPAddress>();
     _dateTimeGenerator       = new SimpleValueGenerator <DateTime>();
     _timeSpanGenerator       = new SimpleValueGenerator <TimeSpan>();
     _boolGenerator           = new SimpleValueGenerator <bool>();
     _objectGenerator         = new SimpleValueGenerator <object>();
     _methodInfoGenerator     = new SimpleValueGenerator <MethodInfo>();
     _typeGenerator           = new SimpleValueGenerator <Type>();
     _exceptionGenerator      = new SimpleValueGenerator <Exception>();
 }
Exemple #4
0
        public void Can_Recieve_Existing_Digits()
        {
            //Arrange
            HashSet <Digit> hashSetWithData = GetHashSetData();

            //Act
            DigitGenerator target = new DigitGenerator(new DigitCreator(), null);
            var            result = target.GenerateDigits(hashSetWithData, 4).ToList();

            //Assert
            Assert.AreEqual(8, result.Count());
            Assert.AreEqual("1", result[0].Number);
            Assert.AreEqual("2", result[1].Number);
            Assert.AreEqual("3", result[2].Number);
            Assert.AreEqual("4", result[3].Number);
            Assert.AreEqual(16, result[4].Number.Length);
            Assert.AreEqual(16, result[5].Number.Length);
            Assert.AreEqual(16, result[6].Number.Length);
            Assert.AreEqual(16, result[7].Number.Length);
        }