rewrite class and method interface

nxvam
timer Asked: Sep 20th, 2014

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.


Unformatted Attachment Preview

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. 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.
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Similar Content

Related Tags

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