loluros
New member
- Joined
- Jan 29, 2022
- Messages
- 4
- Programming Experience
- Beginner
How to write unit tests for testing the KwHpConverter method. It is necessary to define a larger number of test cases and try to find a test case that will end in failure. Errors that you detect in the testing process need to be corrected.
The code to test is shown down:
The code to test is shown down:
C#:
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
double result = 0;
Console.WriteLine("Please, enter value: ");
double value = double.Parse(Console.ReadLine());
Console.WriteLine("Convert to (enter kw or hp(sad)");
string convertTo = Console.ReadLine();
if(convertTo == "kw")
{
result = KwHpConverter(value, "kw");
} else
{
result = KwHpConverter(value, "hp");
}
Console.WriteLine(result);
}
private static double KwHpConverter (double inputValue, string convertTo)
{
if(convertTo == "hp")
{
return inputValue / 0.745699872;
} else
{
return inputValue * 0.745699872;
}
}
}
}
Last edited by a moderator: