Example #1
0
        public void ValidLayoutSpecialGetSublistsMenuTest(ResourceId resourceId, bool isCustomMenu, SublistMenuTestData.EnableDisableValue enabledisable)
        {
            var handler = new HrbcSublistManager();
            var menuId  = isCustomMenu ? SublistMenuTestData.ValidMenuIdMapper[resourceId] : SublistMenuTestData.MenuId[resourceId];
            var request = SublistMenuTestData.GetSublistMenuLayoutRequest(menuId, new List <int>(), new List <int>());

            SublistMenuTestData.ValidEnableDisableMapper[enabledisable](request, CurrentSublist.Data[menuId].Select(value => value.Id).ToList());
            var response = handler.SublistMenuLayout <object>(request, HttpMethod.PUT.ToNetHttpMethod());

            PrAssume.That(response, PrIs.SuccessfulResponse(), "Can not update sublist menu layout");
            var getRequest = new Dictionary <string, string>()
            {
                ["menu_id"] = menuId.ToString()
            };
            var sublists = handler.SublistsMenu <SublistsMenuResponse>(getRequest, HttpMethod.GET.ToNetHttpMethod());

            PrAssert.That(sublists, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not get sublists menu");
            var resultEnableList  = sublists.Result.Values.Where(v => v.Value.Enabled == 1).Select(value => value.Value.Id);
            var resultDisableList = sublists.Result.Values.Where(v => v.Value.Enabled == 0).Select(value => value.Value.Id);

            foreach (var item in (IEnumerable <int>)request["enabled"])
            {
                PrAssert.That(resultEnableList.Contains(item), "enabled is not as expected");
            }
            foreach (var item in (IEnumerable <int>)request["disabled"])
            {
                PrAssert.That(resultDisableList.Contains(item), "disabled is not as expected");
            }
        }
        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 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 InvalidJsonSublistMenuLayoutTest(InvalidSpecialCondition json)
        {
            var handler     = new HrbcSublistManager();
            var menuId      = SublistMenuTestData.ValidMenuIdMapper[ResourceId.Client];
            var requestJson = SublistMenuTestData.GetSublistMenuLayoutRequest(menuId, new List <int>(), new List <int>()).ToJson();
            var response    = handler.SublistMenuLayout <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-layout 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");
        }
Example #8
0
        private static void InvalidInjectionUpdateSublistMenuLayoutTest(string param, InjectionInput injection)
        {
            var handler = new HrbcSublistManager();
            var menuId  = SublistMenuTestData.ValidMenuIdMapper[ResourceId.Client];
            var request = SublistMenuTestData.GetSublistMenuLayoutRequest(menuId, CurrentSublist.Data[menuId].Where(v => v.Enabled == 1).Select(value => value.Id).ToList(), CurrentSublist.Data[menuId].Where(v => v.Enabled == 0).Select(value => value.Id).ToList());

            request[param] = InjectionInputData.InjectionInputMapper[injection];
            var response = handler.SublistMenuLayout <object>(request, HttpMethod.PUT.ToNetHttpMethod());

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still able to update sublist menu layout");
        }
        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");
        }
Example #11
0
        public void ValidUpdateSublistMenuLayoutTest(ResourceId resourceId, bool isCustomMenu, SublistMenuTestData.EnableDisableValue enabledisable)
        {
            var handler = new HrbcSublistManager();
            var menuId  = isCustomMenu ? SublistMenuTestData.ValidMenuIdMapper[resourceId] : SublistMenuTestData.MenuId[resourceId];
            var request = SublistMenuTestData.GetSublistMenuLayoutRequest(menuId, new List <int>(), new List <int>());

            SublistMenuTestData.ValidEnableDisableMapper[enabledisable](request, CurrentSublist.Data[menuId].Select(value => value.Id).ToList());
            var response = handler.SublistMenuLayout <object>(request, HttpMethod.PUT.ToNetHttpMethod());

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not update sublist menu layout");
        }
Example #12
0
        public void InvalidSpecialUpdateSublistMenuLayoutTest(SublistMenuTestData.InvalidEnableDisableValue invalidValue)
        {
            var handler = new HrbcSublistManager();
            var menuId  = SublistMenuTestData.ValidMenuIdMapper[ResourceId.Client];
            var request = SublistMenuTestData.GetSublistMenuLayoutRequest(menuId, CurrentSublist.Data[menuId].Where(v => v.Enabled == 1).Select(value => value.Id).ToList(), CurrentSublist.Data[menuId].Where(v => v.Enabled == 0).Select(value => value.Id).ToList());

            SublistMenuTestData.InvalidEnableDisableMapper[invalidValue](request, CurrentSublist.Data[menuId].Select(value => value.Id).ToList());
            var response = handler.SublistMenuLayout <object>(request, HttpMethod.PUT.ToNetHttpMethod());

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still able to update sublist menu layout");
        }
