Beispiel #1
0
        public void ValidDuplicateParameterUpdateSublistMenuTest(SublistMenuTestData.DuplicateUpdateSublistMenuLayout duplicate)
        {
            var handler  = new HrbcSublistManager();
            var response = handler.SublistMenuLayout <object>(SublistMenuTestData.ValidDuplicateSublistMenuLayoutMapper[duplicate], HttpMethod.POST.ToNetHttpMethod());

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not update sublist menu");
        }
        public void InvalidMethodSublistMenuLayoutTest(HttpMethod httpMethod)
        {
            var handler  = new HrbcSublistManager();
            var response = handler.SublistMenuLayout <object>(httpMethod.ToNetHttpMethod());

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.NotFound), $"{httpMethod} method of sublist-menu-layout successfully");
        }
Beispiel #3
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 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");
        }
Beispiel #5
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");
        }
Beispiel #6
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");
        }
Beispiel #7
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");
        }
Beispiel #8
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);
        }
Beispiel #9
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");
            }
        }