I want to test some commands in my WPF project which contain user interaction needed parts.
This is the viewmodel:
class MainViewModel : ViewModelBase
{
public ICommand Export { get; private set; }
public MainViewModel()
{
Export = SynchronousCommand.Create((o) => ExportModel(o));
}
private void ExportModel(object parameter)
{
string exportPath = null;
SaveFileDialog fileDialog = new SaveFileDialog();
fileDialog.Filter = "UDPROJ (*.udproj) |*.udproj";
if (fileDialog.ShowDialog() == true)
{
exportPath = fileDialog.FileName;
}
// Other logic which should run in test...
}
}
So I want to call this Export command from a test project without calling the SaveFileDialog. My first idea was that I have to send some command parameters through parameter but I would like to ask you, is there a more elegant way (becuase I have to get the command parameters in every case where the command contains some dialog calling)?
Aucun commentaire:
Enregistrer un commentaire