public async Task MaskingService_MaskAsync_WorksWithDifferentRecords() { LogRecord lrecord = new LogRecord("test", "test", "test", "test", "test"); IPAddressRecord irecord = new IPAddressRecord("test"); LogRecord lrecordMasked = (LogRecord)await _maskingService.MaskAsync(lrecord, false).ConfigureAwait(false); IPAddressRecord irecordMasked = (IPAddressRecord)await _maskingService.MaskAsync(irecord, false).ConfigureAwait(false); Assert.IsTrue(lrecordMasked.IsMasked()); Assert.IsTrue(irecordMasked.IsMasked()); try { await _mapDAO.DeleteByIdsAsync(new List <string>() { _maskingService.MaskString("test") }).ConfigureAwait(false); } catch { } }
/// <summary> /// Decrements the occurrences of the hash in the Map table. /// </summary> /// <param name="hashInput">The hash to update.</param> /// <returns>(bool) whether the function executed without exception</returns> public async Task <bool> DecrementOccurrencesAsync(string hashInput) { if (!await _mapDAO.CheckHashExistenceAsync(hashInput).ConfigureAwait(false)) { throw new ArgumentException(Constants.HashNotInTable); } MapObject mapObj = await _mapDAO.ReadByIdAsync(hashInput).ConfigureAwait(false) as MapObject; // If the new occurrences will be 0, we have to delete it from the Map table. if (mapObj.Occurrences - 1 == 0) { return(await _mapDAO.DeleteByIdsAsync(new List <string>() { hashInput }).ConfigureAwait(false)); } else { MapRecord record = new MapRecord(hashInput, occurrences: mapObj.Occurrences - 1); return(await _mapDAO.UpdateAsync(record).ConfigureAwait(false)); } }