コード例 #1
0
        public ICheckLogic <TU> CheckSutAttributes <TU>(Func <T, TU> sutExtractor, string propertyName)
        {
            var value      = this.fluentSut.Value;
            var sutWrapper = new FluentSut <TU>(value == null ? default(TU) : sutExtractor(value),
                                                this.fluentSut.Reporter,
                                                this.IsNegated)
            {
                CustomMessage = this.fluentSut.CustomMessage
            };
            var result =
                new CheckLogic <TU>(sutWrapper)
            {
                isRoot = false
            };

            var sutName = string.IsNullOrEmpty(this.sutName) ? (this.fluentSut.SutName ?? "value") : this.sutName;

            if (!string.IsNullOrEmpty(propertyName))
            {
                result.SetSutName($"{sutName}'s {propertyName}");
            }
            if (this.failed != this.IsNegated)
            {
                result.failed        = this.failed;
                result.negatedFailed = this.negatedFailed;
                result.lastError     = this.lastError;
                result.negatedError  = this.negatedError;
                result.negatedOption = this.negatedOption;
                result.options       = this.options;
            }

            this.child = result;
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Build a FluentSut from an extract of the current value.
        /// </summary>
        /// <typeparam name="TU">type of the sub value</typeparam>
        /// <param name="extractor">sub value extractor</param>
        /// <param name="nameCallback">naming methods</param>
        /// <param name="reporter">error reporter for the extracted sut</param>
        /// <returns>A new <see cref="FluentSut{T}"/> instance</returns>
        public FluentSut <TU> Extract <TU>(Func <T, TU> extractor, Func <FluentSut <T>, string> nameCallback, IErrorReporter reporter = null)
        {
            var val    = (object)this.Value == null ? default(TU) : extractor(this.Value);
            var result = new FluentSut <TU>(val, reporter ?? this.Reporter, this.Negated);

            result.SutName.SetNameBuilder(() => nameCallback(this));
            result.CustomMessage = this.CustomMessage;
            return(result);
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Checker{T,TC}" /> class.
 /// </summary>
 /// <param name="fluentCheckForExtensibility">The runnable fluent check.</param>
 /// <param name="fluentSut"></param>
 public Checker(ICheckForExtensibility <T, TC> fluentCheckForExtensibility, FluentSut <T> fluentSut)
 {
     this.fluentCheckForExtensibility = fluentCheckForExtensibility;
     this.fluentSut = fluentSut;
 }
コード例 #4
0
 public CheckLogic(FluentSut <T> fluentSut)
 {
     this.fluentSut = fluentSut;
 }
コード例 #5
0
 public CheckLogic(FluentSut <T> fluentSut)
 {
     this.fluentSut = fluentSut;
     this.isRoot    = true;
 }
コード例 #6
0
 internal FluentCheck(FluentSut <T> copy, bool negated) : base(copy, negated)
 {
     this.checker = new Checker <T, ICheck <T> >(this, this);
 }
コード例 #7
0
 /// <summary>
 /// Builds a new <see cref="FluentSut{T}"/> instance.
 /// </summary>
 /// <param name="other">Value to examine.</param>
 /// <param name="negated">true if the check logic must be negated.</param>
 public FluentSut(FluentSut <T> other, bool negated) : this(other.Value, other.Reporter, negated)
 {
     this.SutName = other.SutName.Clone();
 }
コード例 #8
0
 private FluentStructCheck(FluentSut <T> other, bool negated) : base(other, negated)
 {
     this.structChecker = new Checker <T, IStructCheck <T> >(this, this);
 }
コード例 #9
0
 /// <summary>
 /// Builds a new <see cref="FluentSut{T}"/> instance.
 /// </summary>
 /// <param name="other">Value to examine.</param>
 /// <param name="negated">true if the check logic must be negated.</param>
 public FluentSut(FluentSut <T> other, bool negated) : this(other.Value, other.Reporter, negated)
 {
     this.namingLogic = other.namingLogic.Clone();
 }