Created
October 28, 2013 07:31
-
-
Save HEskandari/7192698 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[TestFixture] | |
public class MockingAsyncTask | |
{ | |
[Test] | |
public async void can_mock_interface_methods_with_task_return() | |
{ | |
var mock = NSubstitute.Substitute.For<ILongRunningOperation>(); | |
var sut = new SystemUnderTest {Operaiton = mock}; | |
await sut.Execute(); | |
mock.DoSomething().ReceivedCalls(); | |
} | |
public class SystemUnderTest | |
{ | |
public ILongRunningOperation Operaiton { get; set; } | |
public async Task Execute() | |
{ | |
await Operaiton.DoSomething(); | |
} | |
} | |
public interface ILongRunningOperation | |
{ | |
Task DoSomething(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mock.Received().DoSomething();
is what you should be using to assert that a specific method was called