Ejemplo n.º 1
0
        public void ChanegMultipleGroups()
        {
            var initialPeople = Enumerable.Range(1, 10000)
                                .Select(i => new Person("Person" + i, i % 10))
                                .ToArray();

            _source.AddRange(initialPeople);

            initialPeople.GroupBy(p => p.Age)
            .ForEach(group =>
            {
                var grp = _results.Data.Items.First(g => g.Key.Equals(group.Key));
                CollectionAssert.AreEquivalent(group.ToArray(), grp.Items);
            });

            _source.RemoveMany(initialPeople.Take(15));

            initialPeople.Skip(15).GroupBy(p => p.Age)
            .ForEach(group =>
            {
                var list = _results.Data.Items.First(p => p.Key == group.Key);
                CollectionAssert.AreEquivalent(group, list.Items);
            });

            Assert.AreEqual(2, _results.Messages.Count);
            Assert.AreEqual(10, _results.Messages.First().Adds);
            Assert.AreEqual(10, _results.Messages.Skip(1).First().Replaced);
        }
Ejemplo n.º 2
0
        public void RemoveManyOrdered()
        {
            var people = _generator.Take(100).ToList();

            _source.AddRange(people);

            _source.RemoveMany(people.OrderBy(p => p, _comparer).Skip(10).Take(90));

            Assert.AreEqual(10, _results.Data.Count, "Should be 99 people in the cache");
            Assert.AreEqual(2, _results.Messages.Count, "Should be 2 update messages");

            var expectedResult = people.OrderBy(p => p, _comparer).Take(10);
            var actualResult   = _results.Data.Items;

            CollectionAssert.AreEquivalent(expectedResult, actualResult);
        }
Ejemplo n.º 3
0
        public void RemoveManyOrdered()
        {
            var people = _generator.Take(100).ToList();

            _source.AddRange(people);

            _source.RemoveMany(people.OrderBy(p => p, _comparer).Skip(10).Take(90));

            _results.Data.Count.Should().Be(10, "Should be 99 people in the cache");
            _results.Messages.Count.Should().Be(2, "Should be 2 update messages");

            var expectedResult = people.OrderBy(p => p, _comparer).Take(10);
            var actualResult   = _results.Data.Items;

            actualResult.ShouldAllBeEquivalentTo(expectedResult);
        }
        public void ChanegMultipleGroups()
        {
            var initialPeople = Enumerable.Range(1, 10000).Select(i => new Person("Person" + i, i % 10)).ToArray();

            _source.AddRange(initialPeople);

            initialPeople.GroupBy(p => p.Age).ForEach(
                group =>
            {
                var grp = _results.Data.Items.First(g => g.Key.Equals(group.Key));
                grp.Items.Should().BeEquivalentTo(group.ToArray());
            });

            _source.RemoveMany(initialPeople.Take(15));

            initialPeople.Skip(15).GroupBy(p => p.Age).ForEach(
                group =>
            {
                var list = _results.Data.Items.First(p => p.Key == group.Key);
                list.Items.Should().BeEquivalentTo(group);
            });

            _results.Messages.Count.Should().Be(2);
            _results.Messages.First().Adds.Should().Be(10);
            _results.Messages.Skip(1).First().Replaced.Should().Be(10);
        }
Ejemplo n.º 5
0
 public void Remove(IEnumerable <LogEntry> items)
 {
     try
     {
         lock (_locker)
         {
             var itemsToRemove = items as LogEntry[] ?? items.ToArray();
             _logger.Info("Removing {0} log entry items", itemsToRemove.Length);
             _source.RemoveMany(itemsToRemove);
             _logger.Info("Removed {0} log entry items", itemsToRemove.Length);
         }
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "Problem removing log entries: {0}", ex.Message);
     }
 }
Ejemplo n.º 6
0
 public override void Deselect(IEnumerable <Tag> tags)
 => selection.RemoveMany(tags);