Resolved Assigment regarding Unit Test Creation

blackberiz

New member
Joined
Feb 19, 2022
Messages
1
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:

I would need assistance in solving this assignment since the deadline is approaching and due to me having covid I wasn't able to go over this section. Any help on how to do this would be greatly appriciated.

Assigment Code:
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):");
            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;
            }
        }

    }

}
 
You should have started 3 weeks ago like @loluros :
 
Back
Top Bottom