public void TestUpdateRecruiterNonNullToNull()
        {
            string    id       = PrepareRecruiter();
            Recruiter resource = new Recruiter
            {
                Id   = id,
                Name = string.Empty
            };

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


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

            //Verify data
            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "Recruiter.P_Name", string.Empty },
            };

            VerifyFieldData(int.Parse(id), fields);
        }
        public void TestCreateGeneralFieldSettingValidation(Enums.ResourceType resourceType, string property)
        {
            string fieldAlias = customFields.Data[$"{resourceType}-{property}"].Field.ToAlias();

            Assume.That(fieldAlias, Is.Not.Null.And.Not.Empty, "Cannot create a user field for " + resourceType);

            //Create a resource entry with having attachment
            Attachment attachment = new Attachment()
            {
                FileName    = FileNameDefault,
                ContentType = ContentTypeDefault,
                Content     = ContentDefault,
            };

            XmlResource resource = CreateResourceInstance(resourceType);

            resource.DictionaryValues[fieldAlias] = attachment;

            string id = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(resource, cleaner.Delete);

            Assert.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
        }
Example #3
0
        public void TestUpdateContractNullToNonNull()
        {
            var publicApiAdapter = PublicApiAdapter.CreateAdapterForDefaultConnection();
            //Create a Contract
            string id       = string.Empty;
            string clientId = (new ResourceCreator <Client>(PublicApiAdapter.CreateAdapterForDefaultConnection())).Create();

            Assume.That(!string.IsNullOrEmpty(clientId));
            Contract resource = new Contract
            {
                Id     = "-1",
                Client = clientId,
                Name   = string.Empty
            };

            id = publicApiAdapter.WriteSuccess(resource, null);
            Assert.That(id, Is.Not.Null.And.Not.Empty);
            PublicAPISetUp.ListContractId.Add(id);
            PublicAPISetUp.ListClientId.Add(clientId);

            resource = new Contract
            {
                Id   = id,
                Name = Util.GetUniqueString(20, false)
            };

            id = publicApiAdapter.WriteSuccess(resource, null);


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

            //Verify data
            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "Contract.P_Name", resource.Name },
            };

            VerifyFieldData(id, fields);
        }
        /// <summary>
        /// Creates a new Recruiter
        /// </summary>
        /// <param name="clientId">Client Id</param>
        /// <returns></returns>
        private string CreateRecruiterResourceSpecifiedData(string clientId)
        {
            //Create a Recruiter
            string    id       = string.Empty;
            Recruiter resource = new Recruiter
            {
                Id     = "-1",
                Owner  = "1",
                Client = clientId,
                Name   = "The porters company in japan - Tokyo"
            };

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

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

            Assume.That(parsed);
            Assume.That(resourceId > 0, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Recruiter"));
            return(id);
        }
Example #5
0
        public void TestReadSalesWhiteListKeyword(bool isSingle)
        {
            string value = isSingle ? nameKeyword : string.Format("{0},{1}", nameKeyword, memoKeyword);
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { Parttion, AuthenticationInfoProvider.Current.DefaultPartition },
                { "keywords", value }
            };
            ReadResponseData <Sales> result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Sales>(parameters);

            Assert.AreEqual(Enums.PublicAPIResultCode.Success, result.Code,
                            string.Format(Enums.Message.READ_RESOURCE_FAILED, "Sales"));

            //Verify existing of XML element
            ResourceHelper.VerifyListContainElement(result.Items, fields.Keys.ToList());

            //Verify the Count/Start/Total
            Assert.AreEqual(result.Start, 0, Enums.Message.START_ERROR);
            Assert.LessOrEqual(result.Count, 10, Enums.Message.COUNT_ERROR); //Default: 10
            Assert.GreaterOrEqual(result.Total, isSingle? 1 : 2, Enums.Message.TOTAL_ERROR);

            //Verify the type of fields in fieldList
            ResourceHelper.VerifyTypeOfField(result.Items, fields);

            //Verify the keyword
            foreach (Sales sales in result.Items)
            {
                if (isSingle)
                {
                    StringAssert.Contains(nameKeyword, sales.BillingClient,
                                          string.Format(Enums.Message.KEYWORD_NOT_MATCH, isSingle, "Sales's Billing Client", value));
                }
                else
                {
                    Assert.IsTrue(sales.BillingClient.Contains(nameKeyword) || sales.BillingName.Contains(memoKeyword),
                                  string.Format(Enums.Message.KEYWORD_NOT_MATCH, isSingle, "Sales's Billing Client & Name", value));
                }
            }
        }
Example #6
0
        public void TestUpdateContractNonNullToNull()
        {
            string   id       = PrepareContract();
            Contract resource = new Contract
            {
                Id   = id,
                Name = string.Empty
            };

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


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

            //Verify data
            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "Contract.P_Name", string.Empty },
            };

            VerifyFieldData(id, fields);
        }
Example #7
0
        public void TestReadPartitionStartGreaterMaxStart()
        {
            var publicApiAdapter = PublicApiAdapter.CreateAdapterForDefaultConnection();
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "request_type", 1 },
                { "start", 0 }
            };
            ReadResponseData <Partition> beforeResult = publicApiAdapter.ReadSuccess <Partition>(parameters);

            Assert.AreEqual(Enums.PublicAPIResultCode.Success, beforeResult.Code, string.Format(Enums.Message.READ_RESOURCE_FAILED, "User"));

            //Read Max number + 1 of Start
            parameters["start"] = beforeResult.Total + 1;

            XmlHandler result = publicApiAdapter.Read <Partition>(parameters) as XmlHandler;

            Assert.NotNull(result, "Result is null!");
            ErrorCode errorCode = XmlHelper.ParseXMLString <ErrorCode>(result.RawContent);

            Assert.AreEqual(Enums.PublicAPIResultCode.InvalidParameterValue, errorCode.Code, Enums.Message.INVALID_PARAMETER_VALUE);
        }
Example #8
0
        public void TestReadUserRequestType(int requestType)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { Partition, AuthenticationInfoProvider.Current.DefaultPartition },
                { "request_type", requestType }
            };
            ReadResponseData <User> result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <User>(parameters);

            Assert.AreEqual(Enums.PublicAPIResultCode.Success, result.Code, string.Format(Enums.Message.READ_RESOURCE_FAILED, "User"));

            //Verify existing of XML element
            ResourceHelper.VerifyListContainElement(result.Items, fields.Keys.ToList());

            //Verify existing of Count/Total/Start
            Assert.GreaterOrEqual(result.Count, 0, Enums.Message.COUNT_ERROR);
            Assert.GreaterOrEqual(result.Total, 0, Enums.Message.TOTAL_ERROR);
            Assert.GreaterOrEqual(result.Start, 0, Enums.Message.START_ERROR);

            //Verify the type of fields
            ResourceHelper.VerifyTypeOfField(result.Items, fields);
        }
