public void ShouldNotEqual() { var exp1 = EquatableExpression.Create <ClassA, int>(a => a.A); var exp2 = EquatableExpression.Create <AnotherClassA, int>(a => a.A); Assert.AreNotEqual(exp1, exp2); Assert.IsTrue(exp1 != exp2); Assert.IsFalse(exp1 == exp2); }
public void ShouldMatchAnyExpression() { var r = CreateReport(); var o = new ClassA(); //Simulate an error occuring on ClassA r.AddError(new ValidationError(CreateRule(), EquatableExpression.Create <ClassA, int>(a => a.A), new object[0], o)); //Passing in null should match any errors on any expressions... Assert.IsTrue(r.HasError(o, null)); }
public void ShouldHaveErrorB1() { var r = CreateReport(); var o = new ClassB(); //Simulate an error occuring on ClassB. r.AddError(new ValidationError(CreateRule(), EquatableExpression.Create <ClassB, int>(a => a.A), new object[0], o)); Assert.IsTrue(r.HasError(o, EquatableExpression.Create <ClassA, int>(a => a.A))); //Eventhough, o is not ClassB, the expression b => b.A still applies to a ClassA. And therefore the following statement must be true. Assert.IsTrue(r.HasError(o, EquatableExpression.Create <ClassB, int>(b => b.A))); }
public void ShouldNotApplyTo() { var exp1 = EquatableExpression.Create <ClassA, int>(a => a.A); var exp2 = EquatableExpression.Create <AnotherClassA, int>(a => a.A); var exp3 = EquatableExpression.Create <ClassB, int>(a => a.B); Assert.IsFalse(exp1.AppliesTo(exp2)); Assert.IsFalse(exp1.AppliesTo(exp3)); Assert.IsFalse(exp2.AppliesTo(exp1)); Assert.IsFalse(exp2.AppliesTo(exp3)); Assert.IsFalse(exp3.AppliesTo(exp1)); Assert.IsFalse(exp3.AppliesTo(exp2)); }
public void ShouldApplyTo() { var exp1 = EquatableExpression.Create <ClassA, int>(a => a.A); var exp2 = EquatableExpression.Create <ClassB, int>(a1 => a1.A); var exp3 = EquatableExpression.Create <IClassA, int>(x1 => x1.A); Assert.IsTrue(exp1.AppliesTo(exp2)); Assert.IsTrue(exp1.AppliesTo(exp3)); Assert.IsTrue(exp2.AppliesTo(exp1)); Assert.IsTrue(exp2.AppliesTo(exp3)); Assert.IsTrue(exp3.AppliesTo(exp1)); Assert.IsTrue(exp3.AppliesTo(exp2)); }