/// <summary> /// Field value = fieldName + symbol /// </summary> /// <param name="fieldName"></param> /// <param name="symbolType"></param> /// <param name="symbolIndex"></param> /// <param name="isForPrivateApi"></param> /// <returns></returns> public static string GetFieldValueBasedOnSymbolType(string fieldName, SameResultSymbolType symbolType, int symbolIndex, bool isForPrivateApi = true) { string symbol = string.Empty; switch (symbolType) { case SameResultSymbolType.Group1: symbol = $"{CommonConstant.Group1[symbolIndex]}"; break; case SameResultSymbolType.Group2: symbol = $"{CommonConstant.Group2[symbolIndex]}"; break; case SameResultSymbolType.Group3: symbol = $"{CommonConstant.Group3[symbolIndex]}"; break; case SameResultSymbolType.HalfWidthFullWidth: symbol = $"{CommonConstant.FullWidthSymbols[symbolIndex]}"; break; } symbol = symbol.Normalize(System.Text.NormalizationForm.FormKC); //Add an Escape character for Json! if (isForPrivateApi && (symbol == "\"" || symbol == "\\")) { symbol = "\\" + symbol; } return($"{fieldName}{symbol}"); }
private static TestCaseData AddBugTelephoneUserField(TestCaseData testcase, SameResultSymbolType symbolType, HRBCClientPrivate.API.Field.FieldType fieldType, char firstChar, char secondChar, char[] telephoneBugSymbol) { if (fieldType == HRBCClientPrivate.API.Field.FieldType.Telephone) { if (symbolType == SameResultSymbolType.HalfWidthFullWidth && (firstChar.EqualsToChars(telephoneBugSymbol) || secondChar.EqualsToChars(telephoneBugSymbol)) || symbolType == SameResultSymbolType.Group3) { testcase.SetBug("39491"); } } return(testcase); throw new NotImplementedException(); }
private int GetSymbolIndex(SameResultSymbolType symbolType) { int symbolIndex = 0; switch (symbolType) { case SameResultSymbolType.Group1: symbolIndex = Group1Index; break; case SameResultSymbolType.Group2: symbolIndex = Group2Index; break; case SameResultSymbolType.Group3: symbolIndex = Group3Index; break; case SameResultSymbolType.HalfWidthFullWidth: symbolIndex = FullWidthIndex; break; } return(symbolIndex); }
public void TestNoneTelephoneField(Enums.ResourceType resourceType, FieldType fieldType, SameResultSymbolType symbolType) { int symbolIndex = GetSymbolIndex(symbolType); string fieldName = customFields.Data[$"{resourceType}-{fieldType}"].Field.Name; Dictionary <string, object> urlParam1 = new Dictionary <string, object>() { [ResourceHelper.Partition] = AuthenticationInfoProvider.Current.DefaultPartition, ["keyword"] = KeywordHelper.GetKeywordBasedOnSymbolType(fieldName, symbolType, symbolIndex), [ResourceHelper.FieldAlias] = string.Join(",", CommonConstant.NoneTelephoneTextField[resourceType]) + $",{resourceType.ToResourceName()}.P_Id", }; ReadResponseData <XmlResource> result1 = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess(resourceType.ToResourceName(), urlParam1); Assert.That(result1, MustBe.ReadSuccess(1), "Read resource failed!"); Assert.That(result1.Items.Random().DictionaryValues[customFields.Data[$"{resourceType}-{fieldType}"].Field.ToAlias()], Does.Contain(KeywordHelper.GetFieldValueBasedOnSymbolType(fieldName, symbolType, symbolIndex, false)), "The expected field doesn't contain the expected keyword!"); Dictionary <string, object> urlParam2 = new Dictionary <string, object>() { [ResourceHelper.Partition] = AuthenticationInfoProvider.Current.DefaultPartition, ["keyword"] = KeywordHelper.GetFieldValueBasedOnSymbolType(fieldName, symbolType, symbolIndex, false), [ResourceHelper.FieldAlias] = string.Join(",", CommonConstant.NoneTelephoneTextField[resourceType]) + $",{resourceType.ToResourceName()}.P_Id", }; ReadResponseData <XmlResource> result2 = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess(resourceType.ToResourceName(), urlParam2); Assert.That(result2, MustBe.ReadSuccess(1), "Read resource failed!"); Assert.IsTrue(ResourceHelper.CompareList(result1.Items, result2.Items, $"{resourceType.ToResourceName()}.P_Id"), "Results are different!"); }
/// <summary> /// Append common content for creating resource request. /// All keyword text field will not be added /// </summary> /// <param name="content"></param> /// <param name="symbolType"></param> /// <param name="resourceType"></param> public static void AppendCommonContent(CreateRecordRequest.IContentBuilder content, SameResultSymbolType symbolType, Enums.ResourceType resourceType) { switch (resourceType) { case Enums.ResourceType.Client: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Name", "Test Client"); break; case Enums.ResourceType.Recruiter: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Name", "Test Recruiter") .Append("P_Client", new CreateRecordRequest.Reference($"{Enums.ResourceType.Client}{symbolType}")); break; case Enums.ResourceType.Job: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Position", "Test Job") .Append("P_Client", new CreateRecordRequest.Reference($"{Enums.ResourceType.Client}{symbolType}")) .Append("P_Recruiter", new CreateRecordRequest.Reference($"{Enums.ResourceType.Recruiter}{symbolType}")); break; case Enums.ResourceType.Candidate: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Name", "Test Person"); break; case Enums.ResourceType.Resume: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Candidate", new CreateRecordRequest.Reference($"{Enums.ResourceType.Candidate}{symbolType}")); break; case Enums.ResourceType.Process: List <string> processPhases = OptionFieldHelper.GetOptionList(Enums.Options.ProcessPhase); Option option = OptionFieldHelper.GetOptionItem(processPhases.First()); ulong optionId = ulong.Parse(option.Id); content .Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Client", new CreateRecordRequest.Reference($"{Enums.ResourceType.Client}{symbolType}")) .Append("P_Recruiter", new CreateRecordRequest.Reference($"{Enums.ResourceType.Recruiter}{symbolType}")) .Append("P_Job", new CreateRecordRequest.Reference($"{Enums.ResourceType.Job}{symbolType}")) .Append("P_Candidate", new CreateRecordRequest.Reference($"{Enums.ResourceType.Candidate}{symbolType}")) .Append("P_Resume", new CreateRecordRequest.Reference($"{Enums.ResourceType.Resume}{symbolType}")) .Append("P_Phase", optionId); break; case Enums.ResourceType.Sales: content.Append("P_Owner", ResourceHelper.DefaultUser); break; case Enums.ResourceType.Activity: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Title", "Test Activity") .Append("P_FromDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); break; case Enums.ResourceType.Contract: content.Append("P_Client", new CreateRecordRequest.Reference($"{Enums.ResourceType.Client}{symbolType}")) .Append("P_Name", "Test Contract"); break; } }
/// <summary> /// Keyword = fieldName + symbol /// </summary> /// <param name="fieldName"></param> /// <param name="symbolType"></param> /// <returns></returns> public static string GetKeywordBasedOnSymbolType(string fieldName, SameResultSymbolType symbolType, int symbolIndex) { switch (symbolType) { //The next index (index+1) will be chosen if it isn't greater than (Length-1). Otherwise, 0 will be chosen case SameResultSymbolType.Group1: return($"{fieldName}{CommonConstant.Group1[symbolIndex + 1 > CommonConstant.Group1.Length - 1 ? 0 : symbolIndex + 1]}");
public void TestTwoRequestSystemApplicationField(Enums.ResourceType resourceType, string fieldName, SameResultSymbolType symbolType, char firstKeyword, char secondKeyword) { string resourceName = resourceType.ToResourceName(); string fieldAlias = $"{resourceName}.{fieldName}"; string fieldValue = string.Join(",", CommonConstant.SymbolInput[symbolType]); KeywordHelper.TestTwoRequestSameResult(resourceType, fieldAlias, fieldValue, firstKeyword, secondKeyword, records, cleaner); }
/// <summary> /// Append common content for creating resource request. /// All keyword text field will not be added /// </summary> /// <param name="content"></param> /// <param name="symbolType"></param> /// <param name="resourceType"></param> public static void AppendCommonContent(CreateRecordRequest.IContentBuilder content, SameResultSymbolType symbolType, Enums.ResourceType resourceType, Dictionary <Enums.ResourceType, ulong> phaseList) { switch (resourceType) { case Enums.ResourceType.Client: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Phase", phaseList[Enums.ResourceType.Client]) .Append("P_PhaseDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); break; case Enums.ResourceType.Recruiter: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Phase", phaseList[Enums.ResourceType.Recruiter]) .Append("P_PhaseDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) .Append("P_Client", new CreateRecordRequest.Reference($"{Enums.ResourceType.Client}{symbolType}")); break; case Enums.ResourceType.Job: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Client", new CreateRecordRequest.Reference($"{Enums.ResourceType.Client}{symbolType}")) .Append("P_Phase", phaseList[Enums.ResourceType.Job]) .Append("P_PhaseDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) .Append("P_Recruiter", new CreateRecordRequest.Reference($"{Enums.ResourceType.Recruiter}{symbolType}")); break; case Enums.ResourceType.Candidate: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Phase", phaseList[Enums.ResourceType.Candidate]) .Append("P_PhaseDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); break; case Enums.ResourceType.Resume: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Phase", phaseList[Enums.ResourceType.Resume]) .Append("P_PhaseDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) .Append("P_Candidate", new CreateRecordRequest.Reference($"{Enums.ResourceType.Candidate}{symbolType}")); break; case Enums.ResourceType.Process: content .Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Client", new CreateRecordRequest.Reference($"{Enums.ResourceType.Client}{symbolType}")) .Append("P_Recruiter", new CreateRecordRequest.Reference($"{Enums.ResourceType.Recruiter}{symbolType}")) .Append("P_Job", new CreateRecordRequest.Reference($"{Enums.ResourceType.Job}{symbolType}")) .Append("P_Candidate", new CreateRecordRequest.Reference($"{Enums.ResourceType.Candidate}{symbolType}")) .Append("P_Resume", new CreateRecordRequest.Reference($"{Enums.ResourceType.Resume}{symbolType}")) .Append("P_Phase", phaseList[Enums.ResourceType.Process]); break; case Enums.ResourceType.Sales: content .Append("P_Phase", phaseList[Enums.ResourceType.Sales]) .Append("P_PhaseDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) .Append("P_Owner", ResourceHelper.DefaultUser); break; case Enums.ResourceType.Activity: content.Append("P_Owner", ResourceHelper.DefaultUser) .Append("P_Phase", phaseList[Enums.ResourceType.Activity]) .Append("P_PhaseDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) .Append("P_FromDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); break; case Enums.ResourceType.Contract: content.Append("P_Client", new CreateRecordRequest.Reference($"{Enums.ResourceType.Client}{symbolType}")); break; } }
public void TestTwoRequestUserField(Enums.ResourceType resourceType, FieldType fieldType, SameResultSymbolType symbolType, char firstKeyword, char secondKeyword) { string fieldAlias = customFields.Data[$"{resourceType}-{fieldType}"].Field.ToAlias(); string fieldValue = string.Join(",", CommonConstant.SymbolInput[symbolType]); KeywordHelper.TestTwoRequestSameResult(resourceType, fieldAlias, fieldValue, firstKeyword, secondKeyword, records, cleaner); }
private static TestCaseData AddBugUserFields(TestCaseData testcase, Enums.ResourceType resourceType, SameResultSymbolType symbolType, HRBCClientPrivate.API.Field.FieldType fieldType, char firstChar, char secondChar) { char[] telephoneBugSymbol = new char[] { }; if (resourceType == Enums.ResourceType.Client) { var clientBugChar = new char[] { ':', '/' }; if (firstChar.EqualsToChars(clientBugChar) || secondChar.EqualsToChars(clientBugChar)) { testcase.SetBug("39491"); } telephoneBugSymbol = new char[] { '(', ')', '-', '+', '-' }; testcase = AddBugTelephoneUserField(testcase, symbolType, fieldType, firstChar, secondChar, telephoneBugSymbol); } else if (resourceType == Enums.ResourceType.Process || resourceType == Enums.ResourceType.Contract || resourceType == Enums.ResourceType.Activity || resourceType == Enums.ResourceType.Candidate || resourceType == Enums.ResourceType.Job || resourceType == Enums.ResourceType.Sales) { telephoneBugSymbol = new char[] { '(', ')', '-', '+', '-' }; testcase = AddBugTelephoneUserField(testcase, symbolType, fieldType, firstChar, secondChar, telephoneBugSymbol); } else if (resourceType == Enums.ResourceType.Recruiter) { var recruiterBugChar = new char[] { '-', '-' }; if (firstChar.EqualsToChars(recruiterBugChar) || secondChar.EqualsToChars(recruiterBugChar) || symbolType == SameResultSymbolType.Group3) { testcase.SetBug("39491"); } telephoneBugSymbol = new char[] { '(', ')', '-', '+', '-' }; testcase = AddBugTelephoneUserField(testcase, symbolType, fieldType, firstChar, secondChar, telephoneBugSymbol); } else if (resourceType == Enums.ResourceType.Resume) { telephoneBugSymbol = new char[] { '-', '+', '-' }; testcase = AddBugTelephoneUserField(testcase, symbolType, fieldType, firstChar, secondChar, telephoneBugSymbol); } return(testcase); }
private static TestCaseData AddBugTelephoneField(TestCaseData testcase, string[] fieldList, SameResultSymbolType symbolType, string fieldName, char firstChar, char secondChar, char[] telephoneBugSymbol) { if (fieldName.EqualsToStrings(fieldList)) { if (symbolType == SameResultSymbolType.HalfWidthFullWidth && (firstChar.EqualsToChars(telephoneBugSymbol) || secondChar.EqualsToChars(telephoneBugSymbol)) || symbolType == SameResultSymbolType.Group3) { testcase.SetBug("39491"); } } return(testcase); }
private static TestCaseData AddBugApplicationFields(TestCaseData testcase, Enums.ResourceType resourceType, SameResultSymbolType symbolType, string fieldName, char firstChar, char secondChar) { char[] telephoneBugSymbol = new char[] { }; if (resourceType == Enums.ResourceType.Client) { var clientBugChar = new char[] { ':', '/' }; if (firstChar.EqualsToChars(clientBugChar) || secondChar.EqualsToChars(clientBugChar)) { testcase.SetBug("39491"); } telephoneBugSymbol = new char[] { '(', ')', '-', '+', '-' }; testcase = AddBugTelephoneField(testcase, CommonConstant.ApplicationTelephoneField, symbolType, fieldName, firstChar, secondChar, telephoneBugSymbol); } else if (resourceType == Enums.ResourceType.Process || resourceType == Enums.ResourceType.Contract || resourceType == Enums.ResourceType.Activity || resourceType == Enums.ResourceType.Candidate || resourceType == Enums.ResourceType.Job || resourceType == Enums.ResourceType.Sales) { telephoneBugSymbol = new char[] { '(', ')', '-', '+', '-' }; testcase = AddBugTelephoneField(testcase, CommonConstant.ApplicationTelephoneField, symbolType, fieldName, firstChar, secondChar, telephoneBugSymbol); } else if (resourceType == Enums.ResourceType.Resume) { telephoneBugSymbol = new char[] { '-', '+', '-' }; testcase = AddBugTelephoneField(testcase, CommonConstant.ApplicationTelephoneField, symbolType, fieldName, firstChar, secondChar, telephoneBugSymbol); } else { var recruiterBugChar = new char[] { '-', '-' }; if (firstChar.EqualsToChars(recruiterBugChar) || secondChar.EqualsToChars(recruiterBugChar)) { testcase.SetBug("39491"); } telephoneBugSymbol = new char[] { '(', ')', '-', '+', '-' }; testcase = AddBugTelephoneField(testcase, CommonConstant.ApplicationTelephoneField, symbolType, fieldName, firstChar, secondChar, telephoneBugSymbol); } return(testcase); }
private static TestCaseData AddBugSystemFields(TestCaseData testcase, Enums.ResourceType resourceType, SameResultSymbolType symbolType, string fieldName, char firstChar, char secondChar) { var telephoneBugSymbol = new char[] { '(', ')', '-', '+', '-' }; if (resourceType == Enums.ResourceType.Candidate) { testcase = AddBugTelephoneField(testcase, CommonConstant.TelephoneField[resourceType], symbolType, fieldName, firstChar, secondChar, telephoneBugSymbol); } else if (resourceType == Enums.ResourceType.Client) { var clientBugChar = new char[] { ':', '/' }; if (firstChar.EqualsToChars(clientBugChar) || secondChar.EqualsToChars(clientBugChar)) { testcase.SetBug("39491"); } testcase = AddBugTelephoneField(testcase, CommonConstant.TelephoneField[resourceType], symbolType, fieldName, firstChar, secondChar, telephoneBugSymbol); } else if (resourceType == Enums.ResourceType.Recruiter) { var recruiterBugChar = new char[] { '-', '-' }; if (firstChar.EqualsToChars(recruiterBugChar) || secondChar.EqualsToChars(recruiterBugChar)) { testcase.SetBug("39491"); } testcase = AddBugTelephoneField(testcase, CommonConstant.TelephoneField[resourceType], symbolType, fieldName, firstChar, secondChar, telephoneBugSymbol); } return(testcase); }