Example #9
0
        public void TestReadOtherValidInput(Enums.ResourceType resourceType, string lengthType, Enums.TextType textType)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            string fieldAlias   = string.Format("{0}.{1}", resourceName, AppField);

            //Check registered application field
            CheckRegisteredField(resourceType, AppField);

            uint   characterNumber = GetStringLength(lengthType);
            string fieldValue      = Util.GetRandomText(textType, characterNumber);

            XmlResource resource = CreateResourceInstance(resourceType);

            resource.DictionaryValues[fieldAlias] = fieldValue;

            string id = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(resource, cleaner.Delete);

            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);
        }
        public void TestUpdateProcessInvalidPhaseDate(string fieldAlias, object fieldValue)
        {
            Process resource = CreateProcessWithPhase();
            string  id       = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(resource, cleanupAction: null);

            Assume.That(!string.IsNullOrEmpty(id), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Process"));
            resource = new Process()
            {
                Id    = id,
                Phase = new Option()
                {
                    ActualXMLTag = PhaseList.Last()
                },
                PhaseDate = Util.ToString(DateTime.Now),
            };

            resource.DictionaryValues[fieldAlias] = fieldValue;
            ErrorCode error = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteFail(resource, cleanupAction: null);

            Assert.NotNull(error, "Error code is null!");
            Assert.AreEqual(Enums.PublicAPIResultCode.InvalidPhase, error.Code, "Wrong error code!");
        }
Example #11
0
        public void TestUpdateFieldUsingEmpty_Fail(string fieldName, string fieldValue)
        {
            var    publicApiAdapter = PublicApiAdapter.CreateAdapterForDefaultConnection();
            Client client           = new Client()
            {
                Id    = "-1",
                Owner = "1",
            };

            client.DictionaryValues[fieldName] = fieldValue;

            // Create New Resource
            string clientId = publicApiAdapter.WriteSuccess(client, null);

            Assume.That(!string.IsNullOrEmpty(clientId), "Unable to create new resource");

            // Adding id into the static list for further cleanup
            ids.Add(clientId);

            // Update Resource
            client = new Client()
            {
                Id = clientId,
            };
            client.DictionaryValues[fieldName] = string.Empty;

            XmlHandler handler = publicApiAdapter.Write(client, AuthenticationInfoProvider.Current.DefaultPartition) as XmlHandler;

            Assert.NotNull(handler);
            Assert.NotNull(handler.XML);
            Assert.AreEqual(HttpStatusCode.OK, handler.HttpCode);

            ErrorCode xmlCode = XmlHelper.ParseXMLString <ErrorCode>(handler.RawContent);

            Assert.NotNull(xmlCode);

            Assert.AreEqual(Enums.PublicAPIResultCode.InvalidParameterValue, xmlCode.Code,
                            string.Format("It shouldn't be possible to update resource: {0} using Empty Value", clientId));
        }
        /// <summary>
        /// Send a request to read resource. Parse response's xml to ReadResponseData.
        /// </summary>
        /// <param name="resourceName"></param>
        /// <param name="id"></param>
        /// <param name="fieldAlias"></param>
        /// <param name="fieldValue"></param>
        /// <returns>empty</returns>
        private void ReadAndVerifyData(Enums.ResourceType resourceType, string id, string fieldAlias, string fieldValue)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();

            if (fieldValue == "InvalidFieldAlias")
            {
                fieldAlias = "A_TestXXX";
                fieldValue = "(Content)";
            }

            Dictionary <string, object> urlParameters = new Dictionary <string, object>()
            {
                { "partition", AuthenticationInfoProvider.Current.DefaultPartition },
                { "condition", $"{resourceName}.P_Id:eq={id}" },
                { "field", $"{fieldAlias}{fieldValue}" }
            };

            XmlHandler xmlResult = PublicApiAdapter.CreateAdapterForDefaultConnection().Read(resourceType.ToString(), urlParameters) as XmlHandler;
            ReadResponseData <ErrorCode> parseResult = XmlHelper.ParseXMLString <ReadResponseData <ErrorCode> >(xmlResult.RawContent);

            Assert.That(parseResult.Code, Is.EqualTo(Enums.PublicAPIResultCode.InvalidParameterValue), Enums.Message.WRONG_ERROR_CODE);
        }
Example #13
0
        /// <summary>
        /// Get alias by id
        /// </summary>
        /// <param name="level"></param>
        /// <param name="id"></param>
        /// <returns>string</returns>
        private string GetAliasById(int level, string id)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { Partition, AuthenticationInfoProvider.Current.DefaultPartition },
                { "level", -1 }
            };
            XmlHandler resultAllLevel = PublicApiAdapter.CreateAdapterForDefaultConnection().Read <Option>(parameters) as XmlHandler;

            Assert.NotNull(resultAllLevel, "Failed to parse the server's response!");
            ReadResponseData <Option> parseResult = XmlHelper.ParseXMLString <ReadResponseData <Option> >(resultAllLevel.RawContent);

            Assert.That(parseResult.Code, Is.EqualTo(Enums.PublicAPIResultCode.Success), Enums.Message.WRONG_ERROR_CODE);

            string levelOption = "Option/Item"; // Level: 0

            for (int i = 1; i <= level; i++)
            {
                levelOption += "/Items/Item";
            }

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(resultAllLevel.RawContent);
            XmlNodeList listAllLevel = doc.SelectNodes(levelOption);

            string alias = null;

            foreach (XmlNode item in listAllLevel)
            {
                if (item.SelectSingleNode("Option.P_Id").InnerText == id)
                {
                    alias = item.SelectSingleNode("Option.P_Alias").InnerText;
                    break;
                }
            }
            //alias = listAllLevel.Cast<XmlNode>().Select(x => x.SelectSingleNode("Option.P_Alias").InnerText).FirstOrDefault(x => x == id);
            return(alias);
        }
        public void ReadSpecialItemState(Enums.ResourceType resourceType, ValidTestCases.ItemState itemState, string parameter, string expression, int expectedCode)
        {
            string resourceName = resourceType.ToResourceName();
            Dictionary <string, object> urlParameters = new Dictionary <string, object>()
            {
                { ResourceHelper.Partition, AuthenticationInfoProvider.Current.DefaultPartition },
                { parameter, $"{resourceName}.{expression}" }
            };

            ValidTestCases.ItemStateMapper[itemState](urlParameters);
            if (expectedCode == Enums.PublicAPIResultCode.Success)
            {
                var result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess(resourceType.ToString(), urlParameters);
                Assert.That(result, MustBe.ReadSuccess(0), Enums.Message.WRONG_ERROR_CODE);
                Assert.That(result.Total, Is.GreaterThanOrEqualTo(TotalNumberOfRecordSet), Enums.Message.TOTAL_ERROR);
            }
            else
            {
                var result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadFail(resourceType.ToString(), urlParameters);
                Assert.That(result, MustBe.MatchingErrorCode(expectedCode), Enums.Message.WRONG_ERROR_CODE);
            }
        }
Example #15
0
        public void TestWithAllParametersSuccess(int requestType, int count, int start)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "request_type", requestType },
                { "count", count },
                { "start", start },
            };
            ReadResponseData <Partition> result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Partition>(parameters);

            Assert.NotNull(result, "Result is null!");
            Assert.AreEqual(result.Count, count, "Count is not matched!");
            Assert.AreEqual(0, result.Code, "Code is not equal to 0!");
            Assert.NotNull(result.Items, "Item element is null!");
            Assert.AreEqual(result.Items.Count, count, "Item count is not matched!");
            List <string> fieldList = new List <string>()
            {
                "Partition.P_Id", "Partition.P_Name", "Partition.P_CompanyId"
            };

            ResourceHelper.VerifyListContainElement <Partition>(result.Items, fieldList);
        }
Example #16
0
        public void TestCreateProcessReferenceField()
        {
            Process resource = CreateProcess();

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

            int  resourceId = -1;
            bool parsed     = int.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_JobOwner", resource.JobOwner }
            };

            VerifyFieldData(id, fields);
        }
        /// <summary>
        /// Send a request to read resource. Parse response's xml to ReadResponseData.
        /// </summary>
        /// <param name="resourceName"></param>
        /// <param name="type"></param>
        /// <param name="num"></param>
        /// <returns>empty</returns>
        private void ReadAndVerifyCount(Enums.ResourceType resourceType, string type, int num)
        {
            string errorMessage = "The {0} value is wrong in response data";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "partition", AuthenticationInfoProvider.Current.DefaultPartition },
                { "requestType", 0 },
                { "resource", (int)resourceType },
                { "count", num },
            };

            if (type == "WithoutCount")
            {
                parameters.Remove("count");
            }

            ReadResponseData <Attachment> result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess <Attachment>(parameters);

            Assert.AreEqual(result.Code, Enums.PublicAPIResultCode.Success, string.Format("Read {0}' attachment failed", resourceType.ToString()));
            Assert.That(result.Items.Count, Is.EqualTo(num), string.Format(errorMessage, "Count"));
            Assert.That(result.Count, Is.EqualTo(num), string.Format(errorMessage, "Count"));
        }
Example #18
0
        public void TestCreateProcessMultipleLine(string str)
        {
            Process resource = CreateProcessWithPhase();

            resource.PhaseMemo = str;
            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_PhaseMemo", resource.PhaseMemo }
            };

            VerifyFieldData(id, fields);
        }
Example #19
0
        public void TestCreateProcessCurrency(string value)
        {
            Process resource = CreateProcess();

            resource.ExpectedSalesAmount = Util.GetRandomNumber().ToString();
            string id = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(resource, cleanupAction: null);

            int  resourceId = -1;
            bool parsed     = int.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_ExpectedSalesAmount", resource.ExpectedSalesAmount }
            };

            VerifyFieldData(id, fields);
        }
Example #20
0
        public void TestReadEmptyOrder(Enums.ResourceType resourceType)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            string fieldAlias   = string.Format("{0}.{1}", resourceName, AppField1);

            //Check registered application field
            CheckRegisteredField(resourceType, AppField1);

            string idField = (resourceType == Enums.ResourceType.Candidate) ? "Person.P_Id" : resourceType.ToString() + ".P_Id";
            Dictionary <string, object> urlParameter = new Dictionary <string, object>()
            {
                { "partition", AuthenticationInfoProvider.Current.DefaultPartition },
                { "order", fieldAlias },
            };

            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!");
        }
Example #21
0
        public void TestCreateProcessDateField()
        {
            Process resource = CreateProcess();

            resource.ExpectedClosingDate = Util.ToString(DateTime.Now.AddMonths(1), true);
            string id = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(resource, cleanupAction: null);

            int  resourceId = -1;
            bool parsed     = int.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_ExpectedClosingDate", resource.ExpectedClosingDate }
            };

            VerifyFieldData(id, fields);
        }
Example #22
0
        public void TestValidSingleSearch1TextField(string fieldName, PhaseHelper.TextConditions inputCondition)
        {
            string condition = inputCondition.ToLowerString();

            string phaseMemo = records.Data[$"{defaultResource.ToPrivateEnum()}0"].PhaseEntryContents.Random().PhaseMemo;
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { PhaseApiFields.Partition, AuthenticationInfoProvider.Current.DefaultPartition },
                { PhaseApiFields.Resource, (int)defaultResource },
                { PhaseApiFields.Condition, $"{fieldName}:{condition}={phaseMemo}" },
                { PhaseApiFields.Field, fieldName },
            };

            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)
            {
                ResourceHelper.VerifySuffixTextType(condition, phaseMemo, item.Memo);
            }
        }
Example #23
0
        public void TestReadUserOptionParentOutput(int level)
        {
            // Get id from Hrbc creator
            string id = null;

            switch (level)
            {
            case 0:
                id = options.Data[0].Id.ToString();
                break;

            case 1:
                id = options.Data[0].Children[0].Id.ToString();
                break;

            case 2:
                id = options.Data[0].Children[0].Children[0].Id.ToString();
                break;

            case 3:
                id = options.Data[0].Children[0].Children[0].Children[0].Id.ToString();
                break;
            }

            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { Partition, AuthenticationInfoProvider.Current.DefaultPartition },
                { "level", -1 }
            };
            XmlHandler result = PublicApiAdapter.CreateAdapterForDefaultConnection().Read <Option>(parameters) as XmlHandler;

            Assert.NotNull(result, "Failed to parse the server's response!");
            ReadResponseData <Option> parseResult = XmlHelper.ParseXMLString <ReadResponseData <Option> >(result.RawContent);

            Assert.That(parseResult.Code, Is.EqualTo(Enums.PublicAPIResultCode.Success), Enums.Message.WRONG_ERROR_CODE);

            //Verify the Alias
            VerifyParentById(result, level, id);
        }
