コード例 #1
0
 public void CountHigherThanRangeSize()
 {
     Assert.Throws <InvalidOperationException>(() => new CombinatorialRandomAttribute {
         Count = 6, Minimum = 1, Maximum = 5
     }.Values);
     Assert.Throws <InvalidOperationException>(() => new CombinatorialRandomAttribute {
         Count = 4, Minimum = -3, Maximum = -1
     }.Values);
     _ = new CombinatorialRandomAttribute {
         Count = 3, Minimum = 1, Maximum = 3
     }.Values;
     _ = new CombinatorialRandomAttribute {
         Count = 3, Minimum = -3, Maximum = -1
     }.Values;
 }
コード例 #2
0
        internal void Check(CombinatorialRandomAttribute attribute)
        {
            Assert.NotNull(attribute.Values);
            Assert.Equal(attribute.Count, attribute.Values.Length);

            Assert.All(attribute.Values, value =>
            {
                Assert.IsType <int>(value);
                var intValue = (int)value;
                Assert.InRange(intValue, attribute.Minimum, attribute.Maximum);
            });

            if (attribute.Seed != CombinatorialRandomAttribute.NoSeed)
            {
                Assert.Equal(RandomIterator(new Random(attribute.Seed), attribute.Minimum, attribute.Maximum).Distinct().Take(attribute.Count).ToArray(), attribute.Values.Cast <int>());
            }
        }