Test Double Code C++
// Test to add - this should fail
TEST_METHOD(checkExternalTemperatureConverted) {
Converter tc;
Assert::AreEqual(32.0, tc.externalToFahrenheit(), .02);
}
// class to add
#include <cstdlib>
class ExternalTemperatureGetter {
public:
double getTemperature() {
double value = rand() % 100;
return value;
}
};
// Method to add to Converter:
ExternalTemperatureGetter* etc =
new ExternalTemperatureGetter();
public:
double externalToFahrenheit() {
double temp = etc->getTemperature();
return toFahrenheit(temp);
}
~Converter() {
delete etc;
}