private ServiceHours CreateModel(ServiceHoursTypeEnum shType) { return(new ServiceHours { Id = Guid.NewGuid(), ServiceHourTypeId = shType.ToString().GetGuid(), AdditionalInformations = new HashSet <ServiceHoursAdditionalInformation>(), DailyOpeningTimes = new HashSet <DailyOpeningTime>() }); }
private IEnumerable <T> GetHoursWithOrder <T>(IEnumerable <T> openingHours, ServiceHoursTypeEnum type) where T : VmOpeningHour { int order = 0; return(openingHours.Select(x => { x.ServiceHoursType = type; x.OrderNumber = order++; return x; })); }
public static T CreateVmHoursModel <T>(ServiceHoursTypeEnum serviceHoursTypeEnum) where T : VmHours, new () { return(new T() { AdditionalInformation = "AdditionInfo", Id = Guid.Empty, ServiceHoursType = serviceHoursTypeEnum, ValidFrom = DateTimeOffset.Now.ToUnixTimeMilliseconds(), ValidTo = DateTimeOffset.Now.AddDays(1).ToUnixTimeMilliseconds(), // DailyHours = new List<VmDailyHours>() }); }
public void TranslateServiceHoursToVm(ServiceHoursTypeEnum hoursType, int dailyCount, int extraCount) { var model = CreateModel(hoursType); var list = listModelGenerator.Create(dailyCount, i => new DailyOpeningTime { DayFrom = i, From = GetTime(i, false, true), To = GetTime(i, false, false)}); list.AddRange(listModelGenerator.Create(extraCount, i => new DailyOpeningTime { DayFrom = i, From = GetTime(i, true, true), To = GetTime(i, true, false)})); model.DailyOpeningTimes = list; model.DailyOpeningTimes.Count.Should().Be(dailyCount + extraCount); var toTranslate = new List<ServiceHours> { model }; var translations = RunTranslationEntityToModelTest<ServiceHours, VmNormalHours>(translators, toTranslate); var translation = translations.First(); Assert.Equal(toTranslate.Count, translations.Count); CheckTranslation(model, translation, dailyCount, extraCount); }
public void TranslateServiceChannelServiceHourToEntity(ServiceHoursTypeEnum serviceHoursType, int dailyCount, int extraCount, bool isRange) { var model = TestHelper.CreateVmHoursModel <VmHours>(serviceHoursType); model.ServiceHoursType = serviceHoursType; model.IsDateRange = isRange; var toTranslate = new List <VmHours> { model }; var translations = RunTranslationModelToEntityTest <VmHours, ServiceHours>(translators, toTranslate, unitOfWorkMock); var translation = translations.First(); Assert.Equal(toTranslate.Count, translations.Count); CheckTranslation(model, translation, dailyCount, extraCount); }
public void TranslateServiceChannelServiceHourToEntity(ServiceHoursTypeEnum serviceHoursType, WeekDayEnum dayFrom, int dayTo) { var model = TestHelper.CreateVmHoursModel <VmSpecialHours>(serviceHoursType); model.ServiceHoursType = serviceHoursType; model.ValidFrom = DateTime.Now.ToEpochTime(); model.TimeFrom = 100; model.TimeTo = 200; var toTranslate = new List <VmSpecialHours> { model }; var translations = RunTranslationModelToEntityTest <VmSpecialHours, ServiceHours>(translators, toTranslate, unitOfWorkMock); var translation = translations.First(); Assert.Equal(toTranslate.Count, translations.Count); CheckTranslation(model, translation); }
public void TranslateServiceHoursToVm(ServiceHoursTypeEnum hoursType, bool setDateFrom, bool setDateTo, string additionalInfo) { var model = CreateModel(hoursType); model.AdditionalInformations = listModelGenerator.Create(additionalInfo == null ? 0 : 1, i => new ServiceHoursAdditionalInformation { Text = additionalInfo }); model.OpeningHoursTo = setDateFrom ? DateTime.Now : (DateTime?)null; model.OpeningHoursFrom = setDateTo ? DateTime.Now.AddDays(2) : (DateTime?)null; var toTranslate = new List <ServiceHours> { model }; var translations = RunTranslationEntityToModelTest <ServiceHours, VmHours>(translators, toTranslate); var translation = translations.First(); Assert.Equal(toTranslate.Count, translations.Count); CheckTranslation(model, translation); }
public void TranslateServiceHoursToVm(ServiceHoursTypeEnum hoursType, bool isClosed) { var model = CreateModel(hoursType); model.IsClosed = isClosed; model.DailyOpeningTimes = listModelGenerator.Create(1, i => new DailyOpeningTime { From = new TimeSpan(0, 8, 0) }); model.OpeningHoursFrom = DateTime.Now; var toTranslate = new List <ServiceHours> { model }; var translations = RunTranslationEntityToModelTest <ServiceHours, VmExceptionalHours>(translators, toTranslate); var translation = translations.First(); Assert.Equal(toTranslate.Count, translations.Count); CheckTranslation(model, translation); }
public void TranslateServiceChannelServiceHourToEntity(ServiceHoursTypeEnum serviceHoursType, int dailyCount, int extraCount, bool nonstop) { var model = TestHelper.CreateVmHoursModel<VmNormalHours>(serviceHoursType); model.ServiceHoursType = serviceHoursType; model.DailyHours = listModelGenerator.Create(dailyCount, i => new VmDailyHours { Extra = i < extraCount ? DailyHoursExtraTypes.Vissible : DailyHoursExtraTypes.Hidden }); model.DailyHours.Count.Should().Be(dailyCount); model.DailyHours.Count(x => x.Extra == DailyHoursExtraTypes.Vissible).Should().Be(extraCount); model.Nonstop = nonstop; var toTranslate = new List<VmNormalHours> { model }; var translations = RunTranslationModelToEntityTest<VmNormalHours, ServiceHours>(translators, toTranslate, unitOfWorkMock); var translation = translations.First(); Assert.Equal(toTranslate.Count, translations.Count); CheckTranslation(model, translation, dailyCount, extraCount); }
public void TranslateServiceHoursToVm(ServiceHoursTypeEnum hoursType, bool setDateFrom, bool setDateTo, string additionalInfo) { var model = CreateModel(hoursType); model.OpeningHoursFrom = DateTime.Now; model.DailyOpeningTimes.Add(new DailyOpeningTime { From = new TimeSpan(0, 10, 0, 0), To = new TimeSpan(0, 11, 0, 0), DayFrom = 0, DayTo = 1, }); var toTranslate = new List <ServiceHours> { model }; var translations = RunTranslationEntityToModelTest <ServiceHours, VmSpecialHours>(translators, toTranslate); var translation = translations.First(); Assert.Equal(toTranslate.Count, translations.Count); CheckTranslation(model, translation); }
public void TranslateServiceChannelServiceHourToEntity(ServiceHoursTypeEnum serviceHoursType, WeekDayEnum dayFrom, int dayTo) { var model = TestHelper.CreateVmHoursModel <VmExceptionalHours>(serviceHoursType); model.ServiceHoursType = serviceHoursType; // model.DailyHours = listModelGenerator.Create(dailyCount, i => // new VmDailyHours // { // Extra = i < extraCount ? DailyHoursExtraTypes.Vissible : DailyHoursExtraTypes.Hidden // }); model.TimeFrom = 100; model.TimeTo = 200; var toTranslate = new List <VmExceptionalHours> { model }; var translations = RunTranslationModelToEntityTest <VmExceptionalHours, ServiceHours>(translators, toTranslate, unitOfWorkMock); var translation = translations.First(); Assert.Equal(toTranslate.Count, translations.Count); CheckTranslation(model, translation); }
private IEnumerable <ServiceHours> GetHoursByType(ICollection <ServiceHours> openingHours, ServiceHoursTypeEnum type) { return(openingHours .Where(j => typesCache.Compare <ServiceHourType>(j.ServiceHourTypeId, type.ToString())) .OrderBy(x => x.OrderNumber) .ThenBy(x => x.Created)); }
public VmHours SetMissingValues(VmHours hour, ServiceHoursTypeEnum type) { hour.ServiceHoursType = type; return(hour); }