Esempio n. 1
0
 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());
 }
        private void WriteResourceWithFieldSettings(Enums.ResourceType resourceType, string fieldName, bool isReadOnly)
        {
            XmlResource resource     = ResourceHelper.CreateResourceInstance(records, resourceType);
            string      resourceName = resourceType.ToResourceName();
            string      fieldAlias   = resourceName + "." + fieldName;

            resource.DictionaryValues[fieldAlias] = Util.ToString(DateTime.Now);
            if (fieldName.Equals("P_PhaseDate"))
            {
                List <string> phaseList = OptionFieldHelper.GetOptionList($"Option.P_{resourceName}Phase");
                resource.DictionaryValues[$"{resourceName}.P_Phase"] = new Option()
                {
                    ActualXMLTag = phaseList.First()
                };
            }
            if (isReadOnly)
            {
                ErrorCode result = ResourceHelper.WriteResourceFail(resource, cleaner);
                Assert.That(result.Code, Is.EqualTo(Enums.PublicAPIResultCode.ParameterIsInvalid), Enums.Message.WRONG_ERROR_CODE);
            }
            else
            {
                string id = ResourceHelper.WriteResource(resource, cleaner);
                Assert.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            }
        }
Esempio n. 3
0
        public void TestWriteResourceWithReadOnlySetting(Enums.ResourceType resourceType, string fieldName)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            string fieldAlias   = resourceName + "." + fieldName;
            string optionMaster = GetOptionMaster(fieldAlias);

            Assume.That(optionMaster, Is.Not.Null.And.Not.Empty, "Cannot get the master option!");
            List <string> optionList = OptionFieldHelper.GetOptionList(optionMaster);

            Assume.That(optionMaster, Is.Not.Null.And.Not.Empty, "Cannot get the master option!");

            XmlResource resource = CreateResourceInstance(resourceType);

            resource.DictionaryValues[fieldAlias] = new Option()
            {
                ActualXMLTag = optionList.First()
            };
            if (fieldName == "P_Phase")
            {
                resource.DictionaryValues[$"{resourceName}.P_PhaseDate"] = Util.ToString(DateTime.Now);
            }

            ErrorCode result = WriteResourceFail(resource);

            Assert.That(result.Code, Is.EqualTo(Enums.PublicAPIResultCode.ParameterIsInvalid), Enums.Message.WRONG_ERROR_CODE);
        }
        public void TestUpdateListItem(Enums.ResourceType resourceType, string fieldName, string fieldValue)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            string fieldAlias   = resourceName + "." + fieldName;

            var resourceList = new[] { 1, 2 }.Select(depKey =>
            {
                var resource = CreateResourceInstance(resourceType, depKey);
                if (fieldName == "P_PhaseMemo")
                {
                    List <string> phaseList = OptionFieldHelper.GetOptionList($"Option.P_{resourceName}Phase");
                    Assume.That(phaseList, Is.Not.Null.And.Not.Empty, $"Cannot get the phase list of {resourceName}");
                    resource.DictionaryValues[$"{resourceName}.P_Phase"] = new Option()
                    {
                        ActualXMLTag = phaseList.First()
                    };
                    resource.DictionaryValues[$"{resourceName}.P_PhaseDate"] = Util.ToString(DateTime.Now);
                }
                return(resource);
            });

            List <WriteResultItem> ids = WriteResources(resourceType, resourceList);

            Assume.That(ids, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            Assume.That(ids.Select(t => t.Code), Is.All.EqualTo(0), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));

            resourceList = new List <XmlResource>()
            {
                CreateUpdatedResource(resourceType, ids.First().Id, fieldAlias, fieldValue),
                CreateUpdatedResource(resourceType, ids.Last().Id, fieldAlias, fieldValue)
            };
            ids = WriteResources(resourceType, resourceList);
            Assert.That(ids, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, resourceType));
            Assert.That(ids.Select(t => t.Code), Is.All.EqualTo(0), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
        }
        public void TestSearchOption(Enums.ResourceType resourceType, string fieldName, string condition)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            string fieldAlias   = resourceName + "." + fieldName;
            string optionMaster = GetOptionMaster(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!");

            string fieldValue1 = optionList.First();
            string fieldValue2 = optionList.Last();
            string fieldValue3 = optionList.Random();

            var resourceList = new Dictionary <int, string> {
                { 1, fieldValue1 }, { 2, fieldValue2 }, { 3, fieldValue2 },
            }.Select(item =>
            {
                var resource = CreateResourceInstance(resourceType, item.Key);
                resource.DictionaryValues[fieldAlias] = new Option()
                {
                    ActualXMLTag = item.Value
                };
                return(resource);
            });

            List <string> ids = WriteResources(resourceList);

            Assert.That(ids, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));

            //Verify
            ReadResourceAndVerify(resourceType, fieldAlias, condition, fieldValue1, fieldValue2);
        }
Esempio n. 6
0
        public void TestCreateListItem(Enums.ResourceType resourceType, string fieldName, WriteInvalidInput valueType, int expectedCode)
        {
            string resourceName = resourceType.ToResourceName();
            string fieldAlias   = resourceName + "." + fieldName;
            string fieldValue   = FieldValueMapper.InvalidMapper[valueType];

            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                var resource = ResourceHelper.CreateResourceInstance(records, resourceType, depKey);
                resource.DictionaryValues[fieldAlias] = fieldValue;
                if (fieldName == ResourceHelper.PhaseDateField)
                {
                    List <string> phaseList = OptionFieldHelper.GetOptionList($"Option.P_{resourceName}Phase");
                    Assume.That(phaseList, Is.Not.Null.And.Not.Empty, $"Cannot get the phase list of {resourceName}");
                    resource.DictionaryValues[$"{resourceName}.P_Phase"] = new Option()
                    {
                        ActualXMLTag = phaseList.First()
                    };
                }
                return(resource);
            }).ToList();

            ErrorCode result = ResourceHelper.WriteResourcesFail(resourceList, cleaner);

            Assert.That(result, Is.Not.Null, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            Assert.That(result.Code, Is.EqualTo(expectedCode), Enums.Message.WRONG_ERROR_CODE);
        }
Esempio n. 7
0
        public void TestUpdateSingleItem(Enums.ResourceType resourceType, string fieldName, string fieldValue)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            string fieldAlias   = resourceName + "." + fieldName;

            XmlResource resource = CreateResourceInstance(resourceType);

            string id = WriteResource(resourceType, resource);

            Assume.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));

            resource = CreateUpdatedResource(resourceType, id, fieldAlias, fieldValue);
            if (fieldValue == null)
            {
                resource.DictionaryValues.Remove(fieldAlias);
            }
            else
            {
                if (fieldName == "P_PhaseMemo")
                {
                    List <string> phaseList = OptionFieldHelper.GetOptionList($"Option.P_{resourceName}Phase");
                    Assume.That(phaseList, Is.Not.Null.And.Not.Empty, $"Cannot get the phase list of {resourceName}");
                    resource.DictionaryValues[$"{resourceName}.P_Phase"] = new Option()
                    {
                        ActualXMLTag = phaseList.First()
                    };
                    resource.DictionaryValues[$"{resourceName}.P_PhaseDate"] = Util.ToString(DateTime.Now);
                }
            }
            id = WriteResource(resourceType, resource);
            Assert.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, resourceType));
        }
        private static string GetOptionItem(string option)
        {
            string optionName = OptionFieldHelper.GetOptionList(option).FirstOrDefault();

            Assume.That(optionName, Is.Not.Null.And.Not.Empty, $"Cannot get the option name!");
            return(optionName);
        }
Esempio n. 9
0
        public void TestReadValidInput(Enums.ResourceType resourceType, string fieldName, ReadValidInput valueType)
        {
            string resourceName = resourceType.ToResourceName();
            string fieldAlias   = string.Format("{0}.{1}", resourceName, fieldName);
            string fieldValue   = FieldValueMapperRead.ValidInputMapper[valueType];

            XmlResource resource = ResourceHelper.CreateResourceInstance(records, resourceType);

            resource.DictionaryValues[fieldAlias] = fieldValue;

            if (fieldName == DateTimeSystemField.PhaseDate)
            {
                List <string> phaseList = OptionFieldHelper.GetOptionList($"Option.P_{resourceName}Phase");
                Assume.That(phaseList, Is.Not.Null.And.Not.Empty, $"Cannot get the phase list of {resourceName}");
                resource.DictionaryValues[$"{resourceName}.P_Phase"] = new Option()
                {
                    ActualXMLTag = phaseList.First()
                };
            }
            else
            if (fieldName == DateTimeSystemField.ActivityToDate)
            {
                resource.DictionaryValues[$"{resourceName}.{DateTimeSystemField.ActivityFromDate}"] = fieldValue;
            }

            string id = ResourceHelper.WriteResource(resource, cleaner);

            Assert.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceName));

            //Read & verify the field's value
            DateTimeValidator.ReadAndVerifyDate(resourceType, id, fieldAlias, fieldValue);
        }
Esempio n. 10
0
        public void TestUpdatedSingleItem(Enums.ResourceType resourceType, string fieldName)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            string fieldAlias   = resourceName + "." + fieldName;
            string optionMaster = GetOptionMaster(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!");

            var    updatedResource = CreateResourceInstance(resourceType, 1);
            string id = WriteResource(updatedResource);

            Assume.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));

            updatedResource = CreateUpdatedResource(resourceType, id, fieldAlias, new Option()
            {
                ActualXMLTag = optionList.First()
            });
            if (fieldName == "P_Phase")
            {
                updatedResource.DictionaryValues[$"{resourceName}.P_PhaseDate"] = Util.ToString(DateTime.Now);
            }
            id = WriteResource(updatedResource);

            Assert.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
        }
        public void TestReadValidInput(Enums.ResourceType resourceType, string fieldName)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            string fieldAlias   = resourceName + "." + fieldName;
            string optionMaster = GetOptionMaster(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!");

            string      fieldValue = optionList.First();
            XmlResource resource   = CreateResourceInstance(resourceType);

            resource.DictionaryValues[fieldAlias] = new Option()
            {
                ActualXMLTag = fieldValue
            };

            string id = WriteResource(resource);

            Assert.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));

            //Read & verify the field's value
            ReadAndVerifyData(resourceType, id, fieldAlias, fieldValue);
        }
Esempio n. 12
0
        public void TestCreateContractOptionField()
        {
            string   id       = string.Empty;
            string   clientId = (new ResourceCreator <Client>(PublicApiAdapter.CreateAdapterForDefaultConnection())).Create();
            Contract resource = new Contract
            {
                Id             = "-1",
                Name           = "Jacky Nam",
                Client         = clientId,
                ContractorType = new Option()
                {
                    ActualXMLTag = OptionFieldHelper.GetOptionList(Enums.Options.ContructorType).Random()
                },
            };

            id = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(resource, null);
            PublicAPISetUp.ListContractId.Add(id);
            PublicAPISetUp.ListClientId.Add(clientId);

            int  resourceId = -1;
            bool parsed     = Int32.TryParse(id, out resourceId);

            Assert.IsTrue(parsed);
            Assert.IsTrue(resourceId > 0, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Contract"));

            //Verify data
            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "Contract.P_Name", resource.Name },
                { "Contract.P_Client", resource.Client },
                { "Contract.P_ContractorType", (resource.ContractorType as Option).ActualXMLTag },
            };

            VerifyFieldData(id, fields);
        }
