public void ServiceLayer_DeleteTables_DataLayerException_ShouldRethrow(Mock <ITableManager> tableManagerMock, string exceptionMessage) { // Setup ServiceLayer serviceLayer = new ServiceLayer( _eventGridManager, _queueManager, tableManagerMock.Object, _log); DataCleanupParameters parameters = TestValues.GetDataCleanupParameters(); Func <Task> act = async() => await serviceLayer.DeleteTables(parameters); // Act act.Should().Throw <RequestFailedException>().WithMessage(exceptionMessage); // Verify _log.Messages.Should().HaveCount(2); _log.Messages[0].Message.Should().Be("Table deletion starting."); _log.Messages[1].Message.Should().Be("Exception encountered in DeleteTables method."); }
public async Task ServiceLayer_DeleteTables_ShouldWork(List <CloudTable> tableList) { // Setup (Mock <ITableManager> tableManagerMock, List <CloudTable> deletedTableList) = GetMockTableManager(tableList); ServiceLayer serviceLayer = new ServiceLayer( _eventGridManager, _queueManager, tableManagerMock.Object, _log); DataCleanupParameters parameters = TestValues.GetDataCleanupParameters(); // Act await serviceLayer.DeleteTables(parameters); // Verify tableManagerMock.Verify(); deletedTableList.Should().HaveCount(tableList?.Count ?? 0); deletedTableList.Should().BeEquivalentTo(tableList ?? new List <CloudTable>()); _log.Messages.Should().HaveCount(2); _log.Messages[0].Message.Should().Be("Table deletion starting."); _log.Messages[1].Message.Should().Be($"Table deletion completed! Removed {tableList?.Count ?? 0} tables."); }