public IEnumerable<IBe> Mutate(IBe be)
        {
            var ruleValues = (be as MushroomRule).Rule.ToString().Split(',');

            var random = new Random();
            var indexToSpecify = random.Next(0, ruleValues.Count() - 1);

            var attempts = 10;

            while (attempts > 0)
            {
                if (ruleValues.ElementAt(indexToSpecify)[0] == '0')
                {
                    var pvalues = posibleValues.ElementAt(indexToSpecify);
                    var index = random.Next(pvalues.Count() - 1);
                    ///TODO: remove index
                    ruleValues.SetValue(pvalues.ElementAt(index).ToString(), indexToSpecify);
                    break;
                }
                indexToSpecify = random.Next(0, ruleValues.Count() - 1);
                attempts--;
            }

            return new[]
            {
                new MushroomRule((be as MushroomRule).DataProvider, be.Generation + 1, new Mushroom(ruleValues), (be as MushroomRule).ClassValue)
            };
        }
        public IEnumerable<IBe> Mutate(IBe be)
        {
            var ruleValues = (be as MushroomRule).Rule.ToString().Split(',');

            var random = new Random();
            var indexToGeneralize = random.Next(0, ruleValues.Count());

            var attempts = 10;

            while (attempts > 0)
            {
                if (ruleValues.ElementAt(indexToGeneralize)[0] != '0')
                {
                    ruleValues.SetValue(ruleValues.ElementAt(indexToGeneralize), indexToGeneralize);
                    break;
                }

                indexToGeneralize = random.Next(0, ruleValues.Count());
                attempts--;
            }

            return new[]
            {
                new MushroomRule((be as MushroomRule).DataProvider, be.Generation + 1, new Mushroom(ruleValues), (be as MushroomRule).ClassValue)
            };
        }
        public IEnumerable<IBe> Conceive(IBe father, IBe mother)
        {
            var mushroomRuleFatherRuleString = (father as MushroomRule).Rule.ToString().Split(',');
            var mushroomRuleMotherRuleString = (mother as MushroomRule).Rule.ToString().Split(',');

            var random = new Random();

            var splitIndex = random.Next(0, mushroomRuleFatherRuleString.Count());

            return new[]
            {
                new MushroomRule((father as MushroomRule).DataProvider, Math.Max(father.Generation, mother.Generation) + 1, (father as MushroomRule).ClassValue)
                {
                    Rule = new Mushroom(mushroomRuleFatherRuleString.Take(splitIndex).Concat(mushroomRuleMotherRuleString.Skip(splitIndex)))
                }
            };
        }
Esempio n. 4
0
 public static string GreaterThan(this IBe <string> be, string value)
 {
     return(Check.GreaterThan(be.Should, value));
 }
Esempio n. 5
0
 public static string Empty(this IBe <string> be)
 {
     return(be.Should.Apply(
                (t, a) => a.AreEqual(string.Empty, t),
                (t, a) => a.AreNotEqual(string.Empty, t)));
 }
Esempio n. 6
0
 public static string NullOrEmpty(this IBe <string> be)
 {
     return(be.Should.Apply(
                (t, a) => a.IsTrue(string.IsNullOrEmpty(t)),
                (t, a) => a.IsFalse(string.IsNullOrEmpty(t))));
 }
Esempio n. 7
0
 public static Guid LessThanOrEqualTo(this IBe <Guid> be, Guid value)
 {
     return(Check.LessThanOrEqual(be.Should, value));
 }
Esempio n. 8
0
 /// <summary>
 /// Asserts that a string is alpha-numeric
 /// </summary>
 /// <param name="be"></param>
 /// <param name="customMessage"></param>
 /// <returns></returns>
 public static IStringMore Alphanumeric(
     this IBe <string> be,
     string customMessage)
 {
     return(be.Alphanumeric(() => customMessage));
 }
Esempio n. 9
0
 public static string LessThanOrEqualTo(this IBe <string> be, string value)
 {
     return(Check.LessThanOrEqual(be.Should, value));
 }
Esempio n. 10
0
 public static void True(this IBe <bool> expectation, string message)
 {
     TestBoolean(expectation, true, message);
 }
Esempio n. 11
0
 public static DateTime?GreaterThan(this IBe <DateTime?> be, DateTime?value, IComparer <DateTime?> comparer)
 {
     return(Check.GreaterThan(be.Should, value, comparer));
 }
Esempio n. 12
0
 public static DateTime?LessThanOrEqualTo(this IBe <DateTime?> be, DateTime?value)
 {
     return(Check.LessThanOrEqual(be.Should, value));
 }
 public static bool?Null(this IBe <bool?> be)
 {
     return(Check.IsNull(be.Should));
 }
Esempio n. 14
0
 public static DateTime?GreaterThan(this IBe <DateTime?> be, DateTime?value)
 {
     return(Check.GreaterThan(be.Should, value));
 }
Esempio n. 15
0
 public static void NoLongerThan(this IBe <string> be, int maxLength)
 {
     be.Should.Apply(
         (t, a) => a.LessThanOrEqual(t.Length, maxLength),
         (t, a) => a.GreaterThan(t.Length, maxLength));
 }
Esempio n. 16
0
 public static Guid Empty(this IBe <Guid> be)
 {
     return(be.Should.Apply(
                (t, a) => a.AreEqual(Guid.Empty, t),
                (t, a) => a.AreNotEqual(Guid.Empty, t)));
 }
Esempio n. 17
0
 public static Guid LessThanOrEqualTo(this IBe <Guid> be, Guid value, IComparer <Guid> comparer)
 {
     return(Check.LessThanOrEqual(be.Should, value, comparer));
 }
Esempio n. 18
0
 public static string GreaterThan(this IBe <string> be, string value, IComparer <string> comparer)
 {
     return(Check.GreaterThan(be.Should, value, comparer));
 }
Esempio n. 19
0
 public static Guid GreaterThan(this IBe <Guid> be, Guid value)
 {
     return(Check.GreaterThan(be.Should, value));
 }
Esempio n. 20
0
 public static string Null(this IBe <string> be)
 {
     return(Check.IsNull(be.Should));
 }
Esempio n. 21
0
        public IEnumerable<IBe> Mutate(IBe xBe)
        {
            var random = new Random();

            return mutators.ElementAt(random.Next(0, mutators.Count())).Mutate(xBe);
        }
Esempio n. 22
0
 public static string LessThanOrEqualTo(this IBe <string> be, string value, IComparer <string> comparer)
 {
     return(Check.LessThanOrEqual(be.Should, value, comparer));
 }
 public static ICollection Empty(this IBe <ICollection> be)
 {
     return(be.Should.Apply(
                (t, a) => a.AreEqual(0, t.Count),
                (t, a) => a.AreNotEqual(0, t.Count)));
 }
Esempio n. 24
0
 public static DateTime?LessThanOrEqualTo(this IBe <DateTime?> be, DateTime?value, IComparer <DateTime?> comparer)
 {
     return(Check.LessThanOrEqual(be.Should, value, comparer));
 }
Esempio n. 25
0
 public static Guid GreaterThan(this IBe <Guid> be, Guid value, IComparer <Guid> comparer)
 {
     return(Check.GreaterThan(be.Should, value, comparer));
 }
Esempio n. 26
0
 public IEnumerable<IBe> Conceive(IBe father, IBe mother)
 {
     var random = new Random();
     return conceivers.ElementAt(random.Next(0, conceivers.Count())).Conceive(father, mother);
 }
Esempio n. 27
0
 public static DateTime?Null(this IBe <DateTime?> be)
 {
     return(Check.IsNull(be.Should));
 }
Esempio n. 28
0
 /// <summary>
 /// Asserts that a string is alpha-numeric
 /// </summary>
 /// <param name="be"></param>
 /// <returns></returns>
 public static IStringMore Alphanumeric(
     this IBe <string> be)
 {
     return(be.Alphanumeric(NULL_STRING));
 }
 public static ICollection Null(this IBe <ICollection> be)
 {
     return(Check.IsNull(be.Should));
 }