Esempio n. 13
0
        /// <summary>
        /// Create phase with generate a system date fields
        /// </summary>
        /// <returns>List of phase ids</returns>
        public static List <string> CreatePhaseWithGenerateSystemDateTimeField()
        {
            Client resource = new Client
            {
                Id    = "-1",
                Name  = "Test target client",
                Owner = "1"
            };
            string resourceId = ResourceHelper.WriteResource(resource, null);

            Assume.That(resourceId, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Client"));

            List <string> phaseList = OptionFieldHelper.GetOptionList("Option.P_ClientPhase");
            List <string> phaseIds  = new List <string>();

            for (int i = 0; i < 4; i++)
            {
                var phase = new Phase
                {
                    Id          = "-1",
                    Resource    = ((int)Enums.ResourceType.Client).ToString(),
                    ResourceId  = resourceId,
                    Date        = Util.ToString(DateTime.Now.AddSeconds(i)),
                    PhaseObject = new Option {
                        ActualXMLTag = phaseList[i]
                    }
                };
                string id = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(phase, null);
                Assume.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Phase"));
                phaseIds.Add(id);
                Thread.Sleep(10000); //Sleep 5 seconds to make sure system date time is difference in next creating
            }
            return(phaseIds);
        }
        public void TestCreateListItem(Enums.ResourceType resourceType, string fieldName, string fieldValue)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            string fieldAlias   = resourceName + "." + fieldName;

            List <XmlResource> resources = new int[] { 1, 2 }.Select(t =>
            {
                XmlResource item = CreateResourceInstance(resourceType, t);
                item.DictionaryValues[fieldAlias] = fieldValue;
                if (fieldName == "P_PhaseMemo")
                {
                    List <string> phaseList = OptionFieldHelper.GetOptionList($"Option.P_{resourceName}Phase");
                    Assume.That(phaseList, Is.Not.Null.And.Not.Empty, $"Cannot get the phase list of {resourceName}");
                    item.DictionaryValues[$"{resourceName}.P_Phase"] = new Option()
                    {
                        ActualXMLTag = phaseList.First()
                    };
                    item.DictionaryValues[$"{resourceName}.P_PhaseDate"] = Util.ToString(DateTime.Now);
                }
                return(item);
            }).ToList();

            List <WriteResultItem> result = WriteResources(resourceType, resources);

            Assert.That(result, Is.Not.Null.And.Not.Empty);
            Assert.That(result.Select(t => t.Code), Is.All.EqualTo(0), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
        }
Esempio n. 15
0
        private List <string> GetPhaseListResources(Enums.ResourceType resourceType)
        {
            switch (resourceType)
            {
            case Enums.ResourceType.Client:
                return(OptionFieldHelper.GetOptionList(Enums.Options.ClientPhase));

            case Enums.ResourceType.Resume:
                return(OptionFieldHelper.GetOptionList(Enums.Options.ResumePhase));

            case Enums.ResourceType.Process:
                return(OptionFieldHelper.GetOptionList(Enums.Options.ProcessPhase));

            case Enums.ResourceType.Job:
                return(OptionFieldHelper.GetOptionList(Enums.Options.JobPhase));

            case Enums.ResourceType.Activity:
                return(OptionFieldHelper.GetOptionList(Enums.Options.ActivityPhase));

            case Enums.ResourceType.Recruiter:
                return(OptionFieldHelper.GetOptionList(Enums.Options.RecruiterPhase));

            case Enums.ResourceType.Contract:
                return(OptionFieldHelper.GetOptionList(Enums.Options.ContractPhase));

            case Enums.ResourceType.Candidate:
                return(OptionFieldHelper.GetOptionList(Enums.Options.CandidatePhase));

            case Enums.ResourceType.Sales:
                return(OptionFieldHelper.GetOptionList(Enums.Options.SalesPhase));

            default:
                return(null);
            }
        }
Esempio n. 16
0
        public void TestCreateProcessCheckBox()
        {
            List <string> optionList = OptionFieldHelper.GetOptionList(Enums.Options.ProcessClose);
            Process       resource   = CreateProcessWithPhase();

            resource.Close = new Option()
            {
                ActualXMLTag = optionList.Random()
            };

            string id = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(resource, cleanupAction: null);

            int  resourceId = -1;
            bool parsed     = Int32.TryParse(id, out resourceId);

            Assert.IsTrue(parsed);
            Assert.IsTrue(resourceId > 0, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Process"));
            PublicAPISetUp.ListProcessId.Add(id);

            //Verify data
            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "Process.P_Close", (resource.Close as Option).ActualXMLTag },
            };

            VerifyFieldData(id, fields);
        }
        public void TestCreateListItem(Enums.ResourceType resourceType, string fieldName, WriteValidInput valueType)
        {
            string resourceName = resourceType.ToResourceName();
            string fieldAlias   = resourceName + "." + fieldName;
            string fieldValue   = FieldValueMapper.ValidInputMapper[valueType];

            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                var resource = ResourceHelper.CreateResourceInstance(records, resourceType, depKey);
                resource.DictionaryValues[fieldAlias] = fieldValue;
                if (fieldName == ResourceHelper.PhaseDateField)
                {
                    List <string> phaseList = OptionFieldHelper.GetOptionList($"Option.P_{resourceName}Phase");
                    Assume.That(phaseList, Is.Not.Null.And.Not.Empty, $"Cannot get the phase list of {resourceName}");
                    resource.DictionaryValues[$"{resourceName}.P_Phase"] = new Option()
                    {
                        ActualXMLTag = phaseList.First()
                    };
                }
                return(resource);
            }).ToList();

            List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, cleaner);

            Assert.That(result, Is.Not.Null, "The response data is incorrect!");
            Assert.That(result.Count, Is.EqualTo(resourceList.Count), "The response data is incorrect!");
            foreach (var item in result)
            {
                Assert.That(item.Code, Is.EqualTo(Enums.PublicAPIResultCode.Success), Enums.Message.WRONG_ERROR_CODE);
                Assert.That(item.Id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            }
        }
