public void TestMultipleSearchMultipleNumberField(string fieldName1, string fieldName2, string condition1, string condition2) { condition1 = condition1.ToLowerString(); condition2 = condition2.ToLowerString(); if (fieldName1.Contains("Date") && fieldName2.Contains("Date")) { Dictionary <string, string> conditionParameters = new Dictionary <string, string>() { { DateTimeValidator.FieldAlias1, fieldName1 }, { DateTimeValidator.FieldAlias2, fieldName2 }, { DateTimeValidator.Condition1, condition1 }, { DateTimeValidator.Condition2, condition2 }, { DateTimeValidator.ConditionValue1, PhaseHelper.GeneratePhaseNumberType(defaultResource, fieldName1, indexFirstPhaseList) }, //Get phase value by public api because read phase private api could not retrieve RegistrationDate, Option alias { DateTimeValidator.ConditionValue2, PhaseHelper.GeneratePhaseNumberType(defaultResource, fieldName2, indexSecondPhaseList) }, //Get phase value by public api because read phase private api could not retrieve RegistrationDate, Option alias }; SystemFieldTypeHelper.VerifySearchDatePhase(defaultResource, conditionParameters, false); } else { List <string> conditionValues = new List <string>(); conditionValues.Add((PhaseHelper.GeneratePhaseNumberType(defaultResource, fieldName1, indexFirstPhaseList))); conditionValues.Add((PhaseHelper.GeneratePhaseNumberType(defaultResource, fieldName1, indexFirstPhaseList))); conditionValues.Add((PhaseHelper.GeneratePhaseNumberType(defaultResource, fieldName2, indexSecondPhaseList))); conditionValues.Add((PhaseHelper.GeneratePhaseNumberType(defaultResource, fieldName2, indexSecondPhaseList))); string formatCond = PhaseHelper.GetFormatConditionDifferentFields(fieldName1, fieldName2, condition1, condition2, conditionValues[0], conditionValues[1], conditionValues[2], conditionValues[3]); Dictionary <string, object> parameters = new Dictionary <string, object>() { { PhaseApiFields.Partition, AuthenticationInfoProvider.Current.DefaultPartition }, { PhaseApiFields.Resource, (int)defaultResource }, { PhaseApiFields.Condition, formatCond }, { PhaseApiFields.Field, $"{fieldName1},{fieldName2}" }, }; ReadResponseData <Phase> result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Phase>(parameters); Assert.That(result.Code, Is.EqualTo(Enums.PublicAPIResultCode.Success), string.Format(Enums.Message.READ_RESOURCE_FAILED, nameof(Phase))); foreach (var item in result.Items) { DateTimeValidator.ConditionalAssertions[condition1](item.DictionaryValues[fieldName1], conditionValues[0], conditionValues[1]); DateTimeValidator.ConditionalAssertions[condition2](item.DictionaryValues[fieldName2], conditionValues[2], conditionValues[3]); } } }
public void TestMultipleSearchMultipleFields(Enums.ResourceType resourceType, ReadInvalidInputTestData.ItemState itemState, string firstFieldName, string secondFieldName, string firstCondition, string secondCondition) { ItemStateHelper.SearchParameters searchParameters = null; string firstFieldAlias = $"{resourceType.ToResourceName()}.{firstFieldName}"; string secondFieldAlias = $"{resourceType.ToResourceName()}.{secondFieldName}"; var extraUrlParameters = new Dictionary <string, object>(); if (itemState != ReadInvalidInputTestData.ItemState.None) { extraUrlParameters.Add(DeletedDataFields.ItemState, itemState.ToLowerString()); } var itemStateType = itemState == ReadInvalidInputTestData.ItemState.None ? ReadInvalidInputTestData.ItemState.All : itemState; searchParameters = new ItemStateHelper.SearchParameters(firstFieldAlias, secondFieldAlias, firstCondition, secondCondition, null, null, null, null); //Result code var resultCode = (((firstFieldName == DeletedDataFields.P_UpdateDate) && firstCondition.ContainsStrings(new string[] { DateTimeValidator.Le, DateTimeValidator.Lt }) || (secondFieldName == DeletedDataFields.P_UpdateDate) && secondCondition.ContainsStrings(new string[] { DateTimeValidator.Le, DateTimeValidator.Lt })) && (itemState == ReadInvalidInputTestData.ItemState.Deleted || itemState == ReadInvalidInputTestData.ItemState.All)) ? Enums.PublicAPIResultCode.DateTimeOutOfRange : Enums.PublicAPIResultCode.Success; //Get result for condition inputs var extraConditionParam = new Dictionary <string, object>(extraUrlParameters); extraConditionParam["condition"] = $"{resourceType.ToResourceName()}.P_Id:ge={ItemStateHelper.RecordIds[itemStateType](resourceType, RecordNum, recordsIn90Days, recordsOver90Days, deletedRecordsMapping)["Min"]},{resourceType.ToResourceName()}.P_Id:le={ItemStateHelper.RecordIds[itemStateType](resourceType, RecordNum, recordsIn90Days, recordsOver90Days, deletedRecordsMapping)["Max"]}"; var result = ItemStateHelper.GetAllResults(resourceType, $"{firstFieldAlias},{secondFieldAlias}", 0, MaxCount, extraConditionParam).Items; FirstFieldNameValues[firstFieldName](result, searchParameters, resourceType, itemStateType, firstFieldAlias, RecordNum); SecondFieldNameValues[secondFieldName](result, searchParameters, resourceType, itemStateType, secondFieldAlias, RecordNum); //Read & verify data string formatCond = PhaseHelper.GetFormatConditionDifferentFields(firstFieldAlias, secondFieldAlias, firstCondition, secondCondition, searchParameters.FirstCondValue.ToString(), searchParameters.SecondCondValue.ToString(), searchParameters.ThirdCondValue.ToString(), searchParameters.FourCondValue.ToString() ); Dictionary <string, object> parameters = new Dictionary <string, object>() { { "partition", AuthenticationInfoProvider.Current.DefaultPartition }, { "condition", formatCond }, { "field", $"{firstFieldAlias},{secondFieldAlias}" }, { "count", MaxCount }, }; if (extraUrlParameters != null) { parameters = parameters.Concat(extraUrlParameters).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.First().Value); } if (resultCode == Enums.PublicAPIResultCode.DateTimeOutOfRange) { var response = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadFail(resourceType.ToString(), parameters); Assert.That(response, MustBe.MatchingErrorCode(resultCode), Enums.Message.WRONG_ERROR_CODE); } else { var response = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess(resourceType.ToString(), parameters); Assert.That(response, MustBe.ReadSuccess(0), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceType)); object firstRealValue = null; object secondRealValue = null; foreach (var item in response.Items) { firstRealValue = RealValues[firstFieldName](item, firstFieldAlias); secondRealValue = RealValues[secondFieldName](item, secondFieldAlias); DateTimeValidator.ConditionalAssertions[firstCondition](firstRealValue, firstFieldName == DeletedDataFields.P_UpdateDate ? Util.ParseDateTime(searchParameters.FirstCondValue.ToString()) : searchParameters.FirstCondValue, firstFieldName == DeletedDataFields.P_UpdateDate ? Util.ParseDateTime(searchParameters.SecondCondValue.ToString()) : searchParameters.SecondCondValue); DateTimeValidator.ConditionalAssertions[secondCondition](secondRealValue, secondFieldName == DeletedDataFields.P_UpdateDate ? Util.ParseDateTime(searchParameters.ThirdCondValue.ToString()) : searchParameters.ThirdCondValue , secondFieldName == DeletedDataFields.P_UpdateDate ? Util.ParseDateTime(searchParameters.FourCondValue.ToString()) : searchParameters.FourCondValue); } } }