public void CommonCase()
        {
            var keeperFactory = new AverageKeeperFactoryMock1();
            var source        = GenerateStorage;

            var averageCounter = new AllAverageGetter(keeperFactory);
            var result         = averageCounter.Calculate(source);

            Assert.Equal(8, result.Keys.Count);
            var expectedTuples = source.GroupBy(e => e.Country).SelectMany(e => e.Select(ee => ee.Age).Distinct().Select(ee => new Tuple <string, int>(e.Key, ee)));

            Assert.True(expectedTuples.SequenceEqual(result.Keys));

            foreach (var iPair in expectedTuples)
            {
                var selection = source.Where(e => e.Country == iPair.Item1 && e.Age == iPair.Item2);
                Assert.Equal(selection.Sum(e => e.GrossSalary) / selection.Count(), result[iPair]);
            }

            var keepers = keeperFactory.RequestedKeepers.Select(e => new KeeperMockDescription
            {
                IncomingValues      = e.IncomingValues,
                LastRequestedAnswer = e.LastRequestedAnswer,
                RequestsCount       = e.RequestsCount
            }
                                                                );
            var expectedKeeperd = expectedTuples.Select(e => new KeeperMockDescription
            {
                IncomingValues      = source.Where(ee => ee.Country == e.Item1 && ee.Age == e.Item2).Select(ee => ee.GrossSalary),
                LastRequestedAnswer = source.Where(ee => ee.Country == e.Item1 && ee.Age == e.Item2).Select(ee => ee.GrossSalary).Sum() / 3,
                RequestsCount       = 1
            });

            Assert.True(keepers.SequenceEqual(expectedKeeperd));
        }
        public void NotCallCalculate()
        {
            var keeperFactory = new AverageKeeperFactoryMock1();
            var source        = GenerateStorage;

            var averageCounter = new AllAverageGetter(keeperFactory);

            Assert.Empty(keeperFactory.RequestedKeepers);
        }
        public void EmptySource()
        {
            var keeperFactory = new AverageKeeperFactoryMock1();
            var source        = new List <Person>();

            var averageCounter = new AllAverageGetter(keeperFactory);
            var result         = averageCounter.Calculate(source);

            Assert.Empty(result.Keys);
            Assert.Empty(keeperFactory.RequestedKeepers);
        }
        static void Main(string[] args)
        {
            var source           = GenerateStorage;
            var allAverageGetter = new AllAverageGetter(new AverageKeeperFactory());
            var printer          = new PrinterToConsole();

            printer.Print(allAverageGetter.Calculate(source));


            var horisontal = new [] { "Gender", "Age" };
            var vertical   = new [] { "Country", "GrossSalary" };
            var aggregator = new Aggregator();

            var result       = aggregator.Get(source, horisontal, vertical, AggFunc);
            var groupPrinter = new Operations.Aggregation.Printing.PrinterToConsole();

            groupPrinter.Print(result, horisontal, vertical);
        }