コード例 #1
0
ファイル: BloomFilterTests.cs プロジェクト: belav/roslyn
        public void TestSerialization()
        {
            var stream      = new MemoryStream();
            var bloomFilter = new BloomFilter(0.001, false, new[] { "Hello, World" });

            using (var writer = new ObjectWriter(stream, leaveOpen: true))
            {
                bloomFilter.WriteTo(writer);
            }

            stream.Position = 0;

            using var reader = ObjectReader.TryGetReader(stream);
            var rehydratedFilter = BloomFilter.ReadFrom(reader);

            Assert.True(bloomFilter.IsEquivalent(rehydratedFilter));
        }
コード例 #2
0
ファイル: BloomFilterTests.cs プロジェクト: zuvys/roslyn
        public void TestSerialization2()
        {
            var stream      = new MemoryStream();
            var bloomFilter = new BloomFilter(0.001, new[] { "Hello, World" }, new long[] { long.MaxValue, -1, 0, 1, long.MinValue });

            using (var writer = new ObjectWriter(stream))
            {
                bloomFilter.WriteTo(writer);
            }

            stream.Position = 0;

            using var reader = ObjectReader.TryGetReader(stream);
            var rehydratedFilter = BloomFilter.ReadFrom(reader);

            Assert.True(bloomFilter.IsEquivalent(rehydratedFilter));
        }