public void GetExpressionGetsAnExpresssionWhichReturnsTrueForAManifestValueAndTheSameItemWithoutIdentity([ManifestModel] ManifestValue value, ObjectWithIdentity item) { value.IdentityAccessor = null; var context = new ValueContext(null, item, value); var sut = new ValueContextIsMatchForItem(value, item); Assert.That(sut.Matches(context), Is.True); }
public void GetExpressionGetsAnExpresssionWhichReturnsTrueForAManifestValueAndNoItem([ManifestModel] ManifestValue value, object identity, object actualValue) { var context = new ValueContext(identity, actualValue, value); var sut = new ValueContextIsMatchForItem(value); Assert.That(sut.Matches(context), Is.True); }
public void GetExpressionGetsAnExpresssionWhichReturnsFalseForAManifestValueAndAnItemWithTheWrongIdentity([ManifestModel] ManifestValue value, ObjectWithIdentity item) { value.IdentityAccessor = obj => ((ObjectWithIdentity)obj).Identity; var context = new ValueContext(Guid.NewGuid(), item, value); var sut = new ValueContextIsMatchForItem(value, item); Assert.That(sut.Matches(context), Is.False); }
/// <summary> /// Gets an expression which represents the current specification instance. /// </summary> /// <returns>The specification expression.</returns> public Expression <Func <ValidationRuleResult, bool> > GetExpression() { return(result => valueConextIsMatch.Matches(result.RuleContext) || (allowAncestors && result.RuleContext.AncestorContexts.Any(valueConextIsMatch))); }