Esempio n. 1
0
        public void SomeIncluded_SomeExcluded_WorksAsExpected(bool firstKeyIsIncluded)
        {
            var start = firstKeyIsIncluded ? 0 : -1;
            var input = Enumerable.Range(start, 10).ToArray();

            var filtered = CacheKeysFilter <int> .Filter(input, k => k % 2 != 0, out _);

            filtered.ToArray().Should().BeEquivalentTo(Enumerable.Range(0, 5).Select(i => i * 2));
        }
Esempio n. 2
0
        public void AllIncluded_ReturnsEmpty()
        {
            var input = Enumerable.Range(0, 10).ToArray();

            var filtered = CacheKeysFilter <int> .Filter(input, _ => false, out var pooledArray);

            filtered.ToArray().Should().BeEquivalentTo(input);
            pooledArray.Should().BeNull();
        }
Esempio n. 3
0
        public void AllExcluded_WorkAsExpected()
        {
            var input = Enumerable.Range(0, 10).ToArray();

            var filtered = CacheKeysFilter <int> .Filter(input, _ => true, out var pooledArray);

            filtered.IsEmpty.Should().BeTrue();
            pooledArray.Should().BeNull();
        }
        public void AllIncluded_WorksAsExpected()
        {
            var input = Enumerable.Range(0, 10).ToArray();

            var filtered = CacheKeysFilter <int, int> .Filter(0, input, (_, __) => false, out var pooledArray);

            filtered.ToArray().Should().BeEquivalentTo(input);
            pooledArray.Should().BeNull();
        }
        public void AllExcluded_ReturnsEmpty()
        {
            var input = Enumerable.Range(0, 10).ToArray();

            var filtered = CacheKeysFilter <int, int> .Filter(0, input, (_, __) => true, out var pooledArray);

            filtered.IsEmpty.Should().BeTrue();
            pooledArray.Should().BeNull();
        }
Esempio n. 6
0
        public void OneIncluded_WorksAsExpected(int indexOfIncluded)
        {
            var input = Enumerable.Range(0, 10).ToArray();

            var filtered = CacheKeysFilter <int> .Filter(input, k => k != indexOfIncluded, out _);

            var expected = new[] { indexOfIncluded };

            filtered.ToArray().Should().BeEquivalentTo(expected);
        }
Esempio n. 7
0
        public void OneExcluded_WorksAsExpected(int indexOfExcluded)
        {
            var input = Enumerable.Range(0, 10).ToArray();

            var filtered = CacheKeysFilter <int> .Filter(input, k => k == indexOfExcluded, out _);

            var expected = Enumerable.Range(0, 10).Where(i => i != indexOfExcluded).ToArray();

            filtered.ToArray().Should().BeEquivalentTo(expected);
        }