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

            var perDayOfWeekFaker = new Faker <PerDayOfWeekEntity>()
                                    .RuleFor(p => p.Total, f => f.Random.Int(0, 10000))
                                    .RuleFor(p => p.DayOfWeek, f => f.PickRandom <DayOfWeekEnum>())
                                    .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 <PerDayOfWeekEntity>()
            {
                entity,
            };

            var callsByDayOfWeek = mapperHelper.BuildByDayOfWeek <CallByDayOfWeek>(entities);

            Assert.Equal(7, callsByDayOfWeek.Count());
            Assert.Equal(Enum.GetName(typeof(DayOfWeekEnum), DayOfWeekEnum.Sunday), callsByDayOfWeek[0].DayOfWeek);
            Assert.Equal(Enum.GetName(typeof(DayOfWeekEnum), DayOfWeekEnum.Monday), callsByDayOfWeek[1].DayOfWeek);
            Assert.Equal(Enum.GetName(typeof(DayOfWeekEnum), DayOfWeekEnum.Tuesday), callsByDayOfWeek[2].DayOfWeek);
            Assert.Equal(Enum.GetName(typeof(DayOfWeekEnum), DayOfWeekEnum.Wednesday), callsByDayOfWeek[3].DayOfWeek);
            Assert.Equal(Enum.GetName(typeof(DayOfWeekEnum), DayOfWeekEnum.Thursday), callsByDayOfWeek[4].DayOfWeek);
            Assert.Equal(Enum.GetName(typeof(DayOfWeekEnum), DayOfWeekEnum.Friday), callsByDayOfWeek[5].DayOfWeek);
            Assert.Equal(Enum.GetName(typeof(DayOfWeekEnum), DayOfWeekEnum.Saturday), callsByDayOfWeek[6].DayOfWeek);
        }
        public void BuildByDayOfWeek_ShouldMapToRide()
        {
            var configuration = new MapperConfiguration(cfg => { cfg.AddProfile <PerDayOfWeekProfile>(); });
            var mapper        = new Mapper(configuration);
            var mapperHelper  = new EntityMapper(mapper);

            var perDayOfWeekFaker = new Faker <PerDayOfWeekEntity>()
                                    .RuleFor(p => p.Total, f => f.Random.Int(0, 10000))
                                    .RuleFor(p => p.DayOfWeek, f => f.PickRandom <DayOfWeekEnum>())
                                    .RuleFor(p => p.IsIncoming, f => f.Random.Bool())
                                    .RuleFor(p => p.OutgoingTotal, f => null)
                                    .RuleFor(p => p.IncomingTotal, f => null);


            var entity = perDayOfWeekFaker.Generate();

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

            var ridesByDayOfWeek = mapperHelper.BuildByDayOfWeek <RideByDayOfWeek>(entities);
            var rideDayOfWeek    = ridesByDayOfWeek.First(c => c.DayOfWeek == Enum.GetName(typeof(DayOfWeekEnum), entity.DayOfWeek));

            Assert.Equal(entity.Total, rideDayOfWeek.Total);
        }
        public void BuildByDayOfWeek_ShouldMapToMessage()
        {
            var configuration = new MapperConfiguration(cfg => { cfg.AddProfile <PerDayOfWeekProfile>(); });
            var mapper        = new Mapper(configuration);
            var mapperHelper  = new EntityMapper(mapper);

            var perDayOfWeekFaker = new Faker <PerDayOfWeekEntity>()
                                    .RuleFor(p => p.Total, f => f.Random.Int(0, 10000))
                                    .RuleFor(p => p.DayOfWeek, f => f.PickRandom <DayOfWeekEnum>())
                                    .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       = perDayOfWeekFaker.Generate();
            var secondEntity = perDayOfWeekFaker.Generate();

            secondEntity.IsIncoming = !entity.IsIncoming;
            secondEntity.DayOfWeek  = entity.DayOfWeek;

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

            var messagesByDayOfWeek = mapperHelper.BuildByDayOfWeek <MessageByDayOfWeek>(entities);
            var messageDayOfWeek    = messagesByDayOfWeek.First(c => c.DayOfWeek == Enum.GetName(typeof(DayOfWeekEnum), entity.DayOfWeek));

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

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