Esempio n. 18
0
        private CreateRecordRequest.IBuilderWithResource InitCreateResourceRequest(int resourceNumber, Func <Enums.ResourceType, IEnumerable <string> > getFieldList)
        {
            Dictionary <Enums.ResourceType, ulong> phaseList = new Dictionary <Enums.ResourceType, ulong>();

            foreach (var resourceType in Enum.GetValues(typeof(Enums.ResourceType)))
            {
                if ((Enums.ResourceType)resourceType != Enums.ResourceType.Contract)
                {
                    phaseList[(Enums.ResourceType)resourceType] =
                        ulong.Parse(OptionFieldHelper.GetOptionItem(OptionFieldHelper.GetOptionList($"Option.P_{((Enums.ResourceType)resourceType).ToResourceName()}Phase").First()).Id);
                }
            }

            CreateRecordRequest.IBuilder result = ResourceRequest.CreateRecords();
            foreach (var symbolType in Enum.GetValues(typeof(SameResultSymbolType)))
            {
                foreach (var resourceType in Enum.GetValues(typeof(Enums.ResourceType)))
                {
                    result.Append(((Enums.ResourceType)resourceType).ToPrivateEnum(),
                                  content =>
                    {
                        AppendCommonContent(content, (SameResultSymbolType)symbolType, (Enums.ResourceType)resourceType, phaseList);
                        foreach (var field in CommonConstant.NoneTelephoneTextField[(Enums.ResourceType)resourceType])
                        {
                            content.Append(field, KeywordHelper.GetFieldValueBasedOnSymbolType(field, (SameResultSymbolType)symbolType, GetSymbolIndex((SameResultSymbolType)symbolType)));
                        }
                        foreach (var field in CommonConstant.ApplicationNoneTelephoneTextField)
                        {
                            content.Append(field, KeywordHelper.GetFieldValueBasedOnSymbolType(field, (SameResultSymbolType)symbolType, GetSymbolIndex((SameResultSymbolType)symbolType)));
                        }
                    }, $"{resourceType}{symbolType}");
                }
            }
            return(result as CreateRecordRequest.IBuilderWithResource);
        }
