Ejemplo n.º 1
0
        private void SuccessPerform(Dictionary <string, string> request)
        {
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <List <GetMenuListResponse> >(request, System.Net.Http.HttpMethod.Get);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
        }
Ejemplo n.º 2
0
        public void ValidDuplicatedParamsTests(Params param, Duplicated type)
        {
            var request = DuplicateGetRequest(type, param);
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <GetMenuContentShowResponse>(request, System.Net.Http.HttpMethod.Get);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            var resultResponse = 0;
            var expected       = 0;
            var response       = result.Result.Values["5"];

            foreach (var items in response)
            {
                resultResponse += items.Value.Count;
            }
            var expectedData = DataVerificationCreator.Data.Values;

            foreach (var item in expectedData)
            {
                if (item.Value.MenuId == 5 && item.Value.Enabled != 0)
                {
                    expected++;
                }
            }
            PrAssert.That(resultResponse, PrIs.EqualTo(expected));
        }
Ejemplo n.º 3
0
        private void ErrorPerform(Dictionary <string, object> request)
        {
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <object>(request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(result, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Ejemplo n.º 4
0
        public void InvalidSpecialTest()
        {
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <object>(System.Net.Http.HttpMethod.Get);

            PrAssert.That(result, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Ejemplo n.º 5
0
        public void ValidSpecialTest(ResourceId resourceId, Special testcase)
        {
            var request = new Dictionary <string, string>
            {
                [ParamsMapper[Params.MenuId]] = MenuId[resourceId].ToString()
            };
            var sublistId = testcase == Special.ArraySomeSublistIds
                ? RandomSomeValues(2, SublistId[resourceId]).ToArray()
                : RandomSomeValues(SublistId[resourceId].Count, SublistId[resourceId]).ToArray();

            request[ParamsMapper[Params.SublistId]] = $"{sublistId}";

            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <GetMenuContentShowResponse>(request, System.Net.Http.HttpMethod.Get);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            var resultResponse = 0;
            var expected       = 0;

            foreach (var id in sublistId)
            {
                var items = result.Result.Values[MenuId[resourceId].ToString()][id.ToString()];
                resultResponse += items.Count;
                var expectedData = DataVerificationCreator.Data.Values;
                foreach (var item in expectedData)
                {
                    if (item.Value.MenuId == MenuId[resourceId] && item.Value.Enabled != 0)
                    {
                        expected++;
                    }
                }
            }
            PrAssert.That(resultResponse, PrIs.EqualTo(expected));
        }
        public void InvalidJsonFormatTests(InvalidJsonFormat testcase)
        {
            var request = InvalidJsonFormatPutActionMenuLayout[testcase];
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <object>(request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(result, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Ejemplo n.º 7
0
        public static PutActionMenuResponse PrepareData()
        {
            var manager = new ActionMenuManager(EndpointMapper[ActionMenuEndpointType.GetMenuContentToEdit]);
            var result  = manager.Execute <PutActionMenuResponse>(System.Net.Http.HttpMethod.Get);

            Assume.That(result, PrIs.SuccessfulResponse(), "Create verify data is failed.");
            return(result.Result);
        }
Ejemplo n.º 8
0
        private void SuccessPerform(Dictionary <string, string> request, string type, List <int> value)
        {
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <GetMenuContentEditResponse>(request, System.Net.Http.HttpMethod.Get);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            VerifyData(result, type, value);
        }
Ejemplo n.º 9
0
        public void ValidSpecialTest()
        {
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <GetMenuContentEditResponse>(System.Net.Http.HttpMethod.Get);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            PrAssert.That(result.Result.Data.Count, PrIs.EqualTo(DataVerificationCreator.Data.Values.Count));
        }
Ejemplo n.º 10
0
        private void SuccessPerform(Dictionary <string, object> request)
        {
            var requestDict = request.ToDictionary(i => i.Key, i => i.Value.ToString());
            var manager     = new ActionMenuManager(Endpoint);
            var result      = manager.Execute <PutActionMenuResponse>(requestDict, string.Empty, System.Net.Http.HttpMethod.Put);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));
        }
Ejemplo n.º 11
0
        public void ValidDuplicatedParamsTests(Params param, Duplicated type)
        {
            var request = DuplicatePutActionResetRequest(type, param == Params.MenuId ? "menu_id" : "action_menu_id");
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <PutActionMenuResponse>(request, string.Empty, System.Net.Http.HttpMethod.Put);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));
        }
Ejemplo n.º 12
0
        public void VerifyResponseContentTest()
        {
            var request = DefaultPutRequest(ActionMenuEndpointType.PutActionMenuReset);
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute(null, request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(result.Content.Headers.ContentType.MediaType, PrIs.EqualTo("application/json"));
        }
Ejemplo n.º 13
0
        private void SuccessPerform(Dictionary <string, object> request)
        {
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <Dictionary <string, string> >(request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));
            PrAssert.That(result.Result["status"], PrIs.EqualTo("ok"));
        }
Ejemplo n.º 14
0
        public void InvalidMethodTests(HttpMethod method)
        {
            var request = DefaultPutRequest(ActionMenuEndpointType.PutActionMenuReset);
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <object>(request, method.ToNetHttpMethod());

            PrAssert.That(result, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.NotFound));
        }
Ejemplo n.º 15
0
        public void InvalidSpecialTest(InvalidLabelSpecial testcase)
        {
            var request = InvalidLabelSpecialMapper[testcase];
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <object>(request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(result, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Ejemplo n.º 16
0
        public void VerifyResponseContentTest()
        {
            var request = DefaultGetRequest(Params.MenuId);
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute(request, string.Empty, System.Net.Http.HttpMethod.Get);

            PrAssert.That(result.Content.Headers.ContentType.MediaType, PrIs.EqualTo("application/json"));
        }
Ejemplo n.º 17
0
        public void ValidDuplicatedParamsTests(Params param, Duplicated type)
        {
            var request = DuplicateGetRequest(type, param);
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <GetMenuContentEditResponse>(request, System.Net.Http.HttpMethod.Get);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            VerifyData(result, request.First().Key, new List <int>()
            {
                Int32.Parse(request.First().Value)
            });
        }
Ejemplo n.º 18
0
        private void SuccessPerform(Dictionary <string, object> request, int actionId, int type)
        {
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <PutActionMenuResponse>(request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));
            var verifyKeys = PrepareData();

            foreach (var item in verifyKeys.Values)
            {
                if (item.Value.ActionId == actionId)
                {
                    PrAssert.That(type == 2 ? item.Value.Position : item.Value.Enabled, PrIs.EqualTo(type));
                }
            }
        }
Ejemplo n.º 19
0
        private void SuccessPerform(Dictionary <string, string> request, Params param, int value)
        {
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <GetMenuContentShowResponse>(request, System.Net.Http.HttpMethod.Get);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            var resultResponse = 0;
            var expected       = 0;

            if (param == Params.MenuId)
            {
                var response = result.Result.Values[value.ToString()].Values;
                foreach (var item in response)
                {
                    resultResponse += item.Count;
                }
                var verifyData = DataVerificationCreator.Data.Values;
                foreach (var item in verifyData)
                {
                    if (item.Value.MenuId == value && item.Value.Enabled != 0)
                    {
                        expected++;
                    }
                }
            }
            else
            {
                var menuId   = request[ParamsMapper[param]];
                var response = result.Result.Values[menuId][value.ToString()];
                resultResponse += response.Count;
                var verifyData = DataVerificationCreator.Data.Values;
                foreach (var item in verifyData)
                {
                    if (item.Value.MenuId.ToString() == menuId && item.Value.Enabled != 0)
                    {
                        expected++;
                    }
                }
            }
            PrAssert.That(resultResponse, PrIs.EqualTo(expected));
        }
Ejemplo n.º 20
0
        public void ValidDuplicatedParamsTests(Params param, Duplicated type)
        {
            var request = type == Duplicated.SameValue
                ? DuplicatedPutRequestSameValue(ActionMenuEndpointType.PutActionMenuLayout, param)
                : DuplicatedPutRequestNotSameValue(ActionMenuEndpointType.PutActionMenuLayout, param);
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <PutActionMenuResponse>(request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));
            var verifyKeys = request.Split(',').ToList();
            var verifyData = PrepareData();
            var key        = string.Empty;
            var expected   = string.Empty;

            foreach (var item in verifyKeys)
            {
                key      = item.Contains("id") ? item.Split(':')[1].Trim(new[] { '\\', '"', ' ' }) : string.Empty;
                expected = item.Contains("position") ? item.Split(':')[1].Trim() : string.Empty;
            }
            PrAssert.That(verifyData.Values[key].Position, PrIs.EqualTo(Int32.Parse(expected)));
        }
Ejemplo n.º 21
0
        public void ValidDuplicatedParamsTests(Params param, Duplicated type)
        {
            var request = type == Duplicated.SameValue
                ? DuplicatedPutRequestSameValue(ActionMenuEndpointType.PutActionMenuLabel, param)
                : DuplicatedPutRequestNotSameValue(ActionMenuEndpointType.PutActionMenuLabel, param);
            var manager = new ActionMenuManager(Endpoint);
            var result  = manager.Execute <Dictionary <string, string> >(request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(result, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));
            PrAssert.That(result.Result["status"], PrIs.EqualTo("ok"));
            var verifyKeys    = request.Split('\"');
            var expectedLabel = "Test Update Label";

            foreach (var item in verifyKeys)
            {
                if (item.Contains("id_am_content"))
                {
                    VerifyData(item, expectedLabel);
                    break;
                }
            }
        }
Ejemplo n.º 22
0
 public void ValidDuplicatedParamsTests(Params param, Duplicated type)
 {
     var request = DuplicateGetRequest(type, param);
     var manager = new ActionMenuManager(Endpoint);
     var result  = manager.Execute <List <GetMenuListResponse> >(request, System.Net.Http.HttpMethod.Get);
 }