public void OnlyReturnPositiveExpressionTypes()
        {
            // Arrange
            var weighted = new WeightedExpressionTypeProvider();
            foreach (ExpressionType type in Enum.GetValues(typeof(ExpressionType))) {
                weighted.SetTypeDistribution(type, 0);
            }

            ExpressionType[] allowed = {
                                           ExpressionType.Add,
                                           ExpressionType.Subtract,
                                           ExpressionType.Constant
                                       };

            foreach (ExpressionType type in allowed) {
                weighted.SetTypeDistribution(type, 1);
            }

            // Act
            // Assert
            for (int i = 0; i < 10; i++) {
                var expressionType = weighted.NextExpressionType();

                bool typeFound = false;

                foreach (ExpressionType type in allowed) {
                    if (expressionType == type) {
                        typeFound = true;
                        continue;
                    }
                }

                Assert.IsTrue(typeFound);
            }
        }
        public void ShouldNotAllowNegativeWeight()
        {
            // Arrange
            var weighted = new WeightedExpressionTypeProvider();

            // Act
            // Assert
            weighted.SetTypeDistribution(ExpressionType.Subtract, -1);
        }
        public void TypeDistribution_SelectUnlikelyExpressionType()
        {
            // Arrange
            var weighted = new WeightedExpressionTypeProvider();
            foreach (ExpressionType type in Enum.GetValues(typeof(ExpressionType))) {
                weighted.SetTypeDistribution(type, 0);
            }

            // Act
            weighted.SetTypeDistribution(ExpressionType.Add, 100000000);
            weighted.SetTypeDistribution(ExpressionType.Subtract, 0.00001);
            var expressionType = weighted.NextExpressionType();

            // Assert
            Assert.AreEqual(ExpressionType.Add, expressionType);
        }