Esempio n. 19
0
        /// <summary>
        /// Get option list of user fields
        /// </summary>
        /// <param name="masterOption">Master option</param>
        /// <returns>List of options</returns>
        public static List <string> InitUserFieldOptionReader(string masterOption)
        {
            List <string> optionList = OptionFieldHelper.GetOptionList(masterOption);

            Assume.That(optionList, Is.Not.Null.And.Not.Empty, "Cannot read the option list");
            return(optionList);
        }
        public void TestCreatePhaseFlow()
        {
            Option option = OptionFieldHelper.GetOptionItem("Option.P_ClientPhase");
            ulong  optionClientPhaseId = ulong.Parse(option.Id);
            ulong  clientPhaseId       = phaseFlowCreator.Data.Single();

            Assert.That(clientPhaseId, Is.EqualTo(optionClientPhaseId), "Phase is not match");
        }
Esempio n. 21
0
        /// <summary>
        /// Get phase list by resource type
        /// </summary>
        /// <param name="resourceType">Resource Type</param>
        /// <returns>Phase list</returns>
        private static List <string> GetPhaseList(Enums.ResourceType resourceType)
        {
            string        resourceName = resourceType.ToResourceName();
            List <string> phaseList    = OptionFieldHelper.GetOptionList($"Option.P_{resourceName}Phase");

            Assume.That(phaseList, Is.Not.Null.And.Not.Empty, $"Cannot get the phase list of {resourceName}");
            return(phaseList);
        }
Esempio n. 22
0
        public TestAccessSettingUserField() : base()
        {
            InitFieldCreator();
            InitFieldAclUpdater();
            InitRecordCreator();

            optionList = OptionFieldHelper.GetOptionList(MasterOption);
            Assume.That(optionList, Is.Not.Null.And.Not.Empty, "Cannot read the option list");
        }
Esempio n. 23
0
        /// <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);
        }
Esempio n. 24
0
        public void TestReadPhaseFlow()
        {
            Option option = OptionFieldHelper.GetOptionItem("Option.P_ClientPhase");
            int    optionClientPhaseId = int.Parse(option.Id);
            int    clientPhaseId       = phaseFlowReader.Data.Where(dic => dic.Value.Depth == "1").Single().Key;

            Assert.That(clientPhaseId, Is.EqualTo(optionClientPhaseId), "Phase is not match");
            Assert.That(phaseFlowReader.Data.Values.Where(val => val.Depth == "1").Single().FlowItems, Is.Not.Null, "The flow rule is null");
            Assert.That(phaseFlowReader.Data.Values.Where(val => val.Depth == "1").Single().FlowItems.Count, Is.GreaterThan(0), "The flow rule is emtpy");
        }
Esempio n. 25
0
        public void TestCreateProcessAllFields()
        {
            string id = string.Empty;

            PrepareData();
            Process resource = new Process
            {
                Id        = "-1",
                Owner     = "1",
                Client    = clientId,
                Candidate = candidateId,
                Recruiter = recruiterId,
                Job       = jobId,
                Resume    = resumeId,
                Phase     = new Option()
                {
                    ActualXMLTag = PhaseList[0]
                },
                PhaseDate = Util.ToString(DateTime.Now),
                PhaseMemo = Util.GetUniqueString(10, false),
                Close     = new Option()
                {
                    ActualXMLTag = OptionFieldHelper.GetOptionList(Enums.Options.ProcessClose)[0]
                },
                CloseReason = new Option()
                {
                    ActualXMLTag = OptionFieldHelper.GetOptionList(Enums.Options.ProcessReason)[0]
                },
                ExpectedClosingDate = Util.ToString(DateTime.Now.AddDays(10), true),
                ExpectedSalesAmount = Util.GetRandomNumber().ToString(),
                //PhaseCalendar = new Option()
                //{
                //    ActualXMLTag = OptionFieldHelper.GetOptionList(Enums.Options.CalendarDisplay)[0]
                //},
            };

            id = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(resource, cleanupAction: null);

            int  resourceId = -1;
            bool parsed     = Int32.TryParse(id, out resourceId);

            Assert.IsTrue(parsed);
            Assert.IsTrue(resourceId > 0, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Process"));
            PublicAPISetUp.ListProcessId.Add(id);

            //Verify data
            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "Process.P_Owner", resource.Owner },
                { "Process.P_Phase", (resource.Phase as Option).ActualXMLTag },
                { "Process.P_PhaseDate", resource.PhaseDate },
            };

            VerifyFieldData(id, fields);
        }
