rewrite class and method interface

SoccerBoss
Category:
Programming
Price: $5 USD

Question description

Introduction

You have been assigned responsibility for testing a new feature of an Amazing Calculator. This new feature multiplies two numbers together and can either be executed in process or in the cloud. The CloudService used is an off-the-shelf product and is not required to be functionally tested in isolation.

public class AmazingCalculator

{

public int multiplyMe(int a, int b, bool cloudBasedCalc)

{

var retVal = 0;

if (a == 0 || b == 0)

{

return retVal;

}

if (cloudBasedCalc)

{

return multiplyInTheCloud(a, b);

}

if (a == 1)

{

return b;

}

else if (b == 1)

{

return a;

}

for (int count = 0; count < a; count++)

{

retVal = retVal + b;

}

return retVal;

}

// Multiplies two numbers using a remote service private int multiplyInTheCloud(int a, int b)

{

CloudService cloudService = new CloudService();

int retVal = cloudService.RunCloudBasedMultiplication(a, b); return retVal;

}

}

Exercise

1.Rewrite the class and method interfaces and add additional code to make the whole class 100% branch coverage capable.


Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1823 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors