Exemplo n.º 1
0
        public ICheckLogic <TU> CheckSutAttributes <TU>(Func <T, TU> sutExtractor, string propertyName)
        {
            var value  = this.fluentSut.Value;
            var result =
                new CheckLogic <TU>(new FluentSut <TU>(value == null ? default(TU) : sutExtractor(value),
                                                       this.fluentSut.Reporter,
                                                       this.IsNegated))
            {
                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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        // TODO: improve sut naming logic on extraction
        public ICheckLogic <TU> GetSutProperty <TU>(Func <T, TU> sutExtractor, string newSutLabel)
        {
            var result =
                new CheckLogic <TU>(this.value == null ? default(TU) : sutExtractor(this.value), null, this.IsNegated);

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

            result.SutNameIs($"{sutname}'s {newSutLabel}");
            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);
        }