示例#1
0
        public SalesAreaProfile()
        {
            CreateMap <Tuple <SalesArea, IReadOnlyCollection <Demographic> >, AgSalesAreaPtr>()
            .ForMember(ags => ags.ShortName, exp => exp.MapFrom(s => s.Item1.ShortName))
            .ForMember(ags => ags.CurrencyCode, exp => exp.MapFrom(s => s.Item1.CurrencyCode))
            .ForMember(ags => ags.SalesAreaNo, exp => exp.MapFrom(s => s.Item1.CustomId))
            .ForMember(ags => ags.RatingSalesAreaNo, exp => exp.MapFrom(s => s.Item1.CustomId))
            .ForMember(ags => ags.SalesAreaNoRequired, exp => exp.MapFrom(s => s.Item1.CustomId))
            .ForMember(ags => ags.BaseDemoNo,
                       exp => exp.MapFrom(
                           s => (s.Item2.FirstOrDefault(m => m.ExternalRef.Equals(s.Item1.BaseDemographic1)).Id)))
            .ForMember(ags => ags.BaseDemoNo2,
                       exp => exp.MapFrom(
                           s => (s.Item2.FirstOrDefault(m => m.ExternalRef.Equals(s.Item1.BaseDemographic2)).Id)))
            .ForMember(ags => ags.StartTime,
                       exp => exp.MapFrom(
                           s => AgConversions.ToAgTimeAsHHMMSS(s.Item1.StartOffset.ToTimeSpan())))
            .ForMember(ags => ags.NbrHours,
                       exp => exp.MapFrom(
                           s => Convert.ToInt32(s.Item1.DayDuration.BclCompatibleTicks / NodaConstants.TicksPerHour)));

            CreateMap <Tuple <string, List <SalesArea> >, AgSalesArea>()
            .ForMember(d => d.SalesArea, m => m.MapFrom(args => args.Item2.Any(s => s.Name == args.Item1) ? args.Item2.First(s => s.Name == args.Item1).CustomId : -1));

            CreateMap <object, AgSalesAreaRef>().ForMember(ags => ags.SalesAreaNo, exp => exp.MapFrom(i => Convert.ToInt32(i)));

            CreateMap <SalesArea, SalesAreaModel>().ForMember(salesAreaModel => salesAreaModel.Uid, expression => expression.MapFrom(salesArea => salesArea.Id));

            CreateMap <CreateSalesAreaModel, SalesArea>();
        }
示例#2
0
        public void PerformPassDefaultDataPopulation_ShouldReturnRunDateTimeValues_WhenPassDateTimeValuesIsNull()
        {
            DateTime?    nulldate     = null;
            TimeSpan?    nullTimeSpan = null;
            const string nullString   = null;

            //Arrange
            _passes[0].PassSalesAreaPriorities = _fixture.Build <PassSalesAreaPriority>()
                                                 .With(r => r.EndDate, nulldate)
                                                 .With(r => r.StartDate, nulldate)
                                                 .With(r => r.StartTime, nullTimeSpan)
                                                 .With(r => r.EndTime, nullTimeSpan)
                                                 .With(r => r.DaysOfWeek, nullString)
                                                 .Create();

            var expected = _run;

            //Act
            var result = _passes.ToAgPassDefault(_scenario, _run, _tenantSettings);

            //Assert
            var valueToTest =
                expected.EndTime.Minutes == 0 &&
                expected.EndTime.Hours == 0 &&
                expected.EndTime.Seconds == 0
                    ? "995959"
                    : AgConversions.ToAgTimeAsHHMMSS(expected.EndTime);

            _ = expected.EndDate.ToString("yyyyMMdd").Should().Be(result?.AgPassDefaults[0]?.EndDate, null);
            _ = expected.StartDate.ToString("yyyyMMdd").Should().Be(result?.AgPassDefaults[0]?.StartDate, null);
            _ = valueToTest.Should().Be(result?.AgPassDefaults[0]?.EndTime, null);
            _ = AgConversions.ToAgTimeAsHHMMSS(expected.StartTime).Should().Be(result?.AgPassDefaults[0]?.StartTime, null);
            _ = AgConversions.ToAgDaysAsInt(_defaultDaysOfWeek).Should().Be(result?.AgPassDefaults[0]?.DaysOfWeek, null);
        }
示例#3
0
        public SponsoredDayPartProfile()
        {
            CreateMap <SponsoredDayPart, AgSponsorshipDayPart>()
            .ForMember(d => d.StartTime, m => m.MapFrom(src => AgConversions.ToAgTimeAsHHMMSS(src.StartTime)))
            .ForMember(d => d.EndTime, m => m.MapFrom(src => AgConversions.ToAgTimeAsHHMMSS(src.EndTime)))
            .ForMember(d => d.Days, m => m.MapFrom(src => AgConversions.ToAgDaysAsInt(src.DaysOfWeek)));

            CreateMap <CreateSponsoredDayPartModel, SponsoredDayPart>()
            .ForMember(d => d.EndTime, m => m.PreCondition(src => src.EndTime.HasValue));
        }
