private void Test(IBloomFilter bf) { var len = 10; var array = new string[len]; for (int i = 0; i < len; i++) { array[i] = Utilitiy.GenerateString(10); } Assert.All(bf.Add(array), r => Assert.True(r)); Assert.All(bf.Contains(array), r => Assert.True(r)); Assert.True(bf.All(array)); bf.Clear(); Assert.All(bf.Contains(array), r => Assert.False(r)); Assert.False(bf.All(array)); }
async Task buildTestAsync(IBloomFilter bf) { var len = 20; var array = new string[len]; for (int i = 0; i < len; i++) { array[i] = Utilitiy.GenerateString(10); } Assert.All(await bf.AddAsync(array), r => Assert.True(r)); Assert.All(await bf.ContainsAsync(array), r => Assert.True(r)); Assert.True(await bf.AllAsync(array)); await bf.ClearAsync(); Assert.All(await bf.ContainsAsync(array), r => Assert.False(r)); Assert.False(await bf.AllAsync(array)); }
public void NormalTest(HashMethod hashMethod) { var bf = FilterRedisBuilder.Build <string>("localhost", "NormalTest", 10000, 0.01, hashMethod); var len = 10; var array = new string[len]; for (int i = 0; i < len; i++) { array[i] = Utilitiy.GenerateString(10); } Assert.All(bf.Add(array), r => Assert.True(r)); Assert.All(bf.Contains(array), r => Assert.True(r)); Assert.True(bf.All(array)); bf.Clear(); Assert.All(bf.Contains(array), r => Assert.False(r)); Assert.False(bf.All(array)); }
public async Task NormalTestAsync(HashMethod hashMethod) { var bf = FilterRedisBuilder.Build("localhost", "NormalTestAsync", 10000, 0.01, hashMethod); var len = 10; var array = new string[len]; for (int i = 0; i < len; i++) { array[i] = Utilitiy.GenerateString(10); } Assert.All(await bf.AddAsync(array), r => Assert.True(r)); Assert.All(await bf.ContainsAsync(array), r => Assert.True(r)); Assert.True(await bf.AllAsync(array)); await bf.ClearAsync(); Assert.All(await bf.ContainsAsync(array), r => Assert.False(r)); Assert.False(await bf.AllAsync(array)); }