Example #13
0
 private static void VerifyResetLayoutResponse(HrbcSublistManager handler, PrivateApiResponse <SublistsMenuResponse> resetResponse)
 {
     foreach (var key in resetResponse.Result.Values.Keys)
     {
         var sublistRequest  = SublistMenuTestData.GetSublistMenuDefaultRequest(resetResponse.Result.Values[key].Id, SublistMenuTestData.ValidUnixTimeStamp);
         var sublistResponse = handler.SublistMenuDefault <SublistMenuDefaultResponse>(sublistRequest, HttpMethod.GET.ToNetHttpMethod());
         PrAssume.That(sublistResponse, PrIs.SuccessfulResponse(), "Can not get sublist menu default");
         foreach (var field in resetResponse.Result.Values[key].IdFields.Enabled)
         {
             PrAssert.That(sublistResponse.Result.IdFields.Enabled.Contains(field), "Response not contains the expected fields");
         }
     }
 }
        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");
        }
        public void ValidDuplicateGetSublistMenuDefaultTest(SublistMenuTestData.DuplicateGetSublistMenuDefault duplicateGet)
        {
            var handler  = new HrbcSublistManager();
            var menuId   = SublistMenuTestData.MenuId[ResourceId.Client];
            var sublists = handler.SublistsMenu <SublistsMenuResponse>(new Dictionary <string, string> {
                ["menu_id"] = menuId.ToString()
            }, HttpMethod.GET.ToNetHttpMethod());

            PrAssume.That(sublists, PrIs.SuccessfulResponse());
            var sublist      = sublists.Result.Values.FirstOrDefault().Value;
            var validRequest = SublistMenuTestData.GetSublistMenuDefaultRequest(sublist.Id, SublistMenuTestData.ValidUnixTimeStamp);
            var request      = validRequest.ToList();

            SublistMenuTestData.ValidDuplicateSublistMenuDefaultMapper[duplicateGet](request, sublist.Id.ToString(), sublists.Result.Values.LastOrDefault().Value.Id.ToString(), "1536741227");
            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");
        }
Example #17
0
        public void ValidSpecialUpdateSublistMenuResetLayoutTest(ResourceId resourceId, bool isCustomMenu, SublistMenuTestData.EnableDisableValue enabledisable)
        {
            var handler = new HrbcSublistManager();
            var menuId  = isCustomMenu ? SublistMenuTestData.ValidMenuIdMapper[resourceId] : SublistMenuTestData.MenuId[resourceId];
            var request = SublistMenuTestData.GetSublistMenuLayoutRequest(menuId, new List <int>(), new List <int>());

            SublistMenuTestData.ValidEnableDisableMapper[enabledisable](request, CurrentSublist.Data[menuId].Select(value => value.Id).ToList());
            var response = handler.SublistMenuLayout <object>(request, HttpMethod.PUT.ToNetHttpMethod());

            PrAssume.That(response, PrIs.SuccessfulResponse(), "Can not update sublist menu layout");
            var resetRequest = new Dictionary <string, string>()
            {
                ["menu_id"] = menuId.ToString(),
            };
            var resetResponse = handler.SublistMenuResetLayout <SublistsMenuResponse>(resetRequest, HttpMethod.PUT.ToNetHttpMethod());

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not update sublist menu reset layout");
            VerifyResetLayoutResponse(handler, resetResponse);
        }
Example #18
0
        public void ValidSpecialUpdateSublistMenuLayoutTest(string param)
        {
            var handler     = new HrbcSublistManager();
            var menuId      = SublistMenuTestData.ValidMenuIdMapper[ResourceId.Client];
            var request     = SublistMenuTestData.GetSublistMenuLayoutRequest(menuId, CurrentSublist.Data[menuId].Where(v => v.Enabled == 1).Select(value => value.Id).ToList(), CurrentSublist.Data[menuId].Where(v => v.Enabled == 0).Select(value => value.Id).ToList());
            var shuffleList = (request[param] as List <int>);

            shuffleList.Shuffle();
            request[param] = shuffleList;
            var response = handler.SublistMenuLayout <object>(request, HttpMethod.PUT.ToNetHttpMethod());

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not update sublist menu layout");
            var sublists = handler.SublistsMenu <SublistsMenuResponse>(new Dictionary <string, string> {
                ["menu_id"] = menuId.ToString()
            }, HttpMethod.GET.ToNetHttpMethod());
            var result = sublists.Result.Values.Where(v => v.Value.Enabled == (param == "enabled" ? 1 : 0)).Select(value => value.Value).ToList();

            for (int i = 0; i < result.Count; i++)
            {
                PrAssert.That(result.Find(r => r.Position == i).Id, PrIs.EqualTo(shuffleList[i]), "The position is not as expected");
            }
        }