示例#4
0
        public TenantSettingsProfile()
        {
            CreateMap <TenantSettings, TenantSettingsEntity>()
            .ForMember(dest => dest.PeakStartTime,
                       opt => opt.MapFrom(src => AgConversions.ParseHHMMSSFormat(src.PeakStartTime)))
            .ForMember(dest => dest.PeakEndTime,
                       opt => opt.MapFrom(src => AgConversions.ParseHHMMSSFormat(src.PeakEndTime)))
            .ForMember(dest => dest.MidnightStartTime,
                       opt => opt.MapFrom(src => AgConversions.ParseTotalHHMMSSFormat(src.MidnightStartTime, true)))
            .ForMember(dest => dest.MidnightEndTime,
                       opt => opt.MapFrom(src => AgConversions.ParseTotalHHMMSSFormat(src.MidnightEndTime, true)))
            .ReverseMap()
            .ForMember(dest => dest.PeakStartTime,
                       opt => opt.MapFrom(src => AgConversions.ToAgTimeAsHHMMSS(src.PeakStartTime)))
            .ForMember(dest => dest.PeakEndTime,
                       opt => opt.MapFrom(src => AgConversions.ToAgTimeAsHHMMSS(src.PeakEndTime)))
            .ForMember(dest => dest.MidnightStartTime,
                       opt => opt.MapFrom(src => AgConversions.ToAgTimeAsTotalHHMMSS(src.MidnightStartTime)))
            .ForMember(dest => dest.MidnightEndTime,
                       opt => opt.MapFrom(src => AgConversions.ToAgTimeAsTotalHHMMSS(src.MidnightEndTime)));

            CreateMap <RunRestrictions, RunRestrictionsEntity>()
            .ReverseMap();

            CreateMap <MinimumRunSizeDocumentRestriction, MinimumRunSizeDocumentRestrictionEntity>()
            .ReverseMap();

            CreateMap <MinimumDocumentRestriction, MinimumDocumentRestrictionEntity>()
            .ReverseMap();

            CreateMap <RunEventSettings, RunEventSettingsEntity>()
            .ReverseMap();

            CreateMap <HTTPNotificationSettings, HTTPNotificationSettingsEntity>()
            .ReverseMap();

            CreateMap <HTTPMethodSettings, HTTPMethodSettingsEntity>()
            .ReverseMap();

            CreateMap <Feature, FeatureEntity>()
            .ForMember(dest => dest.IdValue, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Id, opt => opt.Ignore())
            .ReverseMap()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.IdValue))
            .ForMember(dest => dest.Settings,
                       opt => opt.MapFrom(src => src.Settings.ToDictionary(x => x.Key, x => (object)x.Value)))
            ;

            CreateMap <WebhookSettings, WebhookSettingsEntity>()
            .ReverseMap();
        }
示例#5
0
        public void PerformPassDefaultDataPopulation_ShouldReturnPassDateTimeValues_WhenPassDateTimeValuesIsNotNull()
        {
            //Arrange
            var expected = _fixture.Build <PassSalesAreaPriority>()
                           .With(r => r.EndDate, DateTime.Now.AddDays(1))
                           .With(r => r.StartDate, DateTime.Now)
                           .With(r => r.StartTime, new TimeSpan(21, 30, 0))
                           .With(r => r.EndTime, new TimeSpan(22, 30, 0))
                           .With(r => r.DaysOfWeek, "1000000")
                           .Create();

            _passes[0].PassSalesAreaPriorities = expected;

            //Act
            var result = _passes.ToAgPassDefault(_scenario, _run, _tenantSettings);

            //Assert
            _ = expected?.EndDate?.ToString("yyyyMMdd").Should().Be(result?.AgPassDefaults[0]?.EndDate, null);
            _ = expected.StartDate?.ToString("yyyyMMdd").Should().Be(result?.AgPassDefaults[0]?.StartDate, null);
            _ = AgConversions.ToAgTimeAsHHMMSS((TimeSpan)expected.EndTime).Should().Be(result?.AgPassDefaults[0]?.EndTime, null);
            _ = AgConversions.ToAgTimeAsHHMMSS((TimeSpan)expected.StartTime).Should().Be(result?.AgPassDefaults[0]?.StartTime, null);
            _ = AgConversions.ToAgDaysAsInt(expected.DaysOfWeek).Should().Be(result?.AgPassDefaults[0]?.DaysOfWeek, null);
        }