4
Answers

Unit tesing - Testing method without implementation of interface

David

David

15y
3k
1
Hello!

I need a fast answer :)

I have an interface and a method.  I want to know whether i can test my method without an implementation of the interface. Any ideas? Are there any usefull things when it comes to unit testing for this kind of stuff?


public interface ICalcStrategy
{
double Calculate(double amount);
}

public static class NumberCalculation
{
public static double[] CalculateTaxes(double[] numbers, ICalcStrategy calcStrategy)
{
double[] result = new double[numbers.Length];

for (int i = 0; i < numbers.Length; i++)
result[i] = calcStrategy.Calculate(numbers[i]);

return result;
}
}

It would be great if someone could help me with this!

Answers (4)