Example #24
0
        /// <summary>
        /// Creates a new Job
        /// </summary>
        /// <param name="clientId">Client Id</param>
        /// <param name="recruiterId">Recruiter Id</param>
        /// <returns>Job Id as string</returns>
        private string CreateJobResourceSpecifiedData(string clientId, string recruiterId)
        {
            //Create a Job
            string id       = string.Empty;
            Job    resource = new Job
            {
                Id        = "-1",
                Owner     = "1",
                Client    = clientId,
                Recruiter = recruiterId,
                Position  = "Job Position"
            };

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

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

            Assume.That(parsed);
            Assume.That(resourceId > 0, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Job"));
            return(id);
        }
Example #25
0
        public void TestUpdateSalesMultipleLineString(string text)
        {
            var    publicApiAdapter = PublicApiAdapter.CreateAdapterForDefaultConnection();
            string id       = string.Empty;
            Sales  resource = new Sales();

            resource.Id = salesId;
            Option option = new Option()
            {
                ActualXMLTag = optionSalesPhase
            };

            resource.Phase     = option;
            resource.PhaseMemo = text;

            id = publicApiAdapter.WriteSuccess(resource, cleanupAction: null);
            Assume.That(null != id, "Can not create the resource entry for Sales!!!");

            // Adding id into the static list for further cleanup
            listSalesId.Add(id);

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

            Assert.IsTrue(parsed);
            Assert.IsTrue(resourceId > 0, "Can not update the resource entry for required sales!!!");

            //Verify data
            string fields = "Sales.P_PhaseMemo";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { Parttion, AuthenticationInfoProvider.Current.DefaultPartition },
                { "condition", "Sales.P_Id:eq=" + id },
                { "field", fields }
            };
            ReadResponseData <Sales> result = publicApiAdapter.ReadSuccess <Sales>(parameters);

            Assert.AreEqual(text, result.Items[0].PhaseMemo, "Sales Phase Memo is not matched!");
        }
        private void ReadSuccessAndVerifyData(Enums.ResourceType resourceType, string fieldName, string fieldValue, FieldTypes fieldType)
        {
            string fieldAlias       = $"{resourceType.ToResourceName()}.{fieldName}";
            string normalPhoneText  = string.Empty;
            string specialPhoneText = string.Empty;

            switch (fieldType)
            {
            case FieldTypes.SystemField:
                normalPhoneText  = NormalPhoneTextSystem;
                specialPhoneText = SpecialPhoneTextSystem;
                break;

            case FieldTypes.ApplicationField:
                normalPhoneText  = NormalPhoneTextApp;
                specialPhoneText = SpecialPhoneTextApp;
                break;

            case FieldTypes.UserField:
                normalPhoneText  = NormalPhoneTextUser;
                specialPhoneText = SpecialPhoneTextUser;
                break;
            }

            Dictionary <string, object> urlParameters = new Dictionary <string, object>()
            {
                { "partition", AuthenticationInfoProvider.Current.DefaultPartition },
                { "keywords", fieldValue },
                { "field", fieldAlias },
                { "count", 200 } //max count
            };

            ReadResponseData <XmlResource> result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess(resourceType.ToString(), urlParameters);

            Assert.That(result.Code, Is.EqualTo(Enums.PublicAPIResultCode.Success), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceType.ToString()));
            Assert.That(result.Total, Is.GreaterThanOrEqualTo(RecordNumber), Enums.Message.TOTAL_ERROR);
            Assert.That(result.Items.Where(item => (item.DictionaryValues[fieldAlias].ToString() == normalPhoneText) || item.DictionaryValues[fieldAlias].ToString() == specialPhoneText).Count, Is.GreaterThanOrEqualTo(RecordNumber), "The keyword does not search correctlly!");
        }
