Skip to content

Instantly share code, notes, and snippets.

@JakeGinnivan
Created January 11, 2012 08:38
Show Gist options
  • Save JakeGinnivan/1593739 to your computer and use it in GitHub Desktop.
Save JakeGinnivan/1593739 to your computer and use it in GitHub Desktop.
[Fact]
public async Task can_recover_buyback()
{
//arrange
var buybackId = Guid.NewGuid();
InitialiseViewModel(true, buybackId);
_contractService.GetContract(buybackId).Returns(new CustomerBuybackDto { ContractItems = new ObservableCollection<ContractItemDto>() });
_buybackService.RecoverAsync(buybackId).Returns(TaskEx.Run(() => { }));
_uiService.AddResult(MessageBoxResult.Yes);
//act
await _viewModelUnderTest.RecoverCommand.ExecuteAsync(null);
//assert
_buybackService.Received().RecoverAsync(buybackId);
}
//This line, I dont want :P
_buybackService.RecoverAsync(buybackId).Returns(TaskEx.Run(() => { }));
// RecoverAsync returns Task, which is basically the void of the async/await world.
// Also have some wcf calls we have moved from IService to IServiceAsync, then it fails because IService automapped the response, Async returns Task<TResponse>, and returns null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment