Ejemplo n.º 1
0
        public ICheckLogic <TU> CheckSutAttributes <TU>(Func <T, TU> sutExtractor, string propertyName)
        {
            var sutWrapper = this.fluentSut.Extract(sutExtractor,
                                                    sut => string.IsNullOrEmpty(propertyName) ? sut.SutName.EntityName : $"{sut.SutName.EntityName}'s {propertyName}");
            var result = new CheckLogic <TU>(sutWrapper);

            if (this.cannotBetNegated)
            {
                result.SetNotNegatable(this.negatedError);
            }

            result.parentFailed        = this.failed;
            result.parentNegatedFailed = this.negatedFailed;
            result.parent = this;

            this.child = result;
            return(result);
        }
Ejemplo n.º 2
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
            };

            if (this.cannotBetNegated)
            {
                result.SetNotNegatable(this.negatedError);
            }

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

            if (!string.IsNullOrEmpty(propertyName))
            {
                result.SetSutName($"{finalSutName}'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);
        }