Exemplo n.º 1
0
void MockFailure::addExpectationsAndCallHistory(const MockExpectedCallsList& expectations)
{
    message_ += "\tEXPECTED calls that did NOT happen:\n";
    message_ += expectations.unfulfilledCallsToString("\t\t");
    message_ += "\n\tACTUAL calls that did happen (in call order):\n";
    message_ += expectations.fulfilledCallsToString("\t\t");
}
Exemplo n.º 2
0
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();
}
Exemplo n.º 3
0
MockCallOrderFailure::MockCallOrderFailure(UtestShell* test, const MockExpectedCallsList& expectations) : MockFailure(test)
{
    MockExpectedCallsList expectationsForOutOfOrder;
    expectationsForOutOfOrder.addExpectations(expectations);
    expectationsForOutOfOrder.onlyKeepOutOfOrderExpectations();

    message_ = "Mock Failure: Out of order calls";
    message_ += "\n";
    addExpectationsAndCallHistory(expectationsForOutOfOrder);
}
Exemplo n.º 4
0
void MockSupport::failTestWithOutOfOrderCalls()
{
    MockExpectedCallsList expectationsList;
    expectationsList.addExpectations(expectations_);

    for(MockNamedValueListNode *p = data_.begin();p;p = p->next())
        if(getMockSupport(p))
            expectationsList.addExpectations(getMockSupport(p)->expectations_);

    MockCallOrderFailure failure(activeReporter_->getTestToFail(), expectationsList);
    clear();
    failTest(failure);
}
Exemplo n.º 5
0
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();
}
Exemplo n.º 6
0
    void checkUnexpectedNthCallMessage(unsigned int count, const char* expectedOrdinal)
    {
        MockExpectedCallsList callList;
        MockCheckedExpectedCall expCall;

        expCall.withName("bar");
        for (unsigned int i = 0; i < (count - 1); i++) {
            expCall.callWasMade(1);
            callList.addExpectedCall(&expCall);
        }

        MockUnexpectedCallHappenedFailure failure(UtestShell::getCurrent(), "bar", callList);

        SimpleString expectedMessage = StringFromFormat("Mock Failure: Unexpected additional (%s) call to function: bar\n\tEXPECTED", expectedOrdinal);
        STRCMP_CONTAINS(expectedMessage.asCharString(), failure.getMessage().asCharString());
    }
Exemplo n.º 7
0
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");
}
Exemplo n.º 8
0
MockUnexpectedCallHappenedFailure::MockUnexpectedCallHappenedFailure(UtestShell* test, const SimpleString& name, const MockExpectedCallsList& expectations) : MockFailure(test)
{
    unsigned int amountOfExpectations = expectations.amountOfExpectationsFor(name);
    if (amountOfExpectations > 0) {
        SimpleString ordinalNumber = StringFromOrdinalNumber(amountOfExpectations + 1);
        message_ = StringFromFormat("Mock Failure: Unexpected additional (%s) call to function: ", ordinalNumber.asCharString());
    } else {
        message_ = "Mock Failure: Unexpected call to function: ";
    }
    message_ += name;
    message_ += "\n";
    addExpectationsAndCallHistory(expectations);
}