Exemplo n.º 1
0
        public override IEnumerable <IRuleParameter> GetRuleInputs(IReadableWorld world)
        {
            Func <RuleValue <string>, bool> predicate = p => p.Value.Length > 3 && (p.UserData.IsMarried == null || !p.UserData.IsMarried);

            yield return(new RuleParameter <string> (predicate));

            yield return(new RuleParameter <string> (predicate));
        }
Exemplo n.º 2
0
        public override IEnumerable <IRuleParameter> GetRuleInputs(IReadableWorld world)
        {
            yield return(new RuleParameter <Person> (p => p.Value.Age >= 14 && p.Value.Age < 20 && p.Value.Gender == Gender.Male,
                                                     (p, ruleInput) => p.Value.Likes(ruleInput.GetValue <Person> (1).Value) ? null : new[] { 1 }));

            yield return
                (new RuleParameter <Person> (
                     p => p.Value.Age >= 14 && p.Value.Age < 20 && p.Value.Gender == Gender.Female && (p.UserData.IsPregnant == null || !p.UserData.IsPregnant),
                     (p, ruleInput) => p.Value.Likes(ruleInput.GetValue <Person> (0).Value) ? null : new[] { 0 }));
        }
Exemplo n.º 3
0
        public override float GetExecutionProbability(IReadableWorld world)
        {
            var fertility = world.Read <float?> (x => x.Fertility);

            if (!fertility.HasValue)
            {
                throw new ArgumentException("You need a global rule that declares the world fertility");
            }

            return(fertility.Value);
        }
 internal CompoundRuleExecutionContext(CompoundRuleInput inputData, ITestDataGenerator testDataGenerator, IReadableWorld world)
     : base(testDataGenerator, world)
 {
     InputData = inputData;
 }
Exemplo n.º 5
0
 public abstract IEnumerable <IRuleParameter> GetRuleInputs(IReadableWorld world);
Exemplo n.º 6
0
 public virtual float GetExecutionProbability(IReadableWorld world)
 {
     return(1);
 }
Exemplo n.º 7
0
 internal SimpleRuleExecutionContext(ITestDataGenerator testDataGenerator, IReadableWorld world, RuleValue <T> input)
     : base(testDataGenerator, world)
 {
     Input = input;
 }
Exemplo n.º 8
0
 public sealed override float GetExecutionProbability(IReadableWorld world)
 {
     return(1f);
 }
Exemplo n.º 9
0
 public sealed override IEnumerable <IRuleParameter> GetRuleInputs(IReadableWorld world)
 {
     yield return(new RuleParameter <T>());
 }
Exemplo n.º 10
0
 public override float GetExecutionProbability(IReadableWorld world)
 {
     return(0.5f);
 }
Exemplo n.º 11
0
 internal RuleExecutionContext(ITestDataGenerator testDataGenerator, IReadableWorld world)
 {
     TestDataGenerator = testDataGenerator;
     World             = world;
 }