jeudi 2 juillet 2015

Controlling private method output when unit testing in C#

I'm using Nunit testing with Rhino mock for my code unit testing. I have faced following situation and can please advice me to handle this type of a situation.

public bool IsValidFile()
{
    ...
    ...
    if(IsValidCheksum(x, y))
    {
        ...
    }
    else
    {
        ...
    }
}

private bool IsValidCheksum(string pathTofile, string receivedChecksum)
{
}

When I am unit testing IsValidFile() method I want to test both scenarios where if condition is met. but since I have no control to handle the output of IsValidCheksum method it always returns false. I cannot test the true scenario.

Is there any way to force the return value of this method.

Aucun commentaire:

Enregistrer un commentaire