Example #27
0
        public void TestValidSingleSearchNumberField(string fieldName, string condition)
        {
            string conditionValue1 = PhaseHelper.GeneratePhaseNumberType(defaultResource, fieldName, indexFirstPhaseList);
            string conditionValue2 = PhaseHelper.GeneratePhaseNumberType(defaultResource, fieldName, indexSecondPhaseList);
            string tempCond        = $"{fieldName}:{condition}={conditionValue1}";
            string formatCond      = condition == DateTimeValidator.Or ? $"{tempCond}:{conditionValue2}" : tempCond;

            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { PhaseApiFields.Partition, AuthenticationInfoProvider.Current.DefaultPartition },
                { PhaseApiFields.Resource, (int)defaultResource },
                { PhaseApiFields.Condition, formatCond },
                { PhaseApiFields.Field, fieldName },
            };
            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)));

            //Read & verify the field's value
            if (fieldName == PhaseApiFields.RegistrationDate || fieldName == PhaseApiFields.UpdateDate || fieldName == PhaseApiFields.Date)
            {
                Dictionary <string, string> conditionParameters = new Dictionary <string, string>()
                {
                    { DateTimeValidator.FieldAlias1, fieldName },
                    { DateTimeValidator.Condition1, condition },
                    { DateTimeValidator.ConditionValue1, conditionValue1 },
                    { DateTimeValidator.ConditionValue2, conditionValue2 },
                };
                DateTimeValidator.VerifySingleSearchSystemFieldPhase(defaultResource, conditionParameters);
            }
            else
            {
                foreach (var item in result.Items)
                {
                    DateTimeValidator.ConditionalAssertions[condition](int.Parse(item.DictionaryValues[fieldName].ToString()), int.Parse(conditionValue1), int.Parse(conditionValue2));
                }
            }
        }
        /// <summary>
        /// Creates a new Resume
        /// </summary>
        /// <returns>Resume id</returns>
        private string PrepareResume()
        {
            string candidateId = string.Empty;
            string id          = string.Empty;
            int    resourceId  = -1;
            bool   parsed      = false;

            if (PublicAPISetUp.ListResumeId.Count > 0)
            {
                id = PublicAPISetUp.ListResumeId.Random();
            }
            else
            {
                var publicApiAdapter = PublicApiAdapter.CreateAdapterForDefaultConnection();
                if (PublicAPISetUp.ListCandidateId.Count > 0)
                {
                    candidateId = PublicAPISetUp.ListCandidateId.Random();
                }
                else
                {
                    candidateId = (new ResourceCreator <Candidate>(publicApiAdapter)).Create();
                    //Assert.IsNotNullOrEmpty(candidateId);
                    parsed = Int32.TryParse(candidateId, out resourceId);
                    Assume.That(parsed);
                    Assume.That(resourceId > 0, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Candidate"));
                    PublicAPISetUp.ListCandidateId.Add(candidateId);
                }
                Resume resource = CreateResumeResourceSpecifiedData(candidateId);
                id = publicApiAdapter.WriteSuccess(resource, cleanupAction: null);
                //Assert.IsNotNullOrEmpty(id);
                resourceId = -1;
                parsed     = Int32.TryParse(id, out resourceId);
                Assume.That(parsed);
                Assume.That(resourceId > 0, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Resume"));
                PublicAPISetUp.ListResumeId.Add(id);
            }
            return(id);
        }
Example #29
0
        public void TestUpdateFieldUsingEmpty_Fail(string fieldName, string fieldValue)
        {
            Candidate candidate = new Candidate()
            {
                Id    = "-1",
                Owner = "1",
            };

            candidate.DictionaryValues[fieldName] = fieldValue;

            // Create New Resource
            string candidateId = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(candidate, null);

            Assume.That(!string.IsNullOrEmpty(candidateId), "Unable to create new resource");

            // Adding id into the static list for further cleanup
            PublicAPISetUp.ListCandidateId.Add(candidateId);

            // Update Resource
            candidate = new Candidate()
            {
                Id = candidateId,
            };
            candidate.DictionaryValues[fieldName] = string.Empty;

            XmlHandler handler = PublicApiAdapter.CreateAdapterForDefaultConnection().Write(candidate, AuthenticationInfoProvider.Current.DefaultPartition) as XmlHandler;

            Assert.NotNull(handler);
            Assert.NotNull(handler.XML);
            Assert.AreEqual(HttpStatusCode.OK, handler.HttpCode);

            XElement xmlCode = handler.XML.Descendants("Code").First();

            Assert.NotNull(xmlCode);

            Assert.AreEqual(Enums.PublicAPIResultCode.InvalidParameterValue.ToString(), xmlCode.Value,
                            string.Format("It shouldn't be possible to update resource: {0} using Empty Value", candidateId));
        }
Example #30
0
        public void TestReadSingleOrder(Enums.ResourceType resourceType, DisplayType displayType, string order)
        {
            string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString();
            string fieldAlias   = customFields.Data[$"{resourceType}-{displayType}-field1"].Field.ToAlias();

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

            List <XmlResource> resourceList = new Dictionary <int, string> {
                { 1, fieldValue1 }, { 2, fieldValue2 }, { 3, fieldValue3 }
            }
            .Select(item => {
                var resource = CreateResourceInstance(resourceType, item.Key);
                resource.DictionaryValues[fieldAlias] = new Option()
                {
                    ActualXMLTag = item.Value
                };
                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}:{1}", fieldAlias, order) },
            };

            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!");
        }