/// <summary> /// Get option master /// </summary> /// <param name="fieldReader">HrbcFieldReader</param> /// <param name="fieldAlias">Field alias</param> /// <returns>Option alias</returns> public static string GetOptionMaster(HrbcFieldReader fieldReader, string fieldAlias) { var query = from t in fieldReader.Data where t.Key.ToAlias() == fieldAlias select t; var field = query.FirstOrDefault(); Assume.That(field, Is.Not.Null, "Cannot read the field {0} !", fieldAlias); Assume.That(field.Value.ContainsKey(FieldProperty.OptionMaster), "Cannot read the master option of {0} !", fieldAlias); Assume.That(field.Value[FieldProperty.OptionMaster] as string, Is.Not.Null.And.Not.Empty, "Cannot read the master option of {0} !", fieldAlias); long masterOptionId = long.Parse(field.Value[FieldProperty.OptionMaster] as string); using (var session = TestBase.PrivateAuthentication.GetPrivateSession(AuthenticationInfoProvider.Current.DefaultCompanyName, AuthenticationInfoProvider.Current.DefaultUserLogin, AuthenticationInfoProvider.Current.DefaultUserPassword)) { List <HRBCClientPrivate.Common.OptionField> select = new List <HRBCClientPrivate.Common.OptionField> { HRBCClientPrivate.Common.OptionField.Name, HRBCClientPrivate.Common.OptionField.Alias }; IRequest <GetOptionRequest, GetOptionResponse> request = (HRBCClientPrivate.API.Option.GetOptionRequest.Builder().Select(select) as HRBCClientPrivate.API.Option.GetOptionRequest.IBuilderWithSelect) .WhereIds(masterOptionId); GetOptionResponse response = session.Call(request); Assume.That(response, Is.Not.Null, "Cannot read the master option!"); Assume.That(response.OptionData, Is.Not.Null, "Cannot read the master option! OptionData of the response is null!"); Assume.That(response.OptionData.Single().Value.Alias, Is.Not.Null.And.Not.Empty, "Cannot read the master option! Option alias is null or empty!"); return($"Option.{response.OptionData.Single().Value.Alias}"); } }
public TestSearchCustomField() : base() { fixedFields = new HrbcFieldReader(new[] { "Client.P_Name", "Resume.P_CurrentSalary" }, new[] { FieldProperty.FieldType, FieldProperty.Min, FieldProperty.Max }); fixedRecords = new HrbcRecordReader(Enums.ResourceType.Client, new List <ulong> { 10001 }, () => FieldCollection.Builder().Append("Client.P_Name", "Client.P_Owner").Build()); readFields = new HrbcFieldReader(new[] { "Resume.P_CurrentSalary" }, new[] { FieldProperty.Min, FieldProperty.Max }); updateMinFields = new HrbcFieldUpdater((test, data) => new[] { CreateFieldUpdateSpecForSingleProperty((Enums.ResourceType)Enum.Parse(typeof(Enums.ResourceType), test.Parent.Properties.Get("Resource") as string, true), test.Parent.Properties.Get("Field") as string, FieldProperty.Min, data.Arguments[0]) }); updateMaxFields = new HrbcFieldUpdater((test, data) => new[] { CreateFieldUpdateSpecForSingleProperty((Enums.ResourceType)data.Arguments[0], (string)data.Arguments[1], FieldProperty.Max, data.Arguments[2]) }); customFields = new HrbcFieldCreator(Enum.GetValues(typeof(Enums.ResourceType)).Cast <Enums.ResourceType>() .SelectMany(resource => new[] { new HrbcFieldCreator.FieldSpec { Resource = resource, Key = $"{resource}-1", FieldType = Enums.FieldType.Number, Label = $"Custom Field {resource} 1" }, new HrbcFieldCreator.FieldSpec { Resource = resource, Key = $"{resource}-2", FieldType = Enums.FieldType.Number, Label = $"Custom Field {resource} 2" }, new HrbcFieldCreator.FieldSpec { Resource = resource, Key = $"{resource}-3", FieldType = Enums.FieldType.Number, Label = $"Custom Field {resource} 3" } }), new List <FieldProperty> { FieldProperty.Name }); records = new HrbcRecordCreator(() => ResourceRequest.CreateRecords() .Append(ResourceId.Client, content => content.Append("P_Name", "Record 1").Append("P_Owner", 1).Append(customFields.Data["Client-1"].Name, 10), "Client 10") .Append(ResourceId.Client, content => content.Append("P_Name", "Record 2").Append("P_Owner", 1).Append(customFields.Data["Client-1"].Name, 20), "Client 20") .Append(ResourceId.Client, content => content.Append("P_Name", "Record 3").Append("P_Owner", 1).Append(customFields.Data["Client-1"].Name, 30), "Client 30")); }
public InsertRecordValidTests() { List <FieldProperty> select = new List <FieldProperty>() { FieldProperty.OptionMaster }; fieldReader = new HrbcFieldReader(ResourceFields.OptionFieldAlias, new List <FieldProperty>() { FieldProperty.OptionMaster }); var fieldRequestBuilder = FieldRequest.CreateFields(); foreach (var resourceId in Enum.GetValues(typeof(TestCoreFramework.Enums.ResourceType)).Cast <TestCoreFramework.Enums.ResourceType>()) { fieldRequestBuilder.Append((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.SingleLineText, "API automation test field", builder => builder.Searchable(false).Required(false).TextLength(100), $"{resourceId}"); } var fieldRequest = ((CreateFieldsRequest.IBuilderWithRecord)fieldRequestBuilder).Build().Content; customFields = new HrbcFieldCreator(fieldRequest, new List <FieldProperty> { FieldProperty.Id, FieldProperty.Name, FieldProperty.Resource }); }
private void InitApplicationFieldReader() { List <string> aliases = new List <string>() { SearchFields.AppOption1, }; applicationFieldReader = SearchHelper.InitOptionReader(aliases); }
public TestWriteAllFields() : base() { List <FieldProperty> select = new List <FieldProperty>() { FieldProperty.OptionMaster }; fieldReader = new HrbcFieldReader(ResourceFields.OptionFieldAlias, select); }
/// <summary> /// Get option list /// </summary> /// <param name="fieldReader">HrbcFieldReader</param> /// <param name="fieldAlias">Field alias</param> /// <returns></returns> public static List <string> GetOptionList(HrbcFieldReader fieldReader, string fieldAlias) { string optionMaster = OptionFieldHelper.GetOptionMaster(fieldReader, fieldAlias); Assume.That(optionMaster, Is.Not.Null.And.Not.Empty, "Cannot get the master option!"); List <string> optionList = OptionFieldHelper.GetOptionList(optionMaster); Assume.That(optionList, Is.Not.Null.And.Not.Empty, "Cannot get the option list!"); return(optionList); }
private void InitReadFields() { List <FieldProperty> select = new List <FieldProperty>() { FieldProperty.Caption }; readFields = new HrbcFieldReader(new List <string> { AppField }, select); }
private void InitFieldReader() { FieldProperty[] select = new FieldProperty[] { FieldProperty.Id, FieldProperty.Name, FieldProperty.Enabled }; ClientFieldReader = new HrbcFieldReader((builder) => { return(builder.WhereDeleted(false).WhereResource(ResourceId.Client)); }, select); ActivityFieldReader = new HrbcFieldReader((builder) => { return(builder.WhereDeleted(false).WhereResource(ResourceId.Activity)); }, select); ResumeFieldReader = new HrbcFieldReader((builder) => { return(builder.WhereDeleted(false).WhereResource(ResourceId.Resume)); }, select); JobFieldReader = new HrbcFieldReader((builder) => { return(builder.WhereDeleted(false).WhereResource(ResourceId.Job)); }, select); ContractFieldReader = new HrbcFieldReader((builder) => { return(builder.WhereDeleted(false).WhereResource(ResourceId.Contract)); }, select); ProcessFieldReader = new HrbcFieldReader((builder) => { return(builder.WhereDeleted(false).WhereResource(ResourceId.Process)); }, select); CandidateFieldReader = new HrbcFieldReader((builder) => { return(builder.WhereDeleted(false).WhereResource(ResourceId.Person)); }, select); RecruiterFieldReader = new HrbcFieldReader((builder) => { return(builder.WhereDeleted(false).WhereResource(ResourceId.Recruiter)); }, select); SalesFieldReader = new HrbcFieldReader((builder) => { return(builder.WhereDeleted(false).WhereResource(ResourceId.Sales)); }, select); }
private void InitApplicationFieldReader() { List <string> alias = new List <string>() { SearchFields.AppOption1, SearchFields.AppOption2, }; List <FieldProperty> select = new List <FieldProperty>() { FieldProperty.OptionMaster }; applicationFieldReader = new HrbcFieldReader(alias, select); }
private void InitSystemFieldReader() { List <string> aliases = new List <string>() { SearchFields.ActivityEventResources, SearchFields.ContractorType, SearchFields.JobArea, SearchFields.ProcessClose, SearchFields.ResumeExperiencedIndustry, SearchFields.ClientPhase, }; systemFieldReader = SearchHelper.InitOptionReader(aliases); }
private void InitFieldReader() { List <string> alias = new List <string>(activityFieldList); alias.AddRange(candidateFieldList); alias.AddRange(clientFieldList); alias.AddRange(contractFieldList); alias.AddRange(jobFieldList); alias.AddRange(processFieldList); alias.AddRange(recruiterFieldList); alias.AddRange(resumeFieldList); alias.AddRange(salesFieldList); List <FieldProperty> select = new List <FieldProperty>() { FieldProperty.OptionMaster }; fieldReader = new HrbcFieldReader(alias.Distinct(), select); }
private void InitSystemFieldReader() { List <string> alias = new List <string>() { SearchFields.ActivityEventResources, SearchFields.ActivityPhase, SearchFields.JobArea, SearchFields.JobCategory, SearchFields.ProcessClose, SearchFields.ProcessCloseReason, SearchFields.ResumeExperiencedIndustry, SearchFields.ResumeCurrentStatus, SearchFields.ContractorType }; List <FieldProperty> select = new List <FieldProperty>() { FieldProperty.OptionMaster }; systemFieldReader = new HrbcFieldReader(alias, select); }
private void InitFieldReader() { List <string> alias = new List <string>() { PhaseField, ActivityEventResources, //ClientServiceType, //ClientType, ContractorType, //JobServiceType, JobPublish, JobEmploymentType, JobIndustry, JobArea, JobCategory, JobExpectedAgeReason, JobPubliclyTraded, ProcessClose, ProcessCloseReason, //ResumeServiceType, //ResumeEmploymentType, ResumeExperiencedIndustry, ResumeCurrentStatus, ResumeExperiencedJobCategory, ResumeExpectIndustry, ResumeExpectJobCategory, ResumeExpectEmploymentType, ResumeExpectArea, ResumeRegisterChannel, ResumeGender, }; List <FieldProperty> select = new List <FieldProperty>() { FieldProperty.OptionMaster }; fieldReader = new HrbcFieldReader(alias, select); }
public TestWriteDefaultField() : base() { //Read fields List <string> defaultField = new List <string> { }; defaultField.Add($"Contract.{AdvancePayment}"); defaultField.Add($"Contract.{ContingentFee}"); defaultField.Add($"Contract.{ContractorFee}"); defaultField.Add($"Resume.{CurrentSalary}"); defaultField.Add($"Resume.{ExpectSalary}"); defaultField.Add($"Resume.{DesiredHourlyRate}"); defaultField.Add($"Resume.{HourlyRate}"); defaultField.Add($"Sales.{SalesAmount}"); defaultField.Add($"Process.{ExpectedSalesAmount}"); defaultField.Add($"Job.{MinSalary}"); defaultField.Add($"Job.{MaxSalary}"); readFields = new HrbcFieldReader(defaultField, new[] { FieldProperty.Min, FieldProperty.Max }); int testUser = 1; records = new HrbcRecordCreator(() => ResourceRequest.CreateRecords() .Append(ResourceId.Client, content => content .Append("P_Name", "Test Client") .Append("P_Owner", testUser), "client1") .Append(ResourceId.Recruiter, content => content .Append("P_Name", "Test Recruiter") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "recruiter1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job2") .Append(ResourceId.Person, content => content .Append("P_Name", "Test Person") .Append("P_Owner", testUser), "person1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume2") /* Example of a progress element: * .Append(ResourceId.Process, * content => content * .Append("P_Owner", testUser) * .Append("P_Client", new CreateRecordRequest.Reference("client")) * .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter")) * .Append("P_Job", new CreateRecordRequest.Reference("job")) * .Append("P_Candidate", new CreateRecordRequest.Reference("person")) * .Append("P_Resume", new CreateRecordRequest.Reference("resume")), * "process") */ .Append(ResourceId.Sales, content => content //.Append("P_SalesAmount", 5000) .Append("P_Owner", testUser), "sales1") .Append(ResourceId.Activity, content => content .Append("P_Title", "Test Activity") .Append("P_Owner", testUser) .Append("P_FromDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), "activity1") .Append(ResourceId.Contract, content => content .Append("P_Name", "Test Contract") //.Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "contract1")); }
public TestReadDefaultField() : base() { //Read fields List <string> defaultField = new List <string> { }; defaultField.Add($"Contract.{ContingentFeeRate}"); defaultField.Add($"Contract.{ContractorHeadCount}"); defaultField.Add($"Resume.{ChangeJobsCount}"); readFields = new HrbcFieldReader(defaultField, new[] { FieldProperty.Min, FieldProperty.Max }); //Update fields RandomMin = Util.GetRandomNumber(-999999999, 0).ToString(); RandomMax = Util.GetRandomNumber(999999999).ToString(); Dictionary <FieldProperty, object> fieldPropertiesMin = new Dictionary <FieldProperty, object> { { FieldProperty.Min, RandomMin } }; Dictionary <FieldProperty, object> fieldPropertiesMax = new Dictionary <FieldProperty, object> { { FieldProperty.Max, RandomMax } }; updateFieldsRandomMinContingentFeeRate = new HrbcFieldUpdater((test, data) => new[] { CreateFieldUpdateSpecForSingleProperty(Enums.ResourceType.Contract, ContingentFeeRate, fieldPropertiesMin) }); updateFieldsRandomMaxContingentFeeRate = new HrbcFieldUpdater((test, data) => new[] { CreateFieldUpdateSpecForSingleProperty(Enums.ResourceType.Contract, ContingentFeeRate, fieldPropertiesMax) }); updateFieldsRandomMinContractorHeadCount = new HrbcFieldUpdater((test, data) => new[] { CreateFieldUpdateSpecForSingleProperty(Enums.ResourceType.Contract, ContractorHeadCount, fieldPropertiesMin) }); updateFieldsRandomMaxContractorHeadCount = new HrbcFieldUpdater((test, data) => new[] { CreateFieldUpdateSpecForSingleProperty(Enums.ResourceType.Contract, ContractorHeadCount, fieldPropertiesMax) }); updateFieldsRandomMinChangeJobsCount = new HrbcFieldUpdater((test, data) => new[] { CreateFieldUpdateSpecForSingleProperty(Enums.ResourceType.Resume, ChangeJobsCount, fieldPropertiesMin) }); updateFieldsRandomMaxChangeJobsCount = new HrbcFieldUpdater((test, data) => new[] { CreateFieldUpdateSpecForSingleProperty(Enums.ResourceType.Resume, ChangeJobsCount, fieldPropertiesMax) }); int testUser = 1; records = new HrbcRecordCreator(() => ResourceRequest.CreateRecords() .Append(ResourceId.Client, content => content .Append("P_Name", "Test Client") .Append("P_Owner", testUser), "client1") .Append(ResourceId.Recruiter, content => content .Append("P_Name", "Test Recruiter") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "recruiter1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job2") .Append(ResourceId.Person, content => content .Append("P_Name", "Test Person") .Append("P_Owner", testUser), "person1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume2") /* Example of a progress element: * .Append(ResourceId.Process, * content => content * .Append("P_Owner", testUser) * .Append("P_Client", new CreateRecordRequest.Reference("client")) * .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter")) * .Append("P_Job", new CreateRecordRequest.Reference("job")) * .Append("P_Candidate", new CreateRecordRequest.Reference("person")) * .Append("P_Resume", new CreateRecordRequest.Reference("resume")), * "process") */ .Append(ResourceId.Sales, content => content //.Append("P_SalesAmount", 5000) .Append("P_Owner", testUser), "sales1") .Append(ResourceId.Activity, content => content .Append("P_Title", "Test Activity") .Append("P_Owner", testUser) .Append("P_FromDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), "activity1") .Append(ResourceId.Contract, content => content .Append("P_Name", "Test Contract") //.Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "contract1")); }
public TestMultipleSearchConditionOneFieldSystemField() : base() { List <string> alias = new List <string>() { ClientField, ActivityField, JobField, ResumeField, ContractField, CandidateField, RecruiterField, SalesField, ProcessField, }; List <FieldProperty> select = new List <FieldProperty>() { FieldProperty.OptionMaster }; fieldReader = new HrbcFieldReader(alias, select); int testUser = 1; records = new HrbcRecordCreator(() => ResourceRequest.CreateRecords() .Append(ResourceId.Client, content => content .Append("P_Name", "Test Client") .Append("P_Owner", testUser), "client1") .Append(ResourceId.Recruiter, content => content .Append("P_Name", "Test Recruiter") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "recruiter1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job2") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job3") .Append(ResourceId.Person, content => content .Append("P_Name", "Test Person") .Append("P_Owner", testUser), "person1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume2") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume3") /* Example of a progress element: * .Append(ResourceId.Process, * content => content * .Append("P_Owner", testUser) * .Append("P_Client", new CreateRecordRequest.Reference("client")) * .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter")) * .Append("P_Job", new CreateRecordRequest.Reference("job")) * .Append("P_Candidate", new CreateRecordRequest.Reference("person")) * .Append("P_Resume", new CreateRecordRequest.Reference("resume")), * "process") */ .Append(ResourceId.Sales, content => content //.Append("P_SalesAmount", 5000) .Append("P_Owner", testUser), "sales1") .Append(ResourceId.Activity, content => content .Append("P_Title", "Test Activity") .Append("P_Owner", testUser) .Append("P_FromDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), "activity1") .Append(ResourceId.Contract, content => content .Append("P_Name", "Test Contract") //.Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "contract1")); }
public static void ReadAndVerify(Enums.ResourceType resourceType, Dictionary <string, ResourceFields.InputType> fieldAlias, string id, int index, HrbcRecordCreator expectedRecords, HrbcFieldReader fieldReader) { ReadResponseData <XmlResource> result = ResourceHelper.ReadResourceById(resourceType, string.Join(",", fieldAlias.Keys), id); Assert.That(result, MustBe.ReadSuccess(1), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceType)); VerifyFieldValue(resourceType, fieldAlias, result.Items[0], index, expectedRecords, fieldReader); }
public static void VerifyFieldValue(Enums.ResourceType resourceType, Dictionary <string, ResourceFields.InputType> fieldName, object fieldValue, int index, HrbcRecordCreator expectedRecords, HrbcFieldReader fieldReader) { XmlResource actualValue = fieldValue as XmlResource; foreach (var item in fieldName) { if (item.Value != ResourceFields.InputType.UserList && item.Value != ResourceFields.InputType.Option) { Assert.That(GetActualValue(actualValue, item), Is.EqualTo(GetValidInput(item, index, expectedRecords, fieldReader)), $"Actual value {item.Key},{item.Value} is not match as expected!"); } else if (item.Value == ResourceFields.InputType.UserList) { Assert.That(GetActualValue(actualValue, item), Is.EqualTo("1"), $"Actual value {item.Key},{item.Value} is not match as expected!"); } else if (item.Value == ResourceFields.InputType.Option) { Assert.That(GetActualValue(actualValue, item), Is.EqualTo((GetValidInput(item, index, expectedRecords, fieldReader) as Option).ActualXMLTag), $"Actual value {item.Key},{item.Value} is not match as expected!"); } } }
public static void TestCreateListItem(Enums.ResourceType resourceType, Dictionary <string, ResourceFields.InputType> dictionaryAliasValue, bool isPhaseIncluded, HrbcRecordCreator referenceRecords, HrbcFieldReader fieldReader, HrbcRecordDelete cleaner) { string resourceName = resourceType.ToResourceName(); var resourceList = new[] { 0, 1 }.Select(depKey => { var resource = ResourceHelper.CreateResourceInstance(referenceRecords, resourceType, depKey); resource = AddValueForAllField(resource, dictionaryAliasValue, depKey, referenceRecords, fieldReader); if (isPhaseIncluded) { resource = AddPhaseToResource(resource, resourceName); } return(resource); }).ToList(); List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); for (int i = 0; i < result.Count; i++) { ReadAndVerify(resourceType, dictionaryAliasValue, result[i].Id, i, referenceRecords, fieldReader); } }
public static XmlResource AddValueForAllField(XmlResource resource, Dictionary <string, ResourceFields.InputType> dictionaryAliasValue, int index, HrbcRecordCreator records, HrbcFieldReader fieldReader) { foreach (var item in dictionaryAliasValue) { resource.DictionaryValues[item.Key] = GetValidInput(item, index, records, fieldReader); if (item.Key.Split('.').First().Equals(nameof(Enums.ResourceType.Sales))) { resource = AddRequiredSystemFieldForSale(resource, item.Value); } } return(resource); }
public static void TestCreateSingleItem(Enums.ResourceType resourceType, Dictionary <string, ResourceFields.InputType> dictionaryAliasValue, bool isPhaseIncluded, HrbcRecordCreator referenceRecords, HrbcFieldReader fieldReader, HrbcRecordDelete cleaner) { string resourceName = resourceType.ToResourceName(); XmlResource resource = ResourceHelper.CreateResourceInstance(referenceRecords, resourceType, 0); resource = AddValueForAllField(resource, dictionaryAliasValue, 0, referenceRecords, fieldReader); if (isPhaseIncluded) { resource = AddPhaseToResource(resource, resourceName); } string id = ResourceHelper.WriteResource(resource, cleaner); Assert.That(id, MustBe.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); ReadAndVerify(resourceType, dictionaryAliasValue, id, 0, referenceRecords, fieldReader); }
public TestReadOrderFieldSystemField() : base() { List <string> alias = new List <string>() { PhaseField, ActivityEventResources, //ClientServiceType, //ClientType, ContractorType, //JobServiceType, JobPublish, JobEmploymentType, JobIndustry, JobArea, JobCategory, JobExpectedAgeReason, JobPubliclyTraded, ProcessClose, ProcessCloseReason, //ResumeServiceType, //ResumeEmploymentType, ResumeExperiencedIndustry, ResumeCurrentStatus, ResumeExperiencedJobCategory, ResumeExpectIndustry, ResumeExpectJobCategory, ResumeExpectEmploymentType, ResumeExpectArea, ResumeRegisterChannel, ResumeGender, }; List <FieldProperty> select = new List <FieldProperty>() { FieldProperty.OptionMaster }; fieldReader = new HrbcFieldReader(alias, select); int testUser = 1; records = new HrbcRecordCreator(() => ResourceRequest.CreateRecords() .Append(ResourceId.Client, content => content .Append("P_Name", "Test Client") .Append("P_Owner", testUser), "client1") .Append(ResourceId.Recruiter, content => content .Append("P_Name", "Test Recruiter") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "recruiter1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job2") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job3") .Append(ResourceId.Person, content => content .Append("P_Name", "Test Person") .Append("P_Owner", testUser), "person1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume2") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume3") /* Example of a progress element: * .Append(ResourceId.Process, * content => content * .Append("P_Owner", testUser) * .Append("P_Client", new CreateRecordRequest.Reference("client")) * .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter")) * .Append("P_Job", new CreateRecordRequest.Reference("job")) * .Append("P_Candidate", new CreateRecordRequest.Reference("person")) * .Append("P_Resume", new CreateRecordRequest.Reference("resume")), * "process") */ .Append(ResourceId.Sales, content => content //.Append("P_SalesAmount", 5000) .Append("P_Owner", testUser), "sales1") .Append(ResourceId.Activity, content => content .Append("P_Title", "Test Activity") .Append("P_Owner", testUser) .Append("P_FromDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), "activity1") .Append(ResourceId.Contract, content => content .Append("P_Name", "Test Contract") //.Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "contract1")); }
public static void TestUpdateListItem(Enums.ResourceType resourceType, Dictionary <string, ResourceFields.InputType> dictionaryAliasValue, bool isPhaseIncluded, HrbcRecordCreator records, HrbcFieldReader fieldReader) { string resourceName = resourceType.ToResourceName(); IEnumerable <XmlResource> resourceList = new int[] { 0, 1 }.Select(index => { XmlResource resource = CreateUpdatedResource(resourceType, records.Data[$"{resourceType.ToPrivateEnum()}{index}"].Id.ToString()); resource = AddValueForAllField(resource, dictionaryAliasValue, index, records, fieldReader); if (isPhaseIncluded) { resource = AddPhaseToResource(resource, resourceName); } return(resource); }); List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, null); Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); for (int i = 0; i < result.Count; i++) { ReadAndVerify(resourceType, dictionaryAliasValue, result[i].Id, i, records, fieldReader); } }
public static void TestUpdateSingleItem(Enums.ResourceType resourceType, Dictionary <string, ResourceFields.InputType> dictionaryAliasValue, bool isPhaseIncluded, HrbcRecordCreator records, HrbcFieldReader fieldReader) { string resourceName = resourceType.ToResourceName(); XmlResource resource = CreateUpdatedResource(resourceType, records.Data[$"{resourceType.ToPrivateEnum()}{0}"].Id.ToString()); resource = AddValueForAllField(resource, dictionaryAliasValue, 0, records, fieldReader); if (isPhaseIncluded) { resource = AddPhaseToResource(resource, resourceName); } string id = ResourceHelper.WriteResource(resource, null); //Verify result Assert.That(id, MustBe.Not.Null.And.Not.Empty, string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, resourceType)); ReadAndVerify(resourceType, dictionaryAliasValue, id, 0, records, fieldReader); }
public static object GetValidInput(KeyValuePair <string, ResourceFields.InputType> InputType, int index, HrbcRecordCreator records, HrbcFieldReader fieldReader) { UpdateSystemResourceId(records, index); if (InputType.Value == ResourceFields.InputType.Option) { string optionMaster = OptionFieldHelper.GetOptionMaster(fieldReader, InputType.Key); Assume.That(optionMaster, Is.Not.Null.And.Not.Empty, "Cannot get the master option!"); List <string> optionList = OptionFieldHelper.GetOptionList(optionMaster); Assume.That(optionList, Is.Not.Null.And.Not.Empty, "Cannot get the option list!"); return(new Option() { ActualXMLTag = optionList.First() }); } if (InputType.Value == ResourceFields.InputType.UserList) { Activity activity = CreateActivityInstance(); activity.EventParticipants = new ArrayList() { new User() { Id = "1" } }; return((activity as XmlResource).DictionaryValues[InputType.Key]); } return(valueDictionary[InputType.Value].ToString()); }
public TestSearchMultipleFieldConditionApplicationField() : base() { List <string> applicationField = new List <string> { }; string resourceName = string.Empty; foreach (var resourceId in Enum.GetValues(typeof(Enums.ResourceType)).Cast <Enums.ResourceType>()) { resourceName = resourceId == Enums.ResourceType.Candidate ? "Person" : resourceId.ToString(); applicationField.Add(resourceName + "." + AppField1); applicationField.Add(resourceName + "." + AppField2); } readFields = new HrbcFieldReader(applicationField, new[] { FieldProperty.TextLength }); int testUser = 1; records = new HrbcRecordCreator(() => ResourceRequest.CreateRecords() .Append(ResourceId.Client, content => content .Append("P_Name", "Test Client") .Append("P_Owner", testUser), "client1") .Append(ResourceId.Recruiter, content => content .Append("P_Name", "Test Recruiter") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "recruiter1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job2") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job3") .Append(ResourceId.Person, content => content .Append("P_Name", "Test Person") .Append("P_Owner", testUser), "person1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume2") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume3") /* Example of a progress element: * .Append(ResourceId.Process, * content => content * .Append("P_Owner", testUser) * .Append("P_Client", new CreateRecordRequest.Reference("client")) * .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter")) * .Append("P_Job", new CreateRecordRequest.Reference("job")) * .Append("P_Candidate", new CreateRecordRequest.Reference("person")) * .Append("P_Resume", new CreateRecordRequest.Reference("resume")), * "process") */ .Append(ResourceId.Sales, content => content //.Append("P_SalesAmount", 5000) .Append("P_Owner", testUser), "sales1") .Append(ResourceId.Activity, content => content .Append("P_Title", "Test Activity") .Append("P_Owner", testUser) .Append("P_FromDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), "activity1") .Append(ResourceId.Contract, content => content .Append("P_Name", "Test Contract") //.Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "contract1")); }
public TestReadEscapeSequencesApplicationField() : base() { List <FieldProperty> select = new List <FieldProperty>() { FieldProperty.TextLength }; readFields = new HrbcFieldReader(new List <string> { AppField }, select); int testUser = 1; records = new HrbcRecordCreator(() => ResourceRequest.CreateRecords() .Append(ResourceId.Client, content => content .Append("P_Name", "Test Client") .Append("P_Owner", testUser), "client1") .Append(ResourceId.Recruiter, content => content .Append("P_Name", "Test Recruiter") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "recruiter1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job2") .Append(ResourceId.Person, content => content .Append("P_Name", "Test Person") .Append("P_Owner", testUser), "person1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume2") /* Example of a progress element: * .Append(ResourceId.Process, * content => content * .Append("P_Owner", testUser) * .Append("P_Client", new CreateRecordRequest.Reference("client")) * .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter")) * .Append("P_Job", new CreateRecordRequest.Reference("job")) * .Append("P_Candidate", new CreateRecordRequest.Reference("person")) * .Append("P_Resume", new CreateRecordRequest.Reference("resume")), * "process") */ .Append(ResourceId.Sales, content => content //.Append("P_SalesAmount", 5000) .Append("P_Owner", testUser), "sales1") .Append(ResourceId.Activity, content => content .Append("P_Title", "Test Activity") .Append("P_Owner", testUser) .Append("P_FromDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), "activity1") .Append(ResourceId.Contract, content => content .Append("P_Name", "Test Contract") //.Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "contract1")); }
public TestReadValidInputApplicationField() : base() { List <string> alias = new List <string>() { OptionCheckBox1, OptionCheckBox2, OptionDropDown1, OptionDropDown2, OptionRadioButton1, OptionRadioButton2, CheckBox1, CheckBox2, DropDown1, DropDown2, RadioButton1, RadioButton2, SearchBox1, SearchBox2, MultiSearchBox1, MultiSearchBox2, }; List <FieldProperty> select = new List <FieldProperty>() { FieldProperty.OptionMaster }; fieldReader = new HrbcFieldReader(alias, select); int testUser = 1; records = new HrbcRecordCreator(() => ResourceRequest.CreateRecords() .Append(ResourceId.Client, content => content .Append("P_Name", "Test Client") .Append("P_Owner", testUser), "client1") .Append(ResourceId.Recruiter, content => content .Append("P_Name", "Test Recruiter") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "recruiter1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job1") .Append(ResourceId.Job, content => content .Append("P_Position", "Test Job") .Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")) .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter1")), "job2") .Append(ResourceId.Person, content => content .Append("P_Name", "Test Person") .Append("P_Owner", testUser), "person1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume1") .Append(ResourceId.Resume, content => content .Append("P_Owner", testUser) .Append("P_Candidate", new CreateRecordRequest.Reference("person1")), "resume2") /* Example of a progress element: * .Append(ResourceId.Process, * content => content * .Append("P_Owner", testUser) * .Append("P_Client", new CreateRecordRequest.Reference("client")) * .Append("P_Recruiter", new CreateRecordRequest.Reference("recruiter")) * .Append("P_Job", new CreateRecordRequest.Reference("job")) * .Append("P_Candidate", new CreateRecordRequest.Reference("person")) * .Append("P_Resume", new CreateRecordRequest.Reference("resume")), * "process") */ .Append(ResourceId.Sales, content => content //.Append("P_SalesAmount", 5000) .Append("P_Owner", testUser), "sales1") .Append(ResourceId.Activity, content => content .Append("P_Title", "Test Activity") .Append("P_Owner", testUser) .Append("P_FromDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), "activity1") .Append(ResourceId.Contract, content => content .Append("P_Name", "Test Contract") //.Append("P_Owner", testUser) .Append("P_Client", new CreateRecordRequest.Reference("client1")), "contract1")); }
/// <summary> /// Check existence of application field /// </summary> /// <param name="readFields">Read hrbc fields</param> /// <param name="resourceType">Resource Type</param> /// <param name="fieldName">Field Name</param> public static void CheckRegisteredField(HrbcFieldReader readFields, Enums.ResourceType resourceType, string fieldName) { string fieldAlias = $"{resourceType.ToResourceName()}.{fieldName}"; Assume.That(readFields.Data.Keys.Any(t => t.ToAlias().Equals(fieldAlias)), string.Format("The {0} is not registered yet!", fieldAlias)); }