public void EqualsObj_xEqualsy_and_yEqualsx_returns_xEqualsz() { var x = new BranchExpression(new DynamicMethod("Test", typeof(bool), null), new Chromosome(), new Chromosome()); var y = new BranchExpression(new DynamicMethod("Test2", typeof(bool), null), new Chromosome(), new Chromosome()); var z = new BranchExpression(new DynamicMethod("Test3", typeof(bool), null), new Chromosome(), new Chromosome()); Assert.IsTrue(!(x.Equals((object)y) && y.Equals((object)z)) || x.Equals((object)z)); }
public void BranchMethod_ToString_Returns_branched_method_structure() { const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance; var methods = GetType().GetMethods(flags); var branchMethod = methods.First(m => m.DeclaringType == GetType() && m.ReturnType == typeof(bool)); var terminalMethod = methods.First(m => m.DeclaringType == GetType() && m.ReturnType == typeof(void)); var branch = new BranchExpression(branchMethod, new Chromosome { Node = new TerminalExpression(terminalMethod) }, new Chromosome { Node = new TerminalExpression(terminalMethod) }); var output = branch.ToString(); var expected = string.Format("{0}(){1}T {2}(){1}F {2}()", branchMethod.Name, Environment.NewLine, terminalMethod.Name); Assert.AreEqual(expected, output); }
public void EqualsObj_xEqualsy_returns_yEqualsx() { var x = new BranchExpression(new DynamicMethod("Test", typeof(bool), null), new Chromosome(), new Chromosome()); var y = new BranchExpression(new DynamicMethod("Test2", typeof(bool), null), new Chromosome(), new Chromosome()); Assert.IsTrue(x.Equals((object)y) == y.Equals((object)x)); }
public void EqualsObj_xEqualsNull_returnsFalse() { var x = new BranchExpression(new DynamicMethod("Test", typeof(bool), null), new Chromosome(), new Chromosome()); Assert.IsFalse(x.Equals((object)null)); }