MockUnexpectedOutputParameterFailure::MockUnexpectedOutputParameterFailure(UtestShell* test, const SimpleString& functionName, const MockNamedValue& parameter, const MockExpectedCallsList& expectations) : MockFailure(test) { MockExpectedCallsList expectationsForFunctionWithParameterName; expectationsForFunctionWithParameterName.addExpectationsRelatedTo(functionName, expectations); expectationsForFunctionWithParameterName.onlyKeepExpectationsWithOutputParameterName(parameter.getName()); if (expectationsForFunctionWithParameterName.isEmpty()) { message_ = "Mock Failure: Unexpected output parameter name to function \""; message_ += functionName; message_ += "\": "; message_ += parameter.getName(); } else { message_ = "Mock Failure: Unexpected parameter type \""; message_ += parameter.getType(); message_ += "\" to output parameter \""; message_ += parameter.getName(); message_ += "\" to function \""; message_ += functionName; message_ += "\""; } message_ += "\n"; addExpectationsAndCallHistoryRelatedTo(functionName, expectations); message_ += "\n\tACTUAL unexpected output parameter passed to function: "; message_ += functionName; message_ += "\n"; message_ += "\t\t"; message_ += parameter.getType(); message_ += " "; message_ += parameter.getName(); }
MockExpectedParameterDidntHappenFailure::MockExpectedParameterDidntHappenFailure(UtestShell* test, const SimpleString& functionName, const MockExpectedCallsList& expectations) : MockFailure(test) { MockExpectedCallsList expectationsForFunction; expectationsForFunction.addExpectationsRelatedTo(functionName, expectations); message_ = "Mock Failure: Expected parameter for function \""; message_ += functionName; message_ += "\" did not happen.\n"; addExpectationsAndCallHistoryRelatedTo(functionName, expectations); message_ += "\n\tMISSING parameters that didn't happen:\n"; message_ += "\t\t"; message_ += expectationsForFunction.missingParametersToString(); }
void MockFailure::addExpectationsAndCallHistoryRelatedTo(const SimpleString& name, const MockExpectedCallsList& expectations) { MockExpectedCallsList expectationsForFunction; expectationsForFunction.addExpectationsRelatedTo(name, expectations); message_ += "\tEXPECTED calls that DID NOT happen related to function: "; message_ += name; message_ += "\n"; message_ += expectationsForFunction.unfulfilledCallsToString("\t\t"); message_ += "\n\tACTUAL calls that DID happen related to function: "; message_ += name; message_ += "\n"; message_ += expectationsForFunction.fulfilledCallsToString("\t\t"); }