public void ValidCustomActionReplaceTest(ResourceId resourceId)
        {
            var requestUrl    = "http://hrbc1-web.localvm/{{" + resourceId.ToString() + ".P_Id}}";
            var expectedId    = resourceId == ResourceId.None ? 0 : RecordsCreator.Data[resourceId].Id;
            var expectUrl     = $"http://hrbc1-web.localvm/{expectedId}";
            var createRequest = CreateCustomActionTests.GetCreateRequest(requestUrl,
                                                                         CustomActionTestData.ValidLabelMapper[CustomActionTestData.ValidLabel.BothEnJa](CustomActionTestData.ValidLabelValueMapper[CustomActionTestData.ValidLabelValue.StringNoSpaceBoth]),
                                                                         CustomActionTestData.ValidPlaceValueMapper[CustomActionTestData.ValidPlaceValue.Client]);
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <CreateCustomActionResponse>(createRequest, HttpMethod.POST.ToNetHttpMethod());

            PrAssert.That(response, PrIs.SuccessfulResponse(), "Can not create custom action");
            var resourceName   = resourceId == ResourceId.Person ? "candidate" : resourceId.ToString().ToLower();
            var replaceRequest = GetReplaceRequest(response.Result.Id,
                                                   new Dictionary <string, object>
            {
                [resourceName] = resourceId == ResourceId.None ? 0 : RecordsCreator.Data[resourceId].Id,
            });

            hanlder = new CustomActionManager();
            var replaceResponse = hanlder.Replace <ReplaceCustomActionResponse>(replaceRequest, HttpMethod.POST.ToNetHttpMethod());

            PrAssert.That(replaceResponse, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create custom action");
            if (resourceId != ResourceId.None && resourceId != ResourceId.Contract)
            {
                PrAssert.That(replaceResponse.Result.Url, PrIs.EqualTo(expectUrl), "Can not create custom action");
            }
        }
        public void ValidGetCustomActionTest(CustomActionTestData.ValidUrl url, CustomActionTestData.ValidLabel validLabel, CustomActionTestData.ValidLabelValue validLabelValue, CustomActionTestData.ValidPlaceValue validPlaceValue)
        {
            var createRequest = CreateCustomActionTests.GetCreateRequest(CustomActionTestData.ValidUrlMapper[url],
                                                                         CustomActionTestData.ValidLabelMapper[validLabel](CustomActionTestData.ValidLabelValueMapper[validLabelValue]),
                                                                         CustomActionTestData.ValidPlaceValueMapper[validPlaceValue]);
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <CreateCustomActionResponse>(createRequest, HttpMethod.POST.ToNetHttpMethod());

            if (validLabel == CustomActionTestData.ValidLabel.BothEnJa)
            {
                PrAssume.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create custom action");
                var allCustomAction = hanlder.GetAllCustomActions();
                CreateCustomActionTests.DeleteCustomAction(response.Result.Id);
                PrAssert.That(allCustomAction.Result[response.Result.Id].Url, PrIs.EqualTo(CustomActionTestData.ValidUrlMapper[url]), "The url is not as expected");
                PrAssert.That(allCustomAction.Result[response.Result.Id].Label.EnUs.Value, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.ValueParam]), "The En label value is not as expected");
                PrAssert.That(allCustomAction.Result[response.Result.Id].Label.Ja.Value, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.ValueParam]), "The Ja label value is not as expected");
                if (validLabelValue != CustomActionTestData.ValidLabelValue.MissingDefaultStringWithSpace && validLabelValue != CustomActionTestData.ValidLabelValue.MissingDefaultStringNoSpace)
                {
                    PrAssert.That(allCustomAction.Result[response.Result.Id].Label.Ja.Default, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.DefaultParam]), "The Ja label default is not as expected");
                    PrAssert.That(allCustomAction.Result[response.Result.Id].Label.EnUs.Default, PrIs.EqualTo(CustomActionTestData.ValidLabelValueMapper[validLabelValue][CustomActionTestData.DefaultParam]), "The En label default is not as expected");
                }
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Create custom action Successfully");
            }
        }
        public void ValidSpecialCustomActionReplaceTest(ResourceId resourceId, string fieldName)
        {
            string fieldAlias    = $"{resourceId.ToAlias()}.{fieldName}";
            var    recordHandler = new RecordManager();
            var    res           = recordHandler.ReadRecords(
                RecordRequestComposer.ComposeReadRequest()
                .ForResource((TestCoreFramework.Enums.ResourceType)(int) resourceId)
                .WithIds((int)RecordsCreator.Data[resourceId].Id)
                .Fields($"{resourceId.ToAlias()}.P_Id", fieldAlias)
                .Result);
            var recordValue = res.Result.Items[0];

            if (fieldName.EndsWith("Date") || fieldName == "P_Owner")
            {
                recordValue[fieldAlias] = recordValue[fieldAlias].ToString().Replace("/", "-").Replace("[\r\n", "").Replace("\r\n]", "").Split('.')[0].Trim();
            }
            var requestUrl    = $"hrbc1-web.localvm/{{{{{fieldAlias}}}}}";
            var expectUrl     = $"hrbc1-web.localvm/{recordValue[fieldAlias].ToString()}";
            var createRequest = CreateCustomActionTests.GetCreateRequest(requestUrl,
                                                                         CustomActionTestData.ValidLabelMapper[CustomActionTestData.ValidLabel.BothEnJa](CustomActionTestData.ValidLabelValueMapper[CustomActionTestData.ValidLabelValue.StringNoSpaceBoth]),
                                                                         CustomActionTestData.ValidPlaceValueMapper[CustomActionTestData.ValidPlaceValue.Client]);
            var hanlder  = new CustomActionManager();
            var response = hanlder.CustomAction <CreateCustomActionResponse>(createRequest, HttpMethod.POST.ToNetHttpMethod());

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create custom action");
            var resourceName   = resourceId == ResourceId.Person ? "candidate" : resourceId.ToString().ToLower();
            var replaceRequest = GetReplaceRequest(response.Result.Id,
                                                   new Dictionary <string, object>
            {
                [resourceName] = resourceId == ResourceId.None ? 0 : RecordsCreator.Data[resourceId].Id,
            });

            hanlder = new CustomActionManager();
            var replaceResponse = hanlder.Replace <ReplaceCustomActionResponse>(replaceRequest, HttpMethod.POST.ToNetHttpMethod());

            PrAssert.That(replaceResponse, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not create custom action");
            var convertedUrl = WebUtility.UrlDecode(replaceResponse.Result.Url).Trim();

            PrAssert.That(convertedUrl, PrIs.EqualTo(expectUrl), "Can not create custom action");
        }