public void TestLoad_FromLines() { FilterDbCollection collection = null; Tuple <int, int> result = getTestCollection(out collection); Assert.AreEqual(result.Item1, 4); Assert.AreEqual(result.Item2, 1); }
private Tuple <int, int> getTestCollection(out FilterDbCollection collection) { string[] rawRuleStrings = getLineList(); collection = new FilterDbCollection(); Tuple <int, int> result = collection.ParseStoreRules(rawRuleStrings, 1).Result; return(result); }
static AdBlock() { var parser = new AbpFormatRuleParser(); var blacklist = Resources.adblock_blacklist.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); var compiledFilters = new List <Filter>(blacklist.Length); foreach (var entry in blacklist) { compiledFilters.Add(parser.ParseAbpFormattedRule(entry, 1)); } _adBlockFilters = new FilterDbCollection(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Guitarify\\AdBlock.db"), true, true); _adBlockFilters.ParseStoreRules(blacklist, 1); _adBlockFilters.FinalizeForRead(); }
public async void TestLoad_FromStream() { using (MemoryStream stream = new MemoryStream()) { using (StreamWriter writer = new StreamWriter(stream)) { var streamContent = string.Join("\r\n", getLineList()); writer.WriteLine(streamContent); } stream.Seek(0, SeekOrigin.Begin); FilterDbCollection memoryCollection = new FilterDbCollection(); var result = await memoryCollection.ParseStoreRulesFromStream(stream, 1); Assert.AreEqual(result.Item1, 4); Assert.AreEqual(result.Item2, 1); } // TODO: Devise tests for testing bloom filters and GetFiltersFromDomain }