private string CreatePropertyFailedMessage([CanBeNull] T candidate) { var from = candidate != null ? SpecificationResultGenerator.GetTypeShortName(candidate.GetType()) : "null"; return ($"Cannot cast type [{from}] to " + $"[{SpecificationResultGenerator.GetTypeShortName(typeof(TCast))}]"); }
private string CreateFailedMessage(bool isNegation) { if (!isNegation) { return ($"Specification [{SpecificationResultGenerator.GetSpecificationShortName(_baseSpecification)}] is not satisfied by candidate"); } return ($"Specification [{SpecificationResultGenerator.GetSpecificationShortName(_baseSpecification)}] is satisfied by candidate"); }
protected string CreateTraceMessage([CanBeNull] string specificationTrace, bool result) { var message = $"{SpecificationResultGenerator.GetSpecificationShortName(this)}({specificationTrace})"; if (!result) { message += "+Failed"; } return(message); }
protected virtual string CreateTraceMessage([CanBeNull] T candidate, bool result) { var message = SpecificationResultGenerator.GetSpecificationShortName(this); if (!result) { message += "+Failed"; } return(message); }
public bool IsSatisfiedBy(T candidate, out SpecificationResult result) { var leftSpecResult = _left.IsSatisfiedBy(candidate, out var leftResult); var rightSpecResult = _right.IsSatisfiedBy(candidate, out var rightResult); var specResult = Merge(leftSpecResult, rightSpecResult); var traceModifier = new TraceMessageModifier( TraceMessageConnector, _grouping ? "({0})" : null); result = SpecificationResultGenerator.GenerateOverallSpecificationResult(specResult, traceModifier, leftResult, rightResult) ?? throw new InvalidOperationException(); return(specResult); }
public bool IsSatisfiedBy(T candidate, out SpecificationResult result) { if (_baseSpecification is INegatableValidationSpecification <T> negatableSpecification) { return(negatableSpecification.IsNotSatisfiedBy(candidate, out result)); } var specResult = !_baseSpecification.IsSatisfiedBy(candidate, out var baseSpecResult); result = SpecificationResultGenerator.GenerateOverallSpecificationResult(specResult, new TraceMessageModifier(null, "Not({0})"), baseSpecResult) ?? throw new InvalidOperationException(); return(specResult); }
private string CreateTraceMessage(bool result, bool isNegation) { var message = SpecificationResultGenerator.GetSpecificationShortName(_baseSpecification); if (!result) { message += "+Failed"; } if (isNegation) { message = $"Not{message}"; } return(message); }
public TrueMockComplexSpecification() : base(candidate => true) { TraceMessage = $"TrueMockComplexSpecification[{SpecificationResultGenerator.GetTypeShortName(typeof(T))}]"; }
protected override string CreateNegationFailedMessage(T candidate) { return($"Object is type of [{SpecificationResultGenerator.GetTypeShortName(_expected)}]"); }
public MockComplexSpecification(Expression <Func <T, bool> > expression) { _expression = expression; TraceMessage = $"MockComplexSpecification[{SpecificationResultGenerator.GetTypeShortName(typeof(T))}]"; }