public HomeController(IHttpContextAccessor contextAccessor, ITrackerEntryService tableService) { NullChecker.IsNotNull(contextAccessor, nameof(contextAccessor)); NullChecker.IsNotNull(tableService, nameof(tableService)); _contextAccessor = contextAccessor; _tableService = tableService; }
public TableService(ITableContext tableContext, IGithubService githubService) { NullChecker.IsNotNull(tableContext, nameof(tableContext)); NullChecker.IsNotNull(githubService, nameof(githubService)); _tableContext = tableContext; _githubService = githubService; }
public async Task <T> RetrieveEnitityAsync <T>(T entity) where T : TableEntity { if (_table == null) { await CheckForTableAsync(); } NullChecker.IsNotNull(entity, nameof(entity)); try { TableOperation retrieveOperation = TableOperation.Retrieve <T>(entity.PartitionKey, entity.RowKey); TableResult result = await _table.ExecuteAsync(retrieveOperation); _logger.LogTrace("Retrieving record from table"); var retrieveEntity = result.Result as T; return(retrieveEntity); } catch (Exception e) { _logger.LogError(e.HResult, e, "Retrieve from table failed"); throw; } }
public async Task <T> InsertOrMergeEntityAsync <T>(T entity) where T : TableEntity { if (_table == null) { await CheckForTableAsync(); } NullChecker.IsNotNull(entity, nameof(entity)); try { // Create the InsertOrReplace table operation TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(entity); // Execute the operation. TableResult result = await _table.ExecuteAsync(insertOrMergeOperation); _logger.LogTrace("Inserting record into table"); var InsertedEntity = result.Result as T; return(InsertedEntity); } catch (Exception e) { _logger.LogError(e.HResult, e, "Insert Or Merge into table failed"); throw; } }
public async Task <IEnumerable <T> > GetEntities <T>(string partitionKey) where T : ITableEntity, new() { if (_table == null) { await CheckForTableAsync(); } NullChecker.IsNotNull(partitionKey, nameof(partitionKey)); try { TableQuerySegment <T> querySegment = null; var entities = new List <T>(); var query = new TableQuery <T>().Where(TableQuery.GenerateFilterCondition(nameof(ITableEntity.PartitionKey), QueryComparisons.Equal, partitionKey)); do { querySegment = await _table.ExecuteQuerySegmentedAsync(query, querySegment?.ContinuationToken); entities.AddRange(querySegment.Results); } while (querySegment.ContinuationToken != null); return(entities); } catch (Exception e) { _logger.LogError(e.HResult, e, "Retrieve from table failed"); throw; } }
public GithubService(ILogger <GithubService> logger, IOptions <GithubConfiguration> githubConfiguration, GitHubClient client) { NullChecker.IsNotNull(logger, nameof(logger)); _logger = logger; _githubConfiguration = githubConfiguration.Value; _client = client; _client.Credentials = new Credentials(_githubConfiguration.ClientId, _githubConfiguration.ClientSecret); }
public async Task <bool> DeleteEntity <T>(T entity) where T : TableEntity { if (_table == null) { await CheckForTableAsync(); } NullChecker.IsNotNull(entity, nameof(entity)); try { TableOperation deleteOperation = TableOperation.Delete(entity); _logger.LogTrace("Deleting record from table"); TableResult result = await _table.ExecuteAsync(deleteOperation); return(result.Result != null); } catch (Exception e) { _logger.LogError(e.HResult, e, "Delete from table failed"); throw; } }
public GithubService(ILogger <GithubService> logger) { NullChecker.IsNotNull(logger, nameof(logger)); _logger = logger; }
public ProjectService(ITableContext tableContext) { NullChecker.IsNotNull(tableContext, nameof(tableContext)); _tableContext = tableContext; }
public SearchController(IGithubService githubService) { NullChecker.IsNotNull(githubService, nameof(githubService)); _githubService = githubService; }
public ProjectsController( IProjectService projectService) { NullChecker.IsNotNull(projectService, nameof(projectService)); _projectService = projectService; }
public void IsNotNull_WithArgumentValueNotNull_ShouldNotThrowArgumentNullException() { NullChecker.IsNotNull(_nonNullValue, nameof(_nonNullValue)); //The fact the testcase was executed up until here means it was successful }
public void IsNotNull_WithArgumentValueNull_ShouldThrowArgumentNullException() { var exception = Assert.Throws <ArgumentNullException>(() => NullChecker.IsNotNull(_nullValue, nameof(_nullValue))); Assert.Equal(nameof(_nullValue), exception.ParamName); }