public void ConstructorSetsCriteria() { var criteria = new OrCriteria(salutationMr, area408); Assert.Contains(salutationMr, criteria.Criteria); Assert.Contains(area408, criteria.Criteria); Assert.Equal(2, criteria.Criteria.Count); }
/// <summary> /// Reduce an <see cref="OrCriteria" /> that might contain a <see cref="ConstantCriteria" />. /// </summary> /// <param name="orCriteria"><see cref="OrCriteria" /> to be reduced.</param> /// <returns>Reduced criteria.</returns> /// <remarks> /// Falses will be removed, trues will replace the entire Or with a true. /// </remarks> private static ICriteria Reduce(OrCriteria orCriteria) { if (orCriteria.Criteria.Any(c => c == ConstantCriteria.True)) return ConstantCriteria.True; return OrCriteria .Combine(orCriteria .Criteria .Select(Reduce) .Where(c => c != ConstantCriteria.False && c != null) .ToArray()); }
/// <summary> /// Reduce an <see cref="OrCriteria" /> that might contain a <see cref="ConstantCriteria" />. /// </summary> /// <param name="orCriteria"><see cref="OrCriteria" /> to be reduced.</param> /// <returns>Reduced criteria.</returns> /// <remarks> /// Falses will be removed, trues will replace the entire Or with a true. /// </remarks> static ICriteria Reduce(OrCriteria orCriteria) { if (orCriteria.Criteria.Any(c => c == ConstantCriteria.True)) { return(ConstantCriteria.True); } return(OrCriteria .Combine(orCriteria .Criteria .Select(Reduce) .Where(c => c != ConstantCriteria.False && c != null) .ToArray())); }
/// <summary> /// Rewrite an <see cref="OrCriteria" /> as a <see cref="BoolCriteria" />. /// </summary> /// <param name="or"><see cref="OrCriteria" /> to rewrite.</param> /// <returns><see cref="BoolCriteria" /> with the criteria from the Or mapped into Should.</returns> static BoolCriteria Rewrite(OrCriteria or) { return(new BoolCriteria(null, or.Criteria.Select(Compensate), null)); }
public void NamePropertyIsOr() { var criteria = new OrCriteria(); Assert.Equal("or", criteria.Name); }
/// <summary> /// Rewrite an <see cref="OrCriteria" /> as a <see cref="BoolCriteria" />. /// </summary> /// <param name="or"><see cref="OrCriteria" /> to rewrite.</param> /// <returns><see cref="BoolCriteria" /> with the criteria from the Or mapped into Should.</returns> private static BoolCriteria Rewrite(OrCriteria or) { return new BoolCriteria(null, or.Criteria.Select(Compensate), null); }