Exemplo n.º 1
0
        public void length_of_strings_should_be_varied()
        {
            var randomStrings = new RandomStringAttribute(0, 500, 1000)
                                .GetData(new FakeParameterInfo());
            var values = randomStrings.Cast <string>().ToList();

            values.GroupBy(value => value.Length).ToList().ForEach(g =>
                                                                   Assert.That(g.Count(), Is.LessThanOrEqualTo(10), $"{g.First().Length} found {g.Count()} times."));
        }
Exemplo n.º 2
0
        public void length_of_strings_should_vary_between_min_and_max(
            [Random(0, 250, 10)] int min,
            [Random(251, 500, 10)] int max)
        {
            var randomStrings = new RandomStringAttribute(min, max)
                                .GetData(new FakeParameterInfo());
            var values = randomStrings.Cast <string>().ToList();

            values.ForEach(s =>
            {
                Assert.That(s.Length, Is.GreaterThanOrEqualTo(min));
                Assert.That(s.Length, Is.LessThanOrEqualTo(max));
            });

            values.GroupBy(value => value.Length).ToList().ForEach(g =>
                                                                   Assert.That(g.Count(), Is.LessThanOrEqualTo(5)));
        }