Question: In C# , no top level statements Using the following class, create a testing project in Visual Studio. Create a a CalculatorTest class and write

In C#, no top level statements
Using the following class, create a testing project in Visual Studio. Create a a CalculatorTest class and write the methods to test each function.
Use the MSTest framework to create your test against the class Calculator. You should test each method. You should turn in one file that follows the naming convention:
All assignments will be ,cs files; all files should follow this convention: _A_<*file sequence*>
Create one method per test.
using System;
public class Calculator
{
// Adds two numbers together and returns the result.
public double Add(double a, double b)
{
return a + b;
}
// Subtracts the second number from the first and returns the result.
public double Subtract(double a, double b)
{
return a - b;
}
// Multiplies two numbers together and returns the result.
public double Multiply(double a, double b)
{
return a * b;
}
// Divides the first number by the second and returns the result.
// Throws DivideByZeroException if the divisor is zero.
public double Divide(double a, double b)
{
if (b ==0)
throw new DivideByZeroException("Division by zero is not allowed.");
return a / b;
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!