Created
November 18, 2009 16:00
-
-
Save jfromaniello/237989 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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