public void InvalidIdFieldsEnableInjectionUpdateSublistMenuTest(InjectionInput injection)
        {
            var handler  = new HrbcSublistManager();
            var sublist  = SublistMenuTestData.GetSublistOfSpecificMenuId(SublistMenuTestData.MenuId[ResourceId.Client], handler);
            var request  = SublistMenuTestData.GetSublistMenuUpdateRequest(sublist.Id, SublistMenuTestData.GetSublistMenuUpdateIdFields(InjectionInputData.InjectionInputMapper[injection]), SublistMenuTestData.GetSublistMenuUpdateLabelValue(SublistMenuTestData.ValidLabelMapper[SublistMenuTestData.LabelValue.StringNoSpaceBoth]));
            var response = handler.SublistMenu <object>(request, HttpMethod.PUT.ToNetHttpMethod());

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still able to update sublist menu");
        }
        public void ValidLabelValueInjectionUpdateSublistMenuTest(InjectionInput injection)
        {
            var handler  = new HrbcSublistManager();
            var sublist  = SublistMenuTestData.GetSublistOfSpecificMenuId(SublistMenuTestData.MenuId[ResourceId.Client], handler);
            var request  = SublistMenuTestData.GetSublistMenuUpdateRequest(sublist.Id, SublistMenuTestData.GetSublistMenuUpdateIdFields(SublistMenuTestData.ValidFieldMapper[SublistMenuTestData.FieldsInput.SystemAllDefaultField](sublist.IdFields.Enabled)), SublistMenuTestData.GetSublistMenuUpdateLabelValue(InjectionInputData.InjectionInputMapper[injection]));
            var response = handler.SublistMenu <object>(request, HttpMethod.PUT.ToNetHttpMethod());

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not update sublist menu");
        }
        public void InvalidJsonSublistMenuDefaultTest(InvalidSpecialCondition json)
        {
            var handler     = new HrbcSublistManager();
            var sublist     = SublistMenuTestData.GetSublistOfSpecificMenuId(SublistMenuTestData.MenuId[ResourceId.Client], handler);
            var requestJson = SublistMenuTestData.GetSublistMenuDefaultRequest(sublist.Id, SublistMenuTestData.ValidUnixTimeStamp).ToDictionary(r => r.Key, r => (object)r.Value).ToJson();
            var response    = handler.SublistMenuDefault <object>(SublistMenuTestData.InvalidBodyJsonTestCasesMapper[json](requestJson), HttpMethod.GET.ToNetHttpMethod());

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), $"Send {json} with api sublist-menu-default successfully");
        }
        public void InvalidJsonSublistMenuTest(InvalidSpecialCondition json)
        {
            var handler     = new HrbcSublistManager();
            var sublist     = SublistMenuTestData.GetSublistOfSpecificMenuId(SublistMenuTestData.MenuId[ResourceId.Client], handler);
            var requestJson = SublistMenuTestData.GetSublistMenuUpdateRequest(sublist.Id, SublistMenuTestData.GetSublistMenuUpdateIdFields(SublistMenuTestData.ValidFieldMapper[SublistMenuTestData.FieldsInput.SystemAllDefaultField](sublist.IdFields.Enabled)), SublistMenuTestData.GetSublistMenuUpdateLabelValue(SublistMenuTestData.ValidLabelMapper[SublistMenuTestData.LabelValue.StringNoSpaceBoth])).ToJson();
            var response    = handler.SublistMenu <object>(SublistMenuTestData.InvalidBodyJsonTestCasesMapper[json](requestJson), HttpMethod.PUT.ToNetHttpMethod());

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), $"Send {json} with api sublist-menu successfully");
        }
        public void ValidReturnJsonContentTypeGetSublistMenuDefaultTest()
        {
            var handler  = new HrbcSublistManager();
            var sublist  = SublistMenuTestData.GetSublistOfSpecificMenuId(SublistMenuTestData.MenuId[ResourceId.Client], handler);
            var request  = SublistMenuTestData.GetSublistMenuDefaultRequest(sublist.Id, SublistMenuTestData.ValidUnixTimeStamp);
            var response = handler.SublistMenuDefault(request, HttpMethod.GET.ToNetHttpMethod());

            PrAssert.That(response.IsSuccessStatusCode, "Can not update custom action");
            PrAssert.That(response.Content.Headers.ContentType.MediaType, PrIs.EqualTo("application/json"), "The content type is not as expected");
        }
        public void InvalidGetSublistMenuDefaultTest(string param, SublistMenuTestData.InvalidValue invalidValue)
        {
            var handler = new HrbcSublistManager();
            var sublist = SublistMenuTestData.GetSublistOfSpecificMenuId(SublistMenuTestData.MenuId[ResourceId.Client], handler);
            var request = SublistMenuTestData.GetSublistMenuDefaultRequest(sublist.Id, SublistMenuTestData.ValidUnixTimeStamp).ToDictionary(r => r.Key, r => (object)r.Value);

            SublistMenuTestData.InvalidValueMapper[invalidValue](request, param);
            var response = handler.SublistMenuDefault <SublistMenuDefaultResponse>(request.ToDictionary(r => r.Key, r => r.Value.ToString()), HttpMethod.GET.ToNetHttpMethod());

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Receive sublist menu default");
        }
        public void ValidGetSublistMenuDefaultTest(ResourceId resourceId, bool isCustomMenu, SublistMenuTestData.ValidUnderScope validUnderScope)
        {
            var handler = new HrbcSublistManager();
            var sublist = SublistMenuTestData.GetSublistOfSpecificMenuId(isCustomMenu ? SublistMenuTestData.ValidMenuIdMapper[resourceId] : SublistMenuTestData.MenuId[resourceId], handler);
            var request = SublistMenuTestData.GetSublistMenuDefaultRequest(sublist.Id, SublistMenuTestData.ValidUnixTimeStamp);

            SublistMenuTestData.ValidUnderScopeMapper[validUnderScope](request);
            var response = handler.SublistMenuDefault <SublistMenuDefaultResponse>(request, HttpMethod.GET.ToNetHttpMethod());

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not get sublist menu default");
        }
        public void InvalidIdFieldsEnableUpdateSublistMenuTest(string param, SublistMenuTestData.InvalidValue invalidValue)
        {
            var handler   = new HrbcSublistManager();
            var sublist   = SublistMenuTestData.GetSublistOfSpecificMenuId(SublistMenuTestData.MenuId[ResourceId.Client], handler);
            var enableDic = new Dictionary <string, object> {
                ["enabled"] = SublistMenuTestData.ValidFieldMapper[SublistMenuTestData.FieldsInput.SystemAllDefaultField](sublist.IdFields.Enabled)
            };

            SublistMenuTestData.InvalidValueMapper[invalidValue](enableDic, param);
            var request  = SublistMenuTestData.GetSublistMenuUpdateRequest(sublist.Id, enableDic, SublistMenuTestData.GetSublistMenuUpdateLabelValue(SublistMenuTestData.ValidLabelMapper[SublistMenuTestData.LabelValue.StringNoSpaceBoth]));
            var response = handler.SublistMenu <object>(request, HttpMethod.PUT.ToNetHttpMethod());

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still able to update sublist menu");
        }
        public void ValidUpdateSublistMenuTest(ResourceId resourceId, bool isCustomMenu, SublistMenuTestData.FieldsInput fieldsInput, SublistMenuTestData.LabelValue labelValue)
        {
            var handler  = new HrbcSublistManager();
            var menuId   = isCustomMenu ? SublistMenuTestData.ValidMenuIdMapper[resourceId] : SublistMenuTestData.MenuId[resourceId];
            var sublist  = SublistMenuTestData.GetSublistOfSpecificMenuId(menuId, handler);
            var request  = SublistMenuTestData.GetSublistMenuUpdateRequest(sublist.Id, SublistMenuTestData.GetSublistMenuUpdateIdFields(SublistMenuTestData.ValidFieldMapper[fieldsInput](sublist.IdFields.Enabled)), SublistMenuTestData.GetSublistMenuUpdateLabelValue(SublistMenuTestData.ValidLabelMapper[labelValue]));
            var response = handler.SublistMenu <object>(request, HttpMethod.PUT.ToNetHttpMethod());

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not update sublist menu");
            var sublists = handler.SublistsMenu <SublistsMenuResponse>(new Dictionary <string, string> {
                ["menu_id"] = menuId.ToString()
            }, HttpMethod.GET.ToNetHttpMethod());
            var specificSublist = sublists.Result.Values.Where(value => value.Value.Id == sublist.Id).Select(dic => dic.Value).SingleOrDefault();

            PrAssert.That(specificSublist.Label.EnUs.Value, PrIs.EqualTo(SublistMenuTestData.ValidLabelMapper[labelValue]), "Value of en_us is not as expected");
            PrAssert.That(specificSublist.Label.Ja.Value, PrIs.EqualTo(SublistMenuTestData.ValidLabelMapper[labelValue]), "Value of ja is not as expected");
            PrAssert.That(specificSublist.IdFields.Enabled, PrIs.EqualTo(SublistMenuTestData.ValidFieldMapper[fieldsInput](sublist.IdFields.Enabled)), "Value of enable is not as expected");
        }