dimanche 28 juin 2015

How to unit test dialog interaction

I have the following class:

public class DirectoryFinder : IDirectoryFinder
{
    public string GetDirectory(string whereTo)
    {
        FolderBrowserDialog dialog = new FolderBrowserDialog {Description = whereTo};
        DialogResult result = dialog.ShowDialog();
        return result == DialogResult.OK ? dialog.SelectedPath : string.Empty;
    }
}

How would I go about verifying that it returns the correct data? eg. string.Empty or whatever was selected in the dialog depending on what the user click?

I'm using NUnit as testing framework.

Aucun commentaire:

Enregistrer un commentaire