public void CustomTotalRows()
        {
            const string USD = "USD";
            const string GBP = "GBP";
            const string CHF = "CHF";

            var items = new[]
            {
                new Trade(1, GBP, 100),
                new Trade(2, GBP, 200),
                new Trade(3, GBP, 100),
                new Trade(4, GBP, 200),
                new Trade(5, USD, 100),
                new Trade(6, USD, 200),
                new Trade(7, CHF, 100),
                new Trade(8, CHF, 200),
            };

            using (var source = new SourceCache <Trade, int>(t => t.Id))
                using (var sut = new CustomTotalRows(source))
                {
                    source.AddOrUpdate(items);

                    //should be 1 grand total row, 3 sub total rows, 8 rows
                    sut.AggregatedData.Count.Should().Be(12);
                    sut.AggregatedData.Items.Count(tp => tp.Key.Type == AggregationType.GrandTotal).Should().Be(1);
                    sut.AggregatedData.Items.Count(tp => tp.Key.Type == AggregationType.SubTotal).Should().Be(3);
                    sut.AggregatedData.Items.Count(tp => tp.Key.Type == AggregationType.Item).Should().Be(8);
                    sut.AggregatedData.Items.OrderBy(tp => tp.Ticker).ShouldAllBeEquivalentTo(CustomTotalRowsExpectation(source));

                    //remove all gbp rows. should be 1 grand total row, 2 sub total rows, 4 rows
                    source.RemoveKeys(new [] { 1, 2, 3, 4 });
                    sut.AggregatedData.Items.Count(tp => tp.Key.Type == AggregationType.GrandTotal).Should().Be(1);
                    sut.AggregatedData.Items.Count(tp => tp.Key.Type == AggregationType.SubTotal).Should().Be(2);
                    sut.AggregatedData.Items.Count(tp => tp.Key.Type == AggregationType.Item).Should().Be(4);
                    sut.AggregatedData.Items.OrderBy(tp => tp.Ticker).ShouldAllBeEquivalentTo(CustomTotalRowsExpectation(source));

                    //add a previously unseen ticker - a new sub total row should have been added
                    source.AddOrUpdate(new Trade(100, "TRY", 2000));
                    sut.AggregatedData.Items.Count(tp => tp.Key.Type == AggregationType.GrandTotal).Should().Be(1);
                    sut.AggregatedData.Items.Count(tp => tp.Key.Type == AggregationType.SubTotal).Should().Be(3);
                    sut.AggregatedData.Items.Count(tp => tp.Key.Type == AggregationType.Item).Should().Be(5);
                    sut.AggregatedData.Items.OrderBy(tp => tp.Ticker).ShouldAllBeEquivalentTo(CustomTotalRowsExpectation(source));
                }
        }
 public void RemoveKeys(IEnumerable <int> keys)
 {
     _cache.RemoveKeys(keys.Select(p => p.ToString()));
 }