public void ExecuteShouldInvokeCallback() { // arrange var dataItem = new object(); var execute = new Mock<Func<object, object, Task>>(); execute.Setup( f => f( It.IsAny<object>(), It.IsAny<object>() ) ).Returns( Task.FromResult( 0 ) ); var command = new AsyncDataItemCommand<object, object>( execute.Object, dataItem ); // act command.Execute(); // assert execute.Verify( f => f( dataItem, null ), Times.Once() ); }
public void CanExecuteShouldInvokeCallback() { // arrange var dataItem = new object(); var canExecute = new Mock<Func<object, object, bool>>(); canExecute.Setup( f => f( It.IsAny<object>(), It.IsAny<object>() ) ).Returns( true ); var command = new AsyncDataItemCommand<object, object>( ( i, p ) => Task.FromResult( 0 ), canExecute.Object, dataItem ); // act command.CanExecute(); // assert canExecute.Verify( f => f( dataItem, null ), Times.Once() ); }