Esempio n. 26
0
 /// <summary>
 /// Get last option phase id
 /// </summary>
 /// <param name="resourceType">Resource type</param>
 /// <param name="index">Index of phase list</param>
 /// <returns>Option list</returns>
 public static ulong GetLastPhaseOptionId(Enums.ResourceType resourceType, int index = 0)
 {
     if (index != 0)
     {
         return(ulong.Parse(OptionFieldHelper.GetOptionItem(OptionFieldHelper.GetOptionList(phaseOption[resourceType])[index]).Id));
     }
     else
     {
         return(ulong.Parse(OptionFieldHelper.GetOptionItem(OptionFieldHelper.GetOptionList(phaseOption[resourceType]).Last()).Id));
     }
 }
        public void TestReadMultiOrder(Enums.ResourceType resourceType, string fieldName1, string fieldName2)
        {
            string        resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            List <string> fieldList    = new List <string>()
            {
                resourceName + "." + fieldName1, resourceName + "." + fieldName2
            };
            string fieldAlias1 = fieldList.First();
            string fieldAlias2 = fieldList.Last();

            List <XmlResource> resourceList = new Dictionary <int, string[]>
            {
                [1] = new string[] { "Anpha", "Beta" },
                [2] = new string[] { "Gamma", "Delta" },
                [3] = new string[] { "Epsilon", "Zeta" }
            }
            .Select(item =>
            {
                var resource = CreateResourceInstance(resourceType, item.Key);
                resource.DictionaryValues[fieldAlias1] = item.Value[0];
                resource.DictionaryValues[fieldAlias2] = item.Value[1];

                if (fieldName1 == "P_PhaseMemo" || fieldName2 == "P_PhaseMemo")
                {
                    List <string> phaseList = OptionFieldHelper.GetOptionList($"Option.P_{resourceName}Phase");
                    Assume.That(phaseList, Is.Not.Null.And.Not.Empty, $"Cannot get the phase list of {resourceName}");
                    resource.DictionaryValues[$"{resourceName}.P_Phase"] = new Option()
                    {
                        ActualXMLTag = phaseList.First()
                    };
                    resource.DictionaryValues[$"{resourceName}.P_PhaseDate"] = Util.ToString(DateTime.Now);
                }

                return(resource);
            }).ToList();

            List <string> idList = WriteResources(resourceType, resourceList);

            Assume.That(idList, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));

            Dictionary <string, object> urlParameter = new Dictionary <string, object>()
            {
                { "partition", AuthenticationInfoProvider.Current.DefaultPartition },
                { "order", string.Format("{0}:desc,{1}:asc", fieldAlias1, fieldAlias2) },
            };

            Handler handler = PublicApiAdapter.CreateAdapterForDefaultConnection().Read(resourceType.ToString(), urlParameter);

            Assert.That(handler, Is.Not.Null, "Cannot read resource!");
            ErrorCode result = XmlHelper.ParseXMLString <ErrorCode>(handler.RawContent);

            Assert.That(result.Code, Is.EqualTo(Enums.PublicAPIResultCode.InvalidParameterValue), "Error code is not matched!");
        }
