public void TestCreateListItem(Enums.ResourceType resourceType, string fieldValue) { List <XmlResource> resources = ResourceHelper.CreateListResourceItem(resourceType, $"{resourceType.ToResourceName()}.{AppField}", fieldValue, records); List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resources, cleaner); Assert.That(result, MustBe.SuccessfullyWritten(resources.Count), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); }
public void TestCreateListItem(Enums.ResourceType resourceType, string fieldName, WriteValidInput valueType) { string fieldAlias = resourceType.ToResourceName() + "." + fieldName; List <XmlResource> resourceList = ResourceHelper.CreateListResourceItem(resourceType, fieldAlias, FieldValueMapper.ValidInputMapper[valueType], records, true); List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); }
public void TestCreateListItem(Enums.ResourceType resourceType, WriteValidInput valueType) { string fieldAlias = resourceType.ToResourceName() + "." + AppField; List <XmlResource> resourceList = ResourceHelper.CreateListResourceItem(resourceType, fieldAlias, FieldValueMapper.ValidInputMapper[valueType], records, true); List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count), "The response data is incorrect!"); }
public void TestCreateListItem(Enums.ResourceType resourceType, WriteValidInput valueType) { Assume.That(customFields.Data, Is.Not.Null, "HrbcFieldCreator cannot create custom fields!"); string fieldAlias = customFields.Data[$"{resourceType}"].Field.ToAlias(); List <XmlResource> resourceList = ResourceHelper.CreateListResourceItem(resourceType, fieldAlias, FieldValueMapper.ValidInputMapper[valueType], records, true); List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); }
public void TestCreateListItem(Enums.ResourceType resourceType) { var resourceList = new[] { 0, 1 }.Select(depKey => { return(PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, depKey)); }).ToList(); List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList); Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType)); }
public void TestUpdateListItem(Enums.ResourceType resourceType, Enums.TextType textType, AlphabetLenght characterNumber) { List<XmlResource> resourceList = new[] { 0, 1 }.Select(depKey => ResourceHelper.CreateResourceInstance(records, resourceType, depKey)).ToList(); List<WriteResultItem> ids = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assume.That(ids, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); string fieldAlias = resourceType.ToResourceName() + "." + AppField; string fieldValue = Util.GetRandomText(textType, AlphabetValueMapper.AlphabetMapper[characterNumber]); resourceList = ids.Select(item => ResourceHelper.CreateUpdatedResource(resourceType, item.Id, fieldAlias, fieldValue)).ToList(); ErrorCode result = ResourceHelper.WriteResourcesFail(resourceList); Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.InvalidParameterValue), Enums.Message.WRONG_ERROR_CODE); }
public void TestCreateListItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType) { var resourceList = new[] { 0, 1 }.Select(depKey => { Phase phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, depKey); phase.Memo = Util.GetRandomText(textType, stringLength[lengthType]); return(phase); }).ToList(); List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList); Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType)); }
public void TestUpdateListItem(Enums.ResourceType resourceType, PhaseDateInput phaseDateType, PhaseOptionInput phaseOptionType, int expectedCode, int index) { phaseDictionary = PhaseFieldHelper.InitPhaseList(phaseSearcher); var resourceList = new int[] { (index * 2), (index * 2 + 1) }.Select(keyDep => { return(PhaseFieldHelper.GetUpdatedResourcePhaseField(resourceType, phaseDateType, phaseOptionType, keyDep, phaseSearcher, phaseEntryReader, GetPhaseOrderBySort(resourceType), phaseDictionary, records)); }).ToList(); List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, null); Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot update phase for {0}", resourceType)); }
public void TestUpdateListItem(Enums.ResourceType resourceType, string fieldValue) { List <XmlResource> resourceList = new[] { 0, 1 }.Select(depKey => ResourceHelper.CreateResourceInstance(records, resourceType, depKey)).ToList(); List <WriteResultItem> ids = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assume.That(ids, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); string fieldAlias = $"{resourceType.ToResourceName()}.{AppField}"; resourceList = ids.Select(item => ResourceHelper.CreateUpdatedResource(resourceType, item.Id, fieldAlias, fieldValue)).ToList(); List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, null); Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, resourceType)); }
public void TestUpdateListItem(Enums.ResourceType resourceType, InjectionInput fieldType) { List <XmlResource> resourceList = new[] { 0, 1 }.Select(depKey => ResourceHelper.CreateResourceInstance(records, resourceType, depKey)).ToList(); List <WriteResultItem> ids = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assume.That(ids, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); string fieldAlias = customFields.Data[$"{resourceType}"].Field.ToAlias(); resourceList = ids.Select(item => ResourceHelper.CreateUpdatedResource(resourceType, item.Id, fieldAlias, InjectionInputData.InjectionInputMapper[fieldType])).ToList(); ErrorCode result = ResourceHelper.WriteResourcesFail(resourceList); Assert.That(result, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.InvalidParameterValue), Enums.Message.WRONG_ERROR_CODE); }
public void TestCreateListItem(Enums.ResourceType resourceType, string fieldName, WriteValidInput valueType) { string fieldValue = FieldValueMapper.ValidInputMapper[valueType]; var resourceList = new[] { 0, 1 }.Select(depKey => { var phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, depKey); phase.DictionaryValues[fieldName] = fieldValue; return(phase); }).ToList(); List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList); Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType)); }
public void TestUpdateListItem(Enums.ResourceType resourceType, string fieldName, WriteValidInput valueType) { var resourceList = new[] { 0, 1 }.Select(depKey => ResourceHelper.CreateResourceInstance(records, resourceType, depKey)); List <WriteResultItem> ids = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assume.That(ids, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); //Write data string fieldAlias = resourceType.ToResourceName() + "." + fieldName; resourceList = ids.Select(item => ResourceHelper.CreateUpdatedResource(resourceType, item.Id, fieldAlias, FieldValueMapper.ValidInputMapper[valueType], true)); List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, null); Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, resourceType)); }
public void TestUpdateListItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType) { var resourceList = new[] { 0, 1 }.Select(depKey => { var phase = new Phase { Id = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{depKey}"].FirstOrDefault().Id, Memo = Util.GetRandomText(textType, stringLength[lengthType]), }; return(phase); }); List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList); Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot update phase memo for {0}", resourceType)); }
public void TestUpdateListItem(Enums.ResourceType resourceType, WriteValidInput valueType) { Assume.That(customFields.Data, Is.Not.Null, "HrbcFieldCreator cannot create custom fields!"); string fieldAlias = customFields.Data[$"{resourceType}"].Field.ToAlias(); var resourceList = new[] { 0, 1 }.Select(depKey => ResourceHelper.CreateResourceInstance(records, resourceType, depKey)); List <WriteResultItem> ids = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assume.That(ids, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); //Write data resourceList = ids.Select(item => ResourceHelper.CreateUpdatedResource(resourceType, item.Id, fieldAlias, FieldValueMapper.ValidInputMapper[valueType], true)); List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, null); Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, resourceType)); }
/// <summary> /// Send a request to update a list of resources /// </summary> /// <param name="resourceType"></param> /// <param name="fieldAlias"></param> /// <param name="fieldValue"></param> /// <param name="expectedCode"></param> /// <param name="records"></param> public static void UpdateListItem(Enums.ResourceType resourceType, string fieldAlias, Func <int, object> getFieldValue, HrbcRecordCreator records, Action <object> verifyActualValue = null, bool idRelatedFieldCreatedAutomatically = false, HrbcRecordCreator referenceRecords = null) { IEnumerable <XmlResource> resourceList = new int[] { 0, 1 }.Select(index => { return(ResourceHelper.CreateUpdatedResource(resourceType, records.Data[$"{resourceType.ToPrivateEnum()}{index}"].Id.ToString(), fieldAlias, getFieldValue(index), idRelatedFieldCreatedAutomatically, referenceRecords, index)); }); List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, null); Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); foreach (var item in result) { ReadAndVerify(resourceType, fieldAlias, item.Id, verifyActualValue); } }
/// <summary> /// Send a request to create a list of resources /// </summary> /// <param name="resourceType"></param> /// <param name="fieldAlias"></param> /// <param name="fieldValue"></param> /// <param name="cleaner"></param> /// <param name="records"></param> /// <param name="verifyActualValue"></param> /// <param name="idRelatedFieldCreatedAutomatically"></param> public static void CreateListItem(Enums.ResourceType resourceType, string fieldAlias, Func <int, object> getFieldValue, HrbcRecordDelete cleaner, HrbcRecordCreator records, Action <object> verifyActualValue = null, bool idRelatedFieldCreatedAutomatically = false) { var resourceList = new[] { 0, 1 }.Select(depKey => { return(ResourceHelper.CreateSingleResourceItem(resourceType, fieldAlias, getFieldValue(depKey), records, idRelatedFieldCreatedAutomatically, depKey, records)); }).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)); foreach (var item in result) { ReadAndVerify(resourceType, fieldAlias, item.Id, verifyActualValue); } }
public void TestUpdateListItem(Enums.ResourceType resourceType, string fieldName, WriteValidInput valueType) { string fieldValue = FieldValueMapper.ValidInputMapper[valueType]; var resourceList = new[] { 0, 1 }.Select(depKey => { var phase = new Phase { Id = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{depKey}"].FirstOrDefault().Id, }; phase.DictionaryValues[fieldName] = fieldValue; return(phase); }); List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList); Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType)); }
public void TestUpdateListItem(Enums.ResourceType resourceType, string fieldName, WriteInvalidInput valueType, int expectedCode) { //Prepare data var resourceList = new[] { 0, 1 }.Select(depKey => ResourceHelper.CreateResourceInstance(records, resourceType, depKey)); List <WriteResultItem> ids = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assume.That(ids, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); //Write data string fieldAlias = resourceType.ToResourceName() + "." + fieldName; resourceList = ids.Select(item => ResourceHelper.CreateUpdatedResource(resourceType, item.Id, fieldAlias, FieldValueMapper.InvalidMapper[valueType], true)); ErrorCode result = ResourceHelper.WriteResourcesFail(resourceList); //Verify the result Assert.That(result, MustBe.MatchingErrorCode(expectedCode), Enums.Message.WRONG_ERROR_CODE); }
public void TestUpdateListItem(Enums.ResourceType resourceType) { var resourcePhase = PhaseSearcher.Data.Options.Where(op => op.Alias == $"Option.P_{resourceType.ToResourceName()}Phase").SingleOrDefault(); var resourceList = new[] { 0, 1 }.Select(depKey => { var phase = new Phase { Id = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{depKey}"].FirstOrDefault().Id, PhaseObject = new Option() { ActualXMLTag = resourcePhase.Children.FirstOrDefault().Alias }, }; return(phase); }); List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList); Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType)); }
public void TestUpdateListItem(Enums.ResourceType resourceType, WriteInvalidInput valueType, int expectedCode) { //Prepare data 1 var resourceList = new[] { 0, 1 }.Select(depKey => ResourceHelper.CreateResourceInstance(records, resourceType, depKey)); List <WriteResultItem> ids = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assume.That(ids, MustBe.SuccessfullyWritten(resourceList.Count()), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); //Prepare data 2 Assume.That(customFields.Data, Is.Not.Null, "HrbcFieldCreator cannot create custom fields!"); string fieldAlias = customFields.Data[$"{resourceType}"].Field.ToAlias(); resourceList = ids.Select(item => ResourceHelper.CreateUpdatedResource(resourceType, item.Id, fieldAlias, FieldValueMapper.InvalidMapper[valueType], true)); //Write data ErrorCode result = ResourceHelper.WriteResourcesFail(resourceList); //Verify the result Assert.That(result, MustBe.MatchingErrorCode(expectedCode), Enums.Message.WRONG_ERROR_CODE); }
public void TestCreateListItem(Enums.ResourceType resourceType, string fieldName) { string resourceName = resourceType.ToResourceName(); string fieldAlias = resourceName + "." + fieldName; string fieldValue = validUserId.ToString(); var resourceList = new[] { 0, 1 }.Select(depKey => { var resource = ResourceHelper.CreateSingleResourceItem(resourceType, fieldAlias, fieldValue, referenceRecords, false, depKey, records); 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)); foreach (var item in result) { ReadAndVerify(resourceType, fieldAlias, item.Id); } }
public void TestCreateListItem(Enums.ResourceType resourceType, int recordNumber) { var resourceList = new List <XmlResource>(); //When PhaseMemo field is used, all phase fields will be written string fieldAlias = $"{resourceType.ToResourceName()}.{ResourceHelper.PhaseMemoField}"; for (int i = 0; i < recordNumber; i++) { resourceList.Add(ResourceHelper.CreateSingleResourceItem(resourceType, $"{resourceType.ToResourceName()}.{ResourceHelper.PhaseMemoField}", PhaseMemoValue, referenceRecords, true, index: i)); } List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, cleaner); Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); foreach (var item in result) { ReadAndVerify(resourceType, fieldAlias, item.Id, PhaseMemoValue); } }
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 void TestUpdateListItem(Enums.ResourceType resourceType, string fieldName) { string resourceName = resourceType.ToResourceName(); string fieldAlias = resourceName + "." + fieldName; string fieldValue = validUserId.ToString(); IEnumerable <XmlResource> resourceList = new int[] { 0, 1 }.Select(index => { XmlResource resource = ResourceHelper.CreateUpdatedResource(resourceType, records.Data[$"{resourceType.ToPrivateEnum()}{index}"].Id.ToString(), fieldAlias, fieldValue, false, referenceRecords, index); 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)); foreach (var item in result) { ReadAndVerify(resourceType, fieldAlias, item.Id); } }
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); } }
private void WriteAndVerify(Enums.ResourceType resourceType, int recordNumber, bool isUpdate = false) { List <Phase> resourceList = new List <Phase>(); Phase phase = new Phase(); for (int i = 0; i < recordNumber; i++) { if (isUpdate) { phase = new Phase { Id = phaseEntryReader.Data[$"{resourceType.ToPrivateEnum()}{i}"].First().Id }; } else { phase = PhaseHelper.CreatePhaseInstance(creatingRecords, resourceType, i); } resourceList.Add(phase); } List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList); Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); }