public void BuildByHour_ShouldAddMissingDaysInOrder()
        {
            var configuration = new MapperConfiguration(cfg => { cfg.AddProfile <PerHourProfile>(); });
            var mapper        = new Mapper(configuration);
            var mapperHelper  = new EntityMapper(mapper);

            var perDayOfWeekFaker = new Faker <PerHourEntity>()
                                    .RuleFor(p => p.Total, f => f.Random.Int(0, 10000))
                                    .RuleFor(p => p.Day, f => f.Random.Int(1, 7))
                                    .RuleFor(p => p.Hour, f => f.Random.Int(0, 23))
                                    .RuleFor(p => p.IsIncoming, f => f.Random.Bool())
                                    .RuleFor(p => p.OutgoingTotal, f => f.Random.Int(0, 10000))
                                    .RuleFor(p => p.IncomingTotal, f => f.Random.Int(0, 10000));


            var entity = perDayOfWeekFaker.Generate();

            var entities = new List <PerHourEntity>()
            {
                entity,
            };

            var callsByHour = mapperHelper.BuildByHour <CallByHour>(entities);

            Assert.Equal(168, callsByHour.Count());
            for (var day = 1; day < 8; day++)
            {
                for (var hour = 0; hour < 24; hour++)
                {
                    Assert.NotNull(callsByHour.Find(c => c.Day == day && c.Hour == hour));
                }
            }
        }
        public void BuildByHour_ShouldMapToRecruitmentMessage()
        {
            var configuration = new MapperConfiguration(cfg => { cfg.AddProfile <PerHourProfile>(); });
            var mapper        = new Mapper(configuration);
            var mapperHelper  = new EntityMapper(mapper);

            var perHourFaker = new Faker <PerHourEntity>()
                               .RuleFor(p => p.Total, f => f.Random.Int(0, 10000))
                               .RuleFor(p => p.Day, f => f.Random.Int(1, 7))
                               .RuleFor(p => p.Hour, f => f.Random.Int(0, 23))
                               .RuleFor(p => p.IsIncoming, f => f.Random.Bool())
                               .RuleFor(p => p.OutgoingTotal, f => f.Random.Int(0, 10000))
                               .RuleFor(p => p.IncomingTotal, f => f.Random.Int(0, 10000));


            // Should have 1 complete day which needs a IsIncoming = true and an IsIncoming = false
            var entity       = perHourFaker.Generate();
            var secondEntity = perHourFaker.Generate();

            secondEntity.IsIncoming = !entity.IsIncoming;
            secondEntity.Day        = entity.Day;
            secondEntity.Hour       = entity.Hour;

            var entities = new List <PerHourEntity>()
            {
                entity,
                secondEntity
            };

            var recruitmentMessagesByHour = mapperHelper.BuildByHour <CallByHour>(entities);
            var recruitmentMessageByHour  = recruitmentMessagesByHour.First(c => c.Day == entity.Day && c.Hour == entity.Hour);

            var incomingTotal = entity.IsIncoming ? entity.Total : secondEntity.Total;
            var outgoingTotal = entity.IsIncoming ? secondEntity.Total : entity.Total;

            Assert.Equal(incomingTotal, recruitmentMessageByHour.Incoming);
            Assert.Equal(outgoingTotal, recruitmentMessageByHour.Outgoing);
            Assert.Equal(incomingTotal + outgoingTotal, recruitmentMessageByHour.Total);
        }