Esempio n. 28
0
        public void TestCreateSalesPhaseDateInvalidValue(string fieldAlias, object fieldValue, int code)
        {
            Sales resource = CreateSalesResourceSpecifiedData();

            resource.DictionaryValues["Sales.P_Phase"] = new Option()
            {
                ActualXMLTag = OptionFieldHelper.GetOptionList(Enums.Options.SalesPhase).Random()
            };
            resource.DictionaryValues[fieldAlias] = fieldValue;
            ErrorCode error = (PublicApiAdapter.CreateAdapterForDefaultConnection()).WriteFail(resource, cleanupAction: null);

            Assert.NotNull(error, "Error code is null!");
            Assert.AreEqual(code, error.Code, Enums.Message.WRONG_ERROR_CODE);
        }
Esempio n. 29
0
        public void TestUpdateListItem(Enums.ResourceType resourceType, string fieldName)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            string fieldAlias   = resourceName + "." + fieldName;
            string optionMaster = GetOptionMaster(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!");

            List <XmlResource> resourceList = new List <XmlResource>
            {
                CreateResourceInstance(resourceType, 2),
                CreateResourceInstance(resourceType, 1)
            };

            List <WriteResultItem> result = this.WriteResources(resourceType, resourceList);

            Assume.That(result, Is.Not.Null, "The response data is not right!");
            Assume.That(result.Count, Is.EqualTo(resourceList.Count), "The response data is not right!");
            foreach (var item in result)
            {
                Assume.That(item.Code, Is.EqualTo(Enums.PublicAPIResultCode.Success), Enums.Message.WRONG_ERROR_CODE);
                Assume.That(item.Id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            }

            resourceList = result.Select(item =>
            {
                var resource = CreateUpdatedResource(resourceType, item.Id, fieldAlias, new Option()
                {
                    ActualXMLTag = optionList.First()
                });
                if (fieldName == "P_Phase")
                {
                    resource.DictionaryValues[$"{resourceName}.P_PhaseDate"] = Util.ToString(DateTime.Now);
                }
                return(resource);
            }).ToList();

            result = this.WriteResources(resourceType, resourceList);
            Assert.That(result, Is.Not.Null, "The response data is not right!");
            Assert.That(result.Count, Is.EqualTo(resourceList.Count), "The response data is not right!");
            foreach (var item in result)
            {
                Assert.That(item.Code, Is.EqualTo(Enums.PublicAPIResultCode.Success), Enums.Message.WRONG_ERROR_CODE);
                Assert.That(item.Id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            }
        }
Esempio n. 30
0
        public void TestUpdateProcessWithAllOptionFields()
        {
            var publicApiAdapter = PublicApiAdapter.CreateAdapterForDefaultConnection();
            //string id = PrepareProcess();
            Process resource = CreateProcessWithPhase();
            string  id       = publicApiAdapter.WriteSuccess(resource, cleanupAction: null);

            Assume.That(!string.IsNullOrEmpty(id), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Process"));

            Process process = new Process()
            {
                Id    = id,
                Phase = new Option()
                {
                    ActualXMLTag = PhaseList.Last()
                },
                PhaseDate = Util.ToString(DateTime.Now),
                Close     = new Option()
                {
                    ActualXMLTag = OptionFieldHelper.GetOptionList(Enums.Options.ProcessClose)[0]
                },
                CloseReason = new Option()
                {
                    ActualXMLTag = OptionFieldHelper.GetOptionList(Enums.Options.ProcessReason)[0]
                },
                //PhaseCalendar = new Option()
                //{
                //    ActualXMLTag = OptionFieldHelper.GetOptionList(Enums.Options.CalendarDisplay)[0]
                //},
            };

            id = publicApiAdapter.WriteSuccess(process, cleanupAction: null);

            int  resourceId = -1;
            bool parsed     = Int32.TryParse(id, out resourceId);

            Assert.IsTrue(parsed);
            Assert.IsTrue(resourceId > 0, string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, "Process"));

            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "Process.P_Phase", (process.Phase as Option).ActualXMLTag },
                { "Process.P_PhaseDate", process.PhaseDate },
                { "Process.P_Close", (process.Close as Option).ActualXMLTag },
                { "Process.P_CloseReason", (process.CloseReason as Option).ActualXMLTag },
            };

            VerifyFieldData(id, fields);
        }