예제 #1
0
        public void ShorthandGeneratorShouldProduceValidShorthands(int length, string pattern)
        {
            // Arrange
            var shorthandGenerator = new ShorthandGenerator(new Random());

            // Act
            var shorthand = shorthandGenerator.GenerateShorthand(length, pattern);

            // Assert
            shorthand.All(pattern.Contains).Should().BeTrue();
            shorthand.Length.Should().Be(length);
        }
예제 #2
0
        public void ShorthandGeneratorShouldProduceUniqueShorthands(int length, string pattern)
        {
            // Arrange
            const int runs = 100000;
            var       shorthandGenerator = new ShorthandGenerator(new Random());
            var       shorthands         = new HashSet <string>();

            // Act
            for (var i = 0; i < runs; i++)
            {
                shorthands.Add(shorthandGenerator.GenerateShorthand(length, pattern));
            }

            // Assert
            shorthands.Count.Should().Be(runs);
        }