public async Task GetPersonByIdReturnsNullIfEntityDoesntExist() { // Act var id = Guid.NewGuid(); var query = ConstructQuery(id); var response = await _classUnderTest.GetPersonByIdAsync(query).ConfigureAwait(false); // Assert response.Should().BeNull(); _logger.VerifyExact(LogLevel.Debug, $"Calling IDynamoDBContext.LoadAsync for id {id}", Times.Once()); }
public void GetPersonByIdExceptionThrow() { // Arrange var mockDynamoDb = new Mock <IDynamoDBContext>(); _classUnderTest = new DynamoDbGateway(mockDynamoDb.Object, _mockUpdater.Object, _logger.Object); var id = Guid.NewGuid(); var query = ConstructQuery(id); var exception = new ApplicationException("Test exception"); mockDynamoDb.Setup(x => x.LoadAsync <PersonDbEntity>(id, default)) .ThrowsAsync(exception); // Act Func <Task <Person> > func = async() => await _classUnderTest.GetPersonByIdAsync(query).ConfigureAwait(false); // Assert func.Should().Throw <ApplicationException>().WithMessage(exception.Message); mockDynamoDb.Verify(x => x.LoadAsync <PersonDbEntity>(id, default), Times.Once); _logger.VerifyExact(LogLevel.Debug, $"Calling IDynamoDBContext.LoadAsync for id {id}", Times.Once()); }