Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created November 18, 2009 16:00
Show Gist options
  • Save jfromaniello/237989 to your computer and use it in GitHub Desktop.
Save jfromaniello/237989 to your computer and use it in GitHub Desktop.
public ICommand Prueba
{
get
{
if (_prueba == null)
_prueba = new AsyncRelayCommand<object, int>(o => Proceso())
{
Preview = o => Descripcion = "procesando...",
Completed = (o, result) => Descripcion = "terminado.." + result,
BlockInteraction = true
};
return _prueba;
}
}
private static int Proceso()
{
Thread.Sleep(TimeSpan.FromSeconds(10));
return 45;
}
[TestFixture]
public class Algo
{
[Test]
public void proceso_funciona()
{
var vm = new ViewModel();
var result = ((AsyncRelayCommand<object, int>) vm.Prueba).ExecuteSync(null);
Assert.AreEqual(45, result);
}
[Test]
public void preview_funciona_ok()
{
var vm = new ViewModel();
((AsyncRelayCommand<object, int>)vm.Prueba).Preview(null);
Assert.AreEqual(vm.Descripcion, "procesando...");
}
[Test]
public void post_action_funciona_ok()
{
var vm = new ViewModel();
((AsyncRelayCommand<object, int>)vm.Prueba).Completed(null, 45);
Assert.AreEqual(vm.Descripcion, "terminado..45");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment