private static HrbcFieldCreator PrepareFieldReferencedToOption(Guid uuid) { var builder = FieldRequest.CreateFields(); HRBCClientPrivate.API.Field.FieldType fieldType = HRBCClientPrivate.API.Field.FieldType.Option; builder.Append(ResourceId.Client, fieldType, $"{fieldType}", content => content.Searchable(true).Copy(false).Required(false).OptionMaster(uuid).Name($"{fieldType}"), $"{fieldType}"); return(new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)builder, new[] { FieldProperty.Id, FieldProperty.Resource, FieldProperty.Name, FieldProperty.FieldType })); }
public void InvalidFormulaWithDependenciesTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, string formulas) { var specs = ParseSpecs(formulas, resource, fieldType); foreach (var spec in specs.Take(specs.Count() - 1)) { var response = SetFormula(spec.Value, new FieldDescriptor(resource, fieldType, spec.Key)); PrAssume.That(response, PrIs.SuccessfulResponse()); } var responseToVerify = SetFormula(specs.Last().Value, new FieldDescriptor(resource, fieldType, specs.Last().Key)); PrAssert.That(responseToVerify, PrIs.ErrorResponse().With.HttpCode(400)); }
public void GetComputationInfoTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, string formula, int precision, Dictionary <string, string[]> expectedOutput) { var response = (new DefaultManager()).Send <GetComputationInfoResponse>(new GetComputationInfoReqeust { ResourceId = (int)resource }); var adaptedExpectedResult = expectedOutput.ToDictionary(x => GetAlias(resource, fieldType, CodeToIndexMap[x.Key]), x => x.Value.Select(item => GetAlias(resource, fieldType, CodeToIndexMap[item])).ToList()); PrAssert.That(response, PrIs.SuccessfulResponse <GetComputationInfoResponse>()); PrAssert.That(response.Result.ComputationInfo.Select(x => x.Field).ToList(), PrIs.Not.Null.And.EquivalentTo(adaptedExpectedResult.Keys.ToList())); foreach (var fieldInfo in response.Result.ComputationInfo) { PrAssert.That(fieldInfo.AffectedTerminalFields, PrIs.EquivalentTo(adaptedExpectedResult[fieldInfo.Field])); } }
private void PerformSimpleOperationTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, Dictionary <string, object> parameters, string expectedResult) { var request = new ComputeFieldsRequest { ResourceId = (int)resource, TargetField = GetAlias(resource, fieldType, CodeToIndexMap["[A]"]), FieldValuePairs = parameters }; var handler = new DefaultManager(); var response = handler.Send <ComputeFieldsResponse>(request); PrAssert.That(response, PrIs.SuccessfulResponse <ComputeFieldsResponse>()); PrAssert.That(response?.Result?.Value, PrIs.EqualTo(expectedResult)); }
public void AffectedSumTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, string formula, int precision, params object[] formulaParameters) { var expectedResult = formulaParameters.Last().ToString(); var formulaParameterNames = formula.Split('(', ')')[1].Split(',').Distinct().ToArray(); var fieldsWithValues = new Dictionary <string, object>(); for (var i = 0; i < formulaParameterNames.Length; i++) { if (IndexExtractorRex.IsMatch(formulaParameterNames[i])) { fieldsWithValues.Add(GetAlias(resource, fieldType, CodeToIndexMap[formulaParameterNames[i]]), formulaParameters[i]); } } PerformSimpleAffectedOperationTest(resource, fieldType, fieldsWithValues, expectedResult); }
private void PerformSimpleAffectedOperationTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, Dictionary <string, object> parameters, string expectedResult) { var request = new ComputeAffectedFieldRequest { ResourceId = (int)resource, TargetField = parameters.First().Key, FieldValuePairs = parameters, TargetFieldValue = parameters.First().Value }; var handler = new DefaultManager(); var response = handler.Send <ComputeAffectedFieldsResponse>(request); PrAssert.That(response, PrIs.SuccessfulResponse <ComputeAffectedFieldsResponse>()); PrAssert.That(response?.Result?.AffectedFields, PrIs.Not.Null.And.Not.Empty.And.Count.EqualTo(1)); PrAssert.That(response.Result.AffectedFields.Single()?.Value, PrIs.EqualTo(expectedResult)); PrAssert.That(response.Result.AffectedFields.Single()?.Field, PrIs.EqualTo(GetAlias(resource, fieldType, CodeToIndexMap["[A]"]))); }
public FieldDescriptor(ResourceId resource, HRBCClientPrivate.API.Field.FieldType type, int index) { Resource = resource; Type = type; Index = index; }
public void ModTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, string formula, int precision, string first, string second, string expectedResult) { PerformSimpleOperationTest(resource, fieldType, formula, first, second, expectedResult); }
public void ValidFormulaTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, string formula) { var response = SetFormula(formula, new FieldDescriptor(resource, fieldType, 0)); PrAssert.That(response, PrIs.SuccessfulResponse()); }
public void ProcessSublistSearchValidUserFieldTest(string field, string conditionField, ProcessSublistSearchCases.SuffixOperator suffix, HRBCClientPrivate.API.Field.FieldType orderField, ProcessSublistSearchCases.OrderType order, int count) { SendRequestAndVerifyResponse(field, conditionField, suffix, FieldCreator.Data[$"{orderField}"].Field.ToAlias(), order, count); }
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); }
public void TestWriteResourceWithReadOnlySetting(Enums.ResourceType resourceType, HRBCClientPrivate.API.Field.FieldType fieldType) { Assume.That(customFields.Data, Is.Not.Null, "HrbcFieldCreator cannot create custom fields!"); Assume.That(records.Data, Is.Not.Null, "HrbcRecordCreator cannot create data!"); string fieldAlias = customFields.Data[$"{resourceType}-{fieldType}"].Field.ToAlias(); XmlResource resource = CreateResourceInstance(resourceType); resource.DictionaryValues[fieldAlias] = new Option() { ActualXMLTag = optionList.First() }; ErrorCode result = WriteResourceFail(resource); Assert.That(result.Code, Is.EqualTo(Enums.PublicAPIResultCode.ParameterIsInvalid), Enums.Message.WRONG_ERROR_CODE); }
private static string ParseExpression(string expression, ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType) { foreach (var entry in CodeToIndexMap) { expression = expression.Replace(entry.Key, GetAlias(resource, fieldType, entry.Value)); } return(expression); }
private Dictionary <string, object> ExtractFieldParameters(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, string formula, string first, string second) { formula = formula.Replace("[A]=", ""); var parameters = new Dictionary <string, object>(); if (IndexExtractorRex.IsMatch(formula)) { parameters = IndexExtractorRex.Matches(formula).Cast <System.Text.RegularExpressions.Match>().Select(m => m.Value) .ToDictionary(x => GetAlias(resource, fieldType, CodeToIndexMap[x]), x => formula.Split(',', '+', '-', '*', '/')[0].Contains(x) ? (object)first : second); } return(parameters); }
private void PerformSimpleAffectedOperationTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, string formula, string first, string second, string expectedResult) { Dictionary <string, object> parameters = ExtractFieldParameters(resource, fieldType, formula, first, second); PerformSimpleAffectedOperationTest(resource, fieldType, parameters, expectedResult); }
public void TestWriteResourceWithReadWriteSetting(Enums.ResourceType resourceType, HRBCClientPrivate.API.Field.FieldType fieldType) { Assume.That(customFields.Data, Is.Not.Null, "HrbcFieldCreator cannot create custom fields!"); Assume.That(records.Data, Is.Not.Null, "HrbcRecordCreator cannot create data!"); string fieldAlias = customFields.Data[$"{resourceType}-{fieldType}"].Field.ToAlias(); XmlResource resource = CreateResourceInstance(resourceType, 2); resource.DictionaryValues[fieldAlias] = new Option() { ActualXMLTag = optionList.First() }; string id = WriteResource(resource); Assert.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); }
public void TestReadResourceWithAccessSetting(Enums.ResourceType resourceType, HRBCClientPrivate.API.Field.FieldType fieldType) { Assume.That(customFields.Data, Is.Not.Null, "HrbcFieldCreator cannot create custom fields!"); Assume.That(records.Data, Is.Not.Null, "HrbcRecordCreator cannot create data!"); string fieldAlias = customFields.Data[$"{resourceType}-{fieldType}"].Field.ToAlias(); Dictionary <string, object> urlParameter = new Dictionary <string, object>() { { "partition", AuthenticationInfoProvider.Current.DefaultPartition }, { "field", fieldAlias } }; ReadResource(resourceType, urlParameter); }
public void AffectedRoundTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, string formula, int precision, string first, string expectedResult) { PerformSimpleAffectedOperationTest(resource, fieldType, formula, first, null, expectedResult); }
public void AffectedSpecialCasesTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, string expectedResult, Dictionary <string, string> parameters, string description) { PerformSimpleAffectedOperationTest(resource, fieldType, parameters.ToDictionary(x => GetAlias(resource, fieldType, CodeToIndexMap[x.Key]), x => (object)x.Value), expectedResult); }
private static IEnumerable <KeyValuePair <int, string> > ParseSpecs(string specs, ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType) { return(specs.Split(';') .Select(x => new KeyValuePair <int, string>(CodeToIndexMap[x.Split('=')[0]], ParseExpression(x.Split('=')[1], resource, fieldType)))); }
public void InvalidFormulaTest(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, string formula) { var response = SetFormula(formula, new FieldDescriptor(resource, fieldType, 0)); PrAssert.That(response, PrIs.ErrorResponse().With.HttpCode(400)); }
private static string GetAlias(ResourceId resource, HRBCClientPrivate.API.Field.FieldType fieldType, int index) { return($"{resource}.{FieldsCreator.Data[new FieldDescriptor(resource, fieldType, index)].Name}"); }
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(); }