public DynamoDbGatewayTests(MockWebApplicationFactory <Startup> appFactory) { _dbFixture = appFactory.DynamoDbFixture; _mockUpdater = new Mock <IEntityUpdater>(); _logger = new Mock <ILogger <DynamoDbGateway> >(); _classUnderTest = new DynamoDbGateway(_dbFixture.DynamoDbContext, _mockUpdater.Object, _logger.Object); }
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()); }
public void Setup() { _dynamoDb = new Mock <IDynamoDBContext>(); _classUnderTest = new DynamoDbGateway(_dynamoDb.Object); }
public void Setup() { _logCallAspectFixture = new LogCallAspectFixture(); _logger = new Mock <ILogger <DynamoDbGateway> >(); _classUnderTest = new DynamoDbGateway(DynamoDbContext, _logger.Object); }