public async Task TryGetByIdAsync_ShouldCallSyncMethod_AndReturnNull_WhenEntityIsNotFound() { // Arrange const int id = 42; FakeEntity <int> person = null; _mockInner .Setup(i => i.TryGetById(id, out person)) .Returns(false); var subject = new AsyncQueryServiceAdapter <FakeEntity <int>, int>(_mockInner.Object); // Act var result = await subject.TryGetByIdAsync(id).ConfigureAwait(false); // Assert result.Should().BeNull(); _mockInner.VerifyAll(); }
public async Task TryGetByIdAsync_ShouldCallSyncMethod_AndReturnEntity_WhenEntityIsFound() { // Arrange var entity = new FakeEntity <int> { Id = 42 }; _mockInner .Setup(i => i.TryGetById(entity.Id, out entity)) .Returns(true); var subject = new AsyncQueryServiceAdapter <FakeEntity <int>, int>(_mockInner.Object); // Act var result = await subject.TryGetByIdAsync(entity.Id).ConfigureAwait(false); // Assert result.Should().BeSameAs(entity); _mockInner.VerifyAll(); }