public void BracketWithWhitespaceLastTen_ConvertFromAnotherFormatsTest(string insertPhone) { var phoneFormatter = new PhoneFormatter(PhoneFormat.BracketWithWhitespaceLastTen); var result = phoneFormatter.FormatString(insertPhone); Assert.That(result, Is.EqualTo("(812) 309 - 80 - 89")); }
public void RussiaOnlyShort_ConvertFromAnotherFormatsTest(string insertPhone) { var phoneFormatter = new PhoneFormatter(PhoneFormat.RussiaOnlyShort); var result = phoneFormatter.FormatString(insertPhone); Assert.That(result, Is.EqualTo("+78123098089")); }
public void BracketWithWhitespaceLastTen_ConvertFromAnotherFormatsTest1(string insertPhone, string result) { var phoneFormatter = new PhoneFormatter(PhoneFormat.BracketWithWhitespaceLastTen); var _result = phoneFormatter.FormatString(insertPhone); Assert.That(_result, Is.EqualTo(result)); }
public void RussiaOnlyHyphenated_ConvertFromAnotherFormatsTest(string insertPhone) { var phoneFormatter = new PhoneFormatter(PhoneFormat.RussiaOnlyHyphenated); var result = phoneFormatter.FormatString(insertPhone); Assert.That(result, Is.EqualTo("+7-812-309-80-89")); }
public SmsSendPanelView( ICommonServices commonServices, ISmsPaymentRepository smsPaymentRepository, IFastPaymentRepository fastPaymentRepository, IFastPaymentParametersProvider fastPaymentParametersProvider) { if (commonServices == null) { throw new ArgumentNullException(nameof(commonServices)); } _smsPaymentRepository = smsPaymentRepository ?? throw new ArgumentNullException(nameof(smsPaymentRepository)); _fastPaymentRepository = fastPaymentRepository ?? throw new ArgumentNullException(nameof(fastPaymentRepository)); _fastPaymentParametersProvider = fastPaymentParametersProvider ?? throw new ArgumentNullException(nameof(fastPaymentParametersProvider)); var currentPermissionService = commonServices.CurrentPermissionService; _interactiveService = commonServices.InteractiveService; _phoneFormatter = new PhoneFormatter(PhoneFormat.BracketWithWhitespaceLastTen); Build(); _orderPermissionResult = currentPermissionService.ValidateEntityPermission(typeof(Order)); _canSendSmsForAdditionalOrderStatuses = currentPermissionService.ValidatePresetPermission("can_send_sms_for_additional_order_statuses"); _canSendSmsForPayFromYookassa = currentPermissionService.ValidatePresetPermission("can_send_sms_for_pay_from_yookassa"); _canSendSmsForPayFromSbpByCard = currentPermissionService.ValidatePresetPermission("can_send_sms_for_pay_from_sbp_by_card"); Configure(); }
public void RussiaOnlyHyphenated_RemoveExtraDigitsTest() { var phoneFormatter = new PhoneFormatter(PhoneFormat.RussiaOnlyHyphenated); var result = phoneFormatter.FormatString("+700011122334455"); Assert.That(result, Is.EqualTo("+7-000-111-22-33")); }
public PhoneBinding(UITextField target) : base(target) { _phoneFormatter = new PhoneFormatter() { FireValueChanged = this.FireValueChanged }; }
public void RussiaOnlyHyphenated_CursorKeepLocation3Test() { var phoneFormatter = new PhoneFormatter(PhoneFormat.RussiaOnlyHyphenated); //Курсор //df r881230|98089 int pos = 10; phoneFormatter.FormatString("df r88123098089", ref pos); //+7-812-30|9-80-89 Assert.That(pos, Is.EqualTo(9)); }
private static void FormatPhoneNumbers() { IEnumerable <string> lines = File.ReadLines(@"InputData/input.4.in"); foreach (var(line, index) in lines.WithIndex()) { FeedBackPrinter.PrintInputPhone(phoneNumber: line, phoneNumberIndexOnList: index); string formattedPhone = PhoneFormatter.GetFormattedPhone(line); FeedBackPrinter.PrintOutputPhone(formattedPhone); } }
public void RussiaOnlyHyphenated_CursorKeepLocation1Test() { var phoneFormatter = new PhoneFormatter(PhoneFormat.RussiaOnlyHyphenated); //Курсор //+78123098|089 int pos = 9; phoneFormatter.FormatString("+78123098089", ref pos); //+7-812-309-8|0-89 Assert.That(pos, Is.EqualTo(12)); }
public void RussiaOnlyHyphenated_CursorOnEndTest() { var phoneFormatter = new PhoneFormatter(PhoneFormat.RussiaOnlyHyphenated); int pos = 1; phoneFormatter.FormatString("8", ref pos); Assert.That(pos, Is.EqualTo(4)); pos = 5; phoneFormatter.FormatString("+7812", ref pos); Assert.That(pos, Is.EqualTo(6)); pos = 7; phoneFormatter.FormatString("+7-8123", ref pos); Assert.That(pos, Is.EqualTo(8)); }
/// <summary> /// Formats the specified string as a phone number, varying according to the culture. /// </summary> /// <param name="phone">The phone number to format.</param> /// <returns></returns> public string FormatPhone(string phone) { if (string.IsNullOrEmpty(phone)) { return(string.Empty); } if (phone.Length <= 3) { return(phone); } if (phone.IndexOfAny(new[] { '(', '-', '.' }) != -1) { return(phone); } var formatter = new PhoneFormatter(); return(formatter.Format(phone)); }
public static void ShouldFormatNotGeographicPhone(string input, string output) { string result = PhoneFormatter.GetFormattedPhone(input); Assert.Equal(result, output); }
/// <summary>Force l'instantiation du formatteur de numéro.</summary> /// <remarks> /// Normalement, un pattern de factory avec les informations /// serait plus approprié, mais, dans un but de simplification, /// on constructeur statique avec un formatteur static fait la job. /// </remarks> static PhoneNumber() { formatter = PhoneFormatter.Create(); }
public static void ShouldNotFormatNotGeographicPhone(string input) { string result = PhoneFormatter.GetFormattedPhone(input); Assert.Equal(GetNotFoundString(input), result); }
public static void ShouldNotFormatResidentialNumbers(string phoneNumber) { string result = PhoneFormatter.GetFormattedPhone(phoneNumber); Assert.Equal(GetNotFoundString(phoneNumber), result); }
public static void ShouldFormatMobileNumbers(string input, string output) { string result = PhoneFormatter.GetFormattedPhone(input); Assert.Equal(output, result); }
public static void ShouldNotFormatMobileNumbers(string input) { string result = PhoneFormatter.GetFormattedPhone(input); Assert.Equal(GetNotFoundString(input), result); }
public static void ShouldFormatServiceProviders(string input, string output) { string result = PhoneFormatter.GetFormattedPhone(input); Assert.Equal(result, output); }
public DataParserEmployee( PersonNames personNames, SizeService sizeService, PhoneFormatter phoneFormatter, IUserService userService = null) { AddColumnName(DataTypeEmployee.Fio, "ФИО", "Ф.И.О.", "Фамилия Имя Отчество", "Сотрудник", "Наименование" //Встречается при выгрузке из 1C ); AddColumnName(DataTypeEmployee.CardKey, "CARD_KEY", "card", "uid" ); AddColumnName(DataTypeEmployee.FirstName, "FIRST_NAME", "имя", "FIRST NAME" ); AddColumnName(DataTypeEmployee.LastName, "LAST_NAME", "фамилия", "LAST NAME" ); AddColumnName(DataTypeEmployee.Patronymic, "SECOND_NAME", "SECOND NAME", "Patronymic", "Отчество" ); AddColumnName(DataTypeEmployee.Sex, "Sex", "Gender", "Пол" ); AddColumnName(DataTypeEmployee.PersonnelNumber, "TN", "Табельный", "Таб. №", "Таб." //Если такой вариант будет пересекаться с другими полями его можно удалить. ); AddColumnName(DataTypeEmployee.Phone, "Телефон", "Номер телефона", "Тел" ); AddColumnName(DataTypeEmployee.HireDate, "Дата приема", "Дата приёма", "Принят" ); AddColumnName(DataTypeEmployee.DismissDate, "Дата увольнения", "Уволен" ); AddColumnName(DataTypeEmployee.BirthDate, "Дата рождения", "День рождения", "BirthDay" ); AddColumnName(DataTypeEmployee.Subdivision, "Подразделение" ); AddColumnName(DataTypeEmployee.Department, "Отдел", "Бригада", "Бригады" ); AddColumnName(DataTypeEmployee.Post, "Должность" ); AddColumnName(DataTypeEmployee.Growth, "Рост" ); AddColumnName(DataTypeEmployee.ShoesSize, "Обувь" ); //Разместил ближе к концу чтобы слово "размер", срабатывало только в том случае если другого не нашли. AddColumnName(DataTypeEmployee.WearSize, "Размер", "Одежда" ); this.personNames = personNames ?? throw new ArgumentNullException(nameof(personNames)); this.phoneFormatter = phoneFormatter ?? throw new ArgumentException(nameof(phoneFormatter)); this.userService = userService; this.sizeService = sizeService; }
public static void ShouldNotFormatServiceProviders(string input) { string result = PhoneFormatter.GetFormattedPhone(input); Assert.Equal(GetNotFoundString(input), result); }
/// <summary> /// Formats the specified string as a phone number, varying according to the culture. /// </summary> /// <param name="phone">The phone number to format.</param> /// <returns></returns> public string FormatPhone(string phone) { if (string.IsNullOrEmpty(phone)) { return string.Empty; } if (phone.Length <= 3) { return phone; } if (phone.IndexOfAny(new char[] {'(', '-', '.'}) != -1) { return phone; } PhoneFormatter formatter = new PhoneFormatter(); return formatter.Format(phone); }
void PhoneUpdate(XSSFWorkbook workbook, IList <WorkOrder> orders) { progressbar1.Adjustment.Value = 1; var sheet = workbook.CreateSheet("Телефоны"); //Заголовок var headerStyle = workbook.CreateCellStyle(); var headerFont = workbook.CreateFont(); headerFont.FontName = "Calibri"; headerFont.FontHeightInPoints = 11; headerFont.IsBold = true; headerStyle.SetFont(headerFont); var newDataFormat = workbook.CreateDataFormat(); var dateCellStyle = workbook.CreateCellStyle(); dateCellStyle.DataFormat = newDataFormat.GetFormat("dd.MM.yyyy"); //Ширина измеряется в количестве симвовлов * 256 sheet.SetColumnWidth(0, 20 * 256); sheet.SetColumnWidth(1, 20 * 256); sheet.SetColumnWidth(2, 20 * 256); #region параметры экспорта string[] columnTiles = new string[] { "Старый", "Новый", "Действие", }; #endregion var headerRow = sheet.CreateRow(0); for (var i = 0; i < columnTiles.Length; i++) { var cell = headerRow.CreateCell(i); cell.SetCellValue(columnTiles[i]); cell.CellStyle = headerStyle; } var PhoneFormatter = new PhoneFormatter(PhoneFormat.RussiaOnlyHyphenated); for (var row = 1; row <= orders.Count; row++) { progressbar1.Text = $"Телефон {row} из {orders.Count}"; progressbar1.Adjustment.Value++; GtkHelper.WaitRedraw(); var order = orders[row - 1]; var dataRow = sheet.CreateRow(row); var cellOld = dataRow.CreateCell(0); var cellNew = dataRow.CreateCell(1); var cellAction = dataRow.CreateCell(2); cellOld.SetCellValue(order.Phone); var formated = order.Phone != null?PhoneFormatter.FormatString(order.Phone) : order.Phone; if (formated == order.Phone) { cellAction.SetCellValue("Без изменений"); } else if (formated.Length == 16) { cellAction.SetCellValue("Отформатирован"); order.Phone = formated; UoW.Save(order); } else { cellAction.SetCellValue("Пропущен"); } cellNew.SetCellValue(order.Phone); logger.Debug($"{row} - {order.Id}"); } logger.Debug("Комит в базу"); UoW.Commit(); }