示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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)));
 }