コード例 #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);
        }
コード例 #4
0
 /// <summary>
 /// Initialises a new instance of <see cref="RuleResultIsForDescendentOfValue"/> with a validated item instance..
 /// </summary>
 /// <param name="value">A manifest value which rules must be a descendent of in order to match the spec.</param>
 /// <param name="item">An optional item (of the type indicated by the <paramref name="value"/>) which the rule must be a descendent of.</param>
 /// <param name="allowAncestors">If <see langword="true" /> then rule results will match if the value appears in any
 /// ancestor context, as well as the rule's own context.  If <see langword="false" /> then only the rule's immediate
 /// context will be searched, indicating that this is a specification for immediate children only.</param>
 /// <exception cref="ArgumentNullException">If <paramref name="value"/> is <see langword="null" />.</exception>
 public RuleResultIsForDescendentOfValue(IManifestItem value, object item, bool allowAncestors = true)
 {
     valueConextIsMatch  = new ValueContextIsMatchForItem(value ?? throw new ArgumentNullException(nameof(value)), item);
     this.allowAncestors = allowAncestors;
 }