public byte[] NewRandomKey() { byte[] randomKey; do { randomKey = Random.NextBytes(PreStoredDataKeySize); }while (KeyValueStore.Exists(randomKey)); return(randomKey); }
public KeyBytes NewRandomKey() { KeyBytes randomKey; do { randomKey = new KeyBytes(Random.NextBytes(PreStoredDataKeySize)); }while (KeyValueStore.Exists(randomKey)); return(randomKey); }
public void Exists() { foreach (var(key, _) in PreStoredDataKeys.Zip(PreStoredDataValues, ValueTuple.Create)) { Assert.True(KeyValueStore.Exists(key)); } var randomKey = NewRandomKey(); Assert.False(KeyValueStore.Exists(randomKey)); }
public void DeleteMany() { KeyBytes[] nonExistentKeys = Enumerable.Range(0, 10) .Select(_ => NewRandomKey()) .ToArray(); KeyBytes[] keys = PreStoredDataKeys .Concat(PreStoredDataKeys.Take(PreStoredDataCount / 2)) .Concat(nonExistentKeys) .ToArray(); KeyValueStore.Delete(keys); Assert.All(keys, k => Assert.False(KeyValueStore.Exists(k))); }
public void Delete() { foreach (KeyBytes key in PreStoredDataKeys) { KeyValueStore.Delete(key); Assert.False(KeyValueStore.Exists(key)); } KeyBytes nonExistent = NewRandomKey(); KeyValueStore.Delete(nonExistent); Assert.False(KeyValueStore.Exists(nonExistent)); }