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))) } }; }
public static string GreaterThan(this IBe <string> be, string value) { return(Check.GreaterThan(be.Should, value)); }
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))); }
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)))); }
public static Guid LessThanOrEqualTo(this IBe <Guid> be, Guid value) { return(Check.LessThanOrEqual(be.Should, value)); }
/// <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)); }
public static string LessThanOrEqualTo(this IBe <string> be, string value) { return(Check.LessThanOrEqual(be.Should, value)); }
public static void True(this IBe <bool> expectation, string message) { TestBoolean(expectation, true, message); }
public static DateTime?GreaterThan(this IBe <DateTime?> be, DateTime?value, IComparer <DateTime?> comparer) { return(Check.GreaterThan(be.Should, value, comparer)); }
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)); }
public static DateTime?GreaterThan(this IBe <DateTime?> be, DateTime?value) { return(Check.GreaterThan(be.Should, value)); }
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)); }
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))); }
public static Guid LessThanOrEqualTo(this IBe <Guid> be, Guid value, IComparer <Guid> comparer) { return(Check.LessThanOrEqual(be.Should, value, comparer)); }
public static string GreaterThan(this IBe <string> be, string value, IComparer <string> comparer) { return(Check.GreaterThan(be.Should, value, comparer)); }
public static Guid GreaterThan(this IBe <Guid> be, Guid value) { return(Check.GreaterThan(be.Should, value)); }
public static string Null(this IBe <string> be) { return(Check.IsNull(be.Should)); }
public IEnumerable<IBe> Mutate(IBe xBe) { var random = new Random(); return mutators.ElementAt(random.Next(0, mutators.Count())).Mutate(xBe); }
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))); }
public static DateTime?LessThanOrEqualTo(this IBe <DateTime?> be, DateTime?value, IComparer <DateTime?> comparer) { return(Check.LessThanOrEqual(be.Should, value, comparer)); }
public static Guid GreaterThan(this IBe <Guid> be, Guid value, IComparer <Guid> comparer) { return(Check.GreaterThan(be.Should, value, comparer)); }
public IEnumerable<IBe> Conceive(IBe father, IBe mother) { var random = new Random(); return conceivers.ElementAt(random.Next(0, conceivers.Count())).Conceive(father, mother); }
public static DateTime?Null(this IBe <DateTime?> be) { return(Check.IsNull(be.Should)); }
/// <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)); }