예제 #1
0
        public void Init()
        {
            _campaignSalesAreaList.Add("TCN91");
            _campaignSalesArea           = _campaignSalesAreaList[0];
            _targetStrikeWeightStartDate = new DateTime(2018, 1, 1, 0, 0, 0);
            _targetStrikeWeightEndDate   = new DateTime(2018, 1, 10, 0, 0, 0);
            _recommendation1             = new Mock <Recommendation>();
            _recommendation2             = new Mock <Recommendation>();
            _rec1Rating     = 10;
            _rec2Rating     = 5;
            _rec1Action     = "B";                  //this is a booking and is to be added to the total
            _rec2Action     = "C";                  //this is a cancellation and is to be subtracted from the total
            _rec1Length     = NodaTime.Duration.FromSeconds(15);
            _rec2Length     = NodaTime.Duration.FromSeconds(30);
            _timeslice1From = "00:00";
            _timeslice1To   = "01:00";
            _timeslice2From = "06:00";
            _timeslice2To   = "08:00";
            _recommendationsTotalForDayPart = 0;

            _dayPart = new DayPartModel()
            {
                DesiredPercentageSplit = 0,
                CurrentPercentageSplit = 10,
                Timeslices             = new List <TimesliceModel>()
                {
                    new TimesliceModel()
                    {
                        FromTime = _timeslice1From, ToTime = _timeslice1To, DowPattern = new List <string>()
                        {
                            "Mon", "Tues", "Wed"
                        },
                    },
                    new TimesliceModel()
                    {
                        FromTime = _timeslice2From, ToTime = _timeslice2To, DowPattern = new List <string>()
                        {
                            "Mon", "Tues", "Wed"
                        },
                    }
                }
            };

            _ = _recommendation1.Setup(r => r.SpotRating).Returns(_rec1Rating);
            _ = _recommendation1.Setup(r => r.Action).Returns(_rec1Action);
            _ = _recommendation1.Setup(r => r.StartDateTime).Returns(_targetStrikeWeightStartDate);
            _ = _recommendation1.Setup(r => r.SalesArea).Returns(_campaignSalesArea);

            _ = _recommendation2.Setup(r => r.SpotRating).Returns(_rec2Rating);
            _ = _recommendation2.Setup(r => r.Action).Returns(_rec2Action);
            _ = _recommendation2.Setup(r => r.StartDateTime).Returns(_targetStrikeWeightStartDate);
            _ = _recommendation2.Setup(r => r.SalesArea).Returns(_campaignSalesArea);
        }
        public static Dictionary <NodaTime.Duration, decimal> ProjectRatingsForCampaignDayPart(DayPartModel dayPart, IEnumerable <Recommendation> recommendations,
                                                                                               DateTime startDate, DateTime endDate, List <string> salesAreaList)
        {
            Dictionary <NodaTime.Duration, decimal> lenRatingList = new Dictionary <NodaTime.Duration, decimal>();

            dayPart.Timeslices.ForEach(ts =>
            {
                ProjectedCampaignTimesliceChange(recommendations, startDate, endDate, ts, salesAreaList, ref lenRatingList);
            });

            return(